Site Logo
Published on

Why is DynamoDB AWSome?


What is DynamoDB?

A cloud NoSQL database service that guarantees consistent performance at any scale. Consistent Performance, Durability and High Availability are the key requirements for many mission critical use cases. DynamoDB is also hassle-free because its fully managed and serverless.

How is DynamoDB able to provide such an amazing performance?

  • It has a fairly simple and straightforward data model.
  • A key-value model. It is simple to understand and many use cases can be modelled as a key-value.
  • Each DynamoDB table is partitioned, which means each partition can be stored on a separate machine.
  • As a table is partitioned, each table can grow to any size and can serve any read-write throughput. This model is purely horizontally scalable.
  • Whats the deal with consistent performance?
    • Each partition can grow up to a predefined max size (10GB) and whenever a partition grows beyond that size a new partition is created.
    • So the old partition never gets a performance hit. It is always bounded. (to a few millis, which is absolutely insane).
    • Now that each table is partitioned, each partitioned is replicated across multiple machines that form a replica group. Each replica in a group is stored in separate AZs to support high availability.
    • This means if any replica goes down there are still other replicas that can serve read-writes.

A little more on the table structure

  • Each table is a collection of Items.
  • Each item has a primary key and a set of properties.
  • Primary key uniquely identifies every item in the table.
  • Primary key is a simple key which contains a partitionKey OR a composite key which is a combination of partitionKey and a sortKey.
  • Sort key is optional, but identifies how the key value pairs will be sorted on a partition that is identified by a partition key.
  • Primary key is hashed using a hashing function, and this hash value identifies a partition where the data is stored.
  • So for any item, a read or a write path knows very quickly which partition to go to.
  • Since read-write path always have a fixed number of hops and each partition has a max size operation latency is bounded and hence predictable.

Advanced Features

  • ACID Transactions: DynamoDB supports ACID transactions, that enables applications to update one or multiple items while ensuring atomicity, consistency, isolation and durability across items without compromising scalability, availability and performance. This is a big win for applications that fit this model and need ACID guarantees.
  • Change Data Capture (CDC): DynamoDB provides a stream of events that can be consumed to be aware of the changes happening to your table. This is a time-ordered flow of information on the changes done to the items in your DynamoDB table. Each record exists exactly once of the stream and the order of the records in the stream is exactly same as how it happened. For an in-depth understanding, refer to the DynamoDB masterclass for detailed insights into its scalability and performance.