Amazon DynamoDB System Design
A managed key-value database with predictable latency at any scale
By Ankur NayakReviewed
How AWS runs a multi-tenant NoSQL database that peaked at 89.2 million requests per second on Prime Day 2021 with single-digit-millisecond latency: tables are split into partitions, each partition is a Multi-Paxos replication group across three Availability Zones, and token buckets at the request routers keep one customer from slowing another.
Open in Studio· edit a copy- Throughput
- 89.2M requests/s peak (2021)
- Prime Day peak
- 89.2M req/s
- Availability SLA
- 99.99%
- Replicas per partition
- 3 AZs
- Metadata cache hit rate
- ~99.75%
Requirements
Functional
- Put, get, update and delete items by primary key
- Query items sharing a partition key, ordered by sort key
- Offer strongly or eventually consistent reads
- Back up and restore tables, including to a point in time
- Scale throughput up or down, or pay per request (on-demand)
Non-functional
- Predictable single-digit-millisecond latency at any table size
- Isolation between tenants sharing hardware
- 99.99% availability; no lost acknowledged writes
- No maintenance windows for customers
In depth
Predictable performance as the product
DynamoDB's headline feature isn't a query language or a data model. It is predictability: single-digit-millisecond latency for every operation, whether a table holds a megabyte or hundreds of terabytes, while thousands of customers share the same hardware. AWS described how it delivers that in a 2022 USENIX ATC paper. During Prime Day 2021, Amazon's own systems made trillions of DynamoDB calls, peaking at 89.2 million requests per second.
DynamoDB launched in 2012. Despite the name, it is not the system from the 2007 Dynamo paper. Dynamo was a single-tenant store that teams ran themselves, built on consistent hashing, sloppy quorums with hinted handoff, and vector clocks; it powered services such as Amazon's shopping cart. DynamoDB took Dynamo's lessons and combined them with the managed, elastic experience of services like S3, with a different architecture underneath.
The data model
A table holds items, each identified by a primary key: a partition key, or a partition key plus a sort key. The partition key is hashed to decide where the item lives; items sharing a partition key are stored together and ordered by the sort key, so a Query can read a range. Operations are deliberately simple (GetItem, PutItem, UpdateItem, DeleteItem, Query, Scan), which is what keeps each one's cost bounded.
Request routers, metadata and storage nodes
Every request reaches a fleet of request routers. A router authenticates and authorizes the request, looks up which storage nodes own the key, checks the table has capacity, and forwards the request.
Routing information comes from the metadata service. Because partition configuration rarely changes, router caches hit about 99.75% of the time, which is dangerous in its own way: if caches went cold at once, every request would need a lookup and the metadata store would be overwhelmed. AWS built MemDS, an in-memory distributed store holding all the metadata, scaled to handle DynamoDB's entire request rate. Routers even call MemDS asynchronously on cache hits, so its load stays constant whatever the hit rate, a constant-work design that prevents cascading failure.
Data lives on storage nodes. Tables are split into partitions, and each partition has replicas in three Availability Zones. Control-plane work, from creating tables to replacing failed replicas, splitting partitions and moving them to balance load, goes to autoadmin, which the paper calls DynamoDB's central nervous system.
A replication group per partition
A partition's replicas form a replication group that uses Multi-Paxos for leader election; see consensus. The leader keeps its role by renewing a lease. For a write, the leader generates a write-ahead log record and sends it to its peers; the write is acknowledged once a quorum has persisted the record. Each storage replica keeps the log and a B-tree of the items.
Reads come in two kinds. A strongly consistent read is served by the leader and reflects every acknowledged write. An eventually consistent read, the default, can be served by any replica and might miss a very recent write, but costs half as much: one read capacity unit buys one strongly consistent read or two eventually consistent reads per second for items up to 4 KB.
Groups can also include log replicas, which store only recent log entries, like Paxos acceptors, with no B-tree. Rebuilding a full replica takes minutes because the B-tree and logs must be copied; adding a log replica takes seconds. So when a node dies, durability is restored almost immediately while the full rebuild proceeds.
Logs are archived to S3 with checksums and manifests, and a scrub process compares live replicas with replicas rebuilt from the archive. Backups and point-in-time restore are built from those archives, so they don't affect the live table's performance.
Gray failures
Not every failure is clean. A leader can be healthy but unreachable from one follower, or from some routers. Electing a new leader on every such glitch would cause needless write pauses. So before triggering failover, a follower asks the other replicas whether they can still reach the leader, and only proceeds if they confirm. A newly elected leader serves no writes or consistent reads until the old leader's lease has expired.
The long road to fair capacity
The most instructive part of the paper is its history of admission control. At launch, a table's provisioned throughput was divided evenly across its partitions. Real workloads aren't uniform, so a hot key could be throttled even when the table as a whole had plenty of capacity.
AWS fixed this in stages. Bursting let partitions use unused capacity, kept for up to 300 seconds, for short spikes. Adaptive capacity watched tables and boosted throttled partitions, eliminating over 99.99% of throttling due to skew, but only after throttling had happened. Finally global admission control (GAC) separated admission from partitions: each router keeps local token buckets and refills them from GAC every few seconds, so a table can use its full capacity however its traffic is spread. Partition-level buckets remain as defence in depth, and partitions whose consumption crosses a threshold are split for consumption. On-demand tables then removed capacity planning altogether. See rate limiting algorithms.
The trade-offs
DynamoDB makes a clear bet. It offers a narrow API, with no joins and no arbitrary queries, so every operation has a predictable cost, and it pushes the hard work into multi-tenant isolation and healing. Applications must model their data around access patterns, choosing partition keys with many distinct values. In return, they get a database that behaves the same at any size.
Compare it with Google Spanner, which makes the opposite bet: rich transactions across shards, paid for with coordination and commit wait.
What to take into an interview
- Hash a partition key to place data; keep each operation single-partition where possible
- Replicate each partition with a leader-based consensus group across zones
- Separate a fast data plane (routers, storage) from a control plane (autoadmin)
- Do admission control globally with token buckets, not by dividing capacity evenly
- Make metadata lookups constant work so a cold cache can't cause an outage
- Restore durability fast with lightweight log-only replicas
Components
Application
AWS SDKClient. Calls GetItem, PutItem, Query and other operations over HTTPS.
Request Routers
Load balancer. Authenticate and authorize each request, look up which storage nodes hold the key, check capacity tokens, and forward the request.
Metadata Service
MemDSCache. Stores routing information for tables, indexes and replication groups. MemDS keeps it all in memory, replicated across a fleet, so it can absorb the full request rate if router caches go cold.
Why: A cold start where every request needs a metadata lookup would otherwise overwhelm the metadata store.
IAM & KMS
Auth. AWS identity and key-management services. Request routers authenticate every request and cache the results from IAM and KMS.
Admission Control
GACCoordination. Tracks each table's capacity as token buckets on an independent hash ring of servers, and hands tokens to request routers at regular intervals.
Building block: Rate Limiting Algorithms
Storage Nodes
NoSQL database. Host partition replicas. A partition's replicas, in three Availability Zones, form a replication group that uses Multi-Paxos; each storage replica keeps a B-tree of items and a write-ahead log.
Why: Quorum replication across zones survives the loss of a node or a whole AZ without losing acknowledged writes.
Building block: Consensus (Paxos & Raft), Database Sharding, Write-Ahead Log
Leader Replica
NoSQL database. Elected through Multi-Paxos and kept by renewing a leadership lease. Takes all writes and strongly consistent reads.
Storage Replica (AZ 2)
NoSQL database. Holds a B-tree of the items and a write-ahead log. Can serve eventually consistent reads.
Storage Replica (AZ 3)
NoSQL database. Third full replica in another Availability Zone.
Log Replica
NoSQL database. Stores only recent write-ahead log entries, no B-tree, like a Paxos acceptor. Added in seconds while a full replica is being rebuilt.
Archived Logs
S3Object storage. Write-ahead logs are archived to S3 with checksums and manifests; backups and point-in-time restore are built from them.
Autoadmin
Scheduler. The control plane, the 'central nervous system': handles table creation and updates, replaces replicas on unhealthy nodes, splits partitions and moves them to balance load.
Amazon S3
Object storage. Holds archived write-ahead logs, partition snapshots and full backups, so backup and restore don't touch the live table.
Update Streams
Stream. One of the services outside the core request path, alongside global tables, global secondary indexes and transactions.
Request flows
Write an item
- The application sends PutItem to a request router.
- The router authenticates and authorizes it, using cached results from IAM and KMS.
- The router hashes the partition key and looks up which replication group owns it (usually from its cache).
- It takes tokens from its local bucket for the table; GAC refills those buckets every few seconds.
- The write goes to the partition's leader, which logs it and replicates it to its peers.
- Once a quorum has persisted the log record, the write is acknowledged.
Read with eventual or strong consistency
- The application sends GetItem with ConsistentRead true or false.
- A strongly consistent read goes to the leader replica; an eventually consistent read can be served by any replica.
- The item is returned, typically in single-digit milliseconds.
Back up a table without touching it
- Write-ahead logs and periodic partition snapshots are already archived to S3.
- A backup or point-in-time restore is assembled from those archives, so the live table's performance isn't affected.
Failure scenarios
What if: traffic piles onto one partition?
Early DynamoDB divided a table's provisioned throughput evenly across partitions, so a skewed workload was throttled even when the table had capacity. Bursting, then adaptive capacity, then global admission control fixed this; today a partition whose consumption crosses a threshold is split for consumption, and autoadmin moves busy replicas to nodes with room.
User impact: Throttling on the hot keys until capacity is rebalanced.
- Global admission control instead of fixed per-partition limits
- Split partitions by consumption
- Choose partition keys with many distinct values
What if: request routers lose their caches?
If every router restarts with an empty cache, every request needs a metadata lookup. DynamoDB's routers call MemDS asynchronously even on cache hits, so MemDS always serves a constant load and doesn't collapse when the hit rate drops.
User impact: Slightly slower requests while caches refill, instead of a cascading outage.
- MemDS in-memory metadata fleet sized for the full request rate
- Constant work: refresh on every hit
What if: a leader is half-reachable (gray failure)?
A leader may be healthy but unreachable from one follower. Before triggering failover, that follower asks the other replicas whether they can still talk to the leader; only if they confirm the problem is a new leader elected, avoiding needless failovers.
User impact: Without the check, writes would pause during false-positive elections.
- Confirm leader failure with peers before electing
- New leaders wait for the old lease to expire
Trade-offs
Leader-based Multi-Paxos per partition
Elect one leader per partition for writes and strongly consistent reads.
- Pros
- Simple, strong semantics for every write
- Followers can serve cheap eventually consistent reads
- Cons
- A leader failover briefly pauses writes for that partition
Admission control at the routers
Replace fixed per-partition limits with global token buckets that routers draw from.
- Pros
- Skewed workloads use their table's full capacity
- Tenants stay isolated
- Cons
- A separate, highly available GAC fleet to run
Constant work for metadata
Refresh routing metadata on every cache hit, keeping load on MemDS steady.
- Pros
- No cascading failure when caches go cold
- Cons
- More metadata traffic than a conventional cache
Predictable latency over features
Expose a key-value and document API with limited queries instead of arbitrary SQL.
- Pros
- Every operation's cost is bounded
- Scales to any table size
- Cons
- Data must be modelled around access patterns
- Joins and ad-hoc queries happen elsewhere
Frequently asked questions
How does DynamoDB replicate data?
Each partition has replicas in three Availability Zones that form a replication group using Multi-Paxos. The elected leader writes a write-ahead log record, sends it to its peers and acknowledges the write once a quorum has persisted it.
Is DynamoDB the same as the Dynamo paper?
No. The 2007 Dynamo paper described a single-tenant store built on consistent hashing, sloppy quorums with hinted handoff and vector clocks, used by services such as Amazon's shopping cart. DynamoDB, launched in 2012, is a managed service with its own architecture: Multi-Paxos replication groups with a leader per partition.
What is a hot partition in DynamoDB?
A partition receiving far more traffic than the others, usually because many requests share a partition key. DynamoDB now splits partitions by consumption and uses global admission control, but choosing a partition key with many distinct values remains the best defence.
What's the difference between strongly and eventually consistent reads?
A strongly consistent read is served by the partition's leader and reflects every acknowledged write. An eventually consistent read, the default, can be served by any replica, so it might miss a very recent write, but costs half as much: one read capacity unit buys one strongly or two eventually consistent reads per second of up to 4 KB.
Building blocks used
Sources
- Amazon DynamoDB: A Scalable, Predictably Performant, and Fully Managed NoSQL Database Service · USENIX ATC
- Dynamo: Amazon's Highly Available Key-Value Store · SOSP (DeCandia et al.)
- DynamoDB read consistency · AWS Documentation
- DynamoDB provisioned capacity mode · AWS Documentation