Skip to content

Instantly share code, notes, and snippets.

@xeoncross
Last active March 25, 2019 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xeoncross/acc943675bcfb5c823f293ec6a58309a to your computer and use it in GitHub Desktop.
Save xeoncross/acc943675bcfb5c823f293ec6a58309a to your computer and use it in GitHub Desktop.
Amazon DynamoDB

Amazon DynamoDB

Amazon DynamoDB supports several more advanced key/value operations:

  • Batch Operations
  • Atomic Counters
  • Conditional Writes
  • Time To Live

These are important as Conditional Writes could be used for acquiring locks allowing a single instance to work on some data in a more race-safe way.

Articles

Reviews

Ways to create useful Composite keys (Partition Key + Sort Key)

Using primary, secondary, and data keys in unique (and sometimes repeating) ways you can work complex relationships into simple tables.

  • STATIC string / sparse index:
    • 'PRDOUCT' + 'discontinued' lets us find all discontinued products easily
    • 'ORDER' + DATE lets us find all orders of a certain date
  • Write Sharding:
    • Append a random value to the end of the PK to partition writes
    • Append a known value to the end of the PK % module + 1
  • hierarchical sort key
    • Combine multiple values into a single key. This : COUNTRY##STATE##CITY or GUID + _ + DATE
    • Use range queries with operators such as starts-with, between, >, <, and so on.

Reddit

Reddit uses PostgreSQL as a glorified k/v store with two tables: Things and their Data Properties: https://www.infoq.com/presentations/reddit-architecture-evolution

This idea of a forum is repeated with the AWS sample forum webapp: Java + Angular Forum. You can see a basic schema here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SampleData.CreateTables.html#SampleData.CreateTables2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment