System design paper · 2007
Dynamo
How Amazon built a key-value store that accepts every write, even while servers fail and the network splits.
You’ll learn to
- Explain how consistent hashing and virtual nodes spread keys across a ring of servers.
- Pick N, R and W for a quorum and predict what each choice costs.
- Describe how vector clocks detect conflicting writes, and who resolves them.
- Name the parts of Dynamo that later systems kept, and the parts they dropped.
Read first: Consistent hashing
The idea in short
Amazon’s shopping cart must accept an “add to cart” even when servers are down. Dynamo chooses availability over consistency: every write succeeds somewhere, and the system sorts out disagreements later, when the data is read.
It combines a handful of known techniques into one design: consistent hashing to place data, quorums to tune reads and writes, hinted handoff to ride out failures, vector clocks to spot conflicts, Merkle trees to repair replicas and gossip to track which servers are alive.
The problem
Amazon runs on hundreds of services spread over tens of thousands of servers in data centres around the world. Building one product page can mean calls to over 150 of them. At that size, something is always broken: a disk, a server, a network link. The shopping cart still has to take every “add to cart”.
The paper sets the bar plainly: customers must be able to add items to their cart even if disks are failing, network routes are flapping, or “data centers are being destroyed by tornados”. A rejected write is a customer who can’t buy something.
The databases of the day didn’t fit. Relational databases that replicate data usually choose consistency over availability: when replicas can’t agree, they refuse the write. They also bring features most of these services never used. Best seller lists, shopping carts, customer preferences, session data, sales rank and the product catalogue all read and write one item at a time, by its key. No joins, no queries across many rows, and objects usually under 1 MB.
Speed mattered as much as staying up. Amazon’s services promise each other response times, and they measure those promises at the 99.9th percentile, not the average. A typical promise for Dynamo: 99.9% of reads and writes finish within 300 ms. Averages hide who the slow requests hit. The paper’s example: with heavy personalisation, customers with longer histories need more processing, so they land in the slow tail.
So the team asked a narrow question: what does a store look like if it only does key lookups, runs on hundreds of ordinary servers, treats failure as normal and never refuses a write?
Some things were left out on purpose. Dynamo runs inside Amazon’s own network, so it has no authentication or authorisation. Each service runs its own Dynamo cluster, sized for that service, rather than sharing one giant store.