Learn

CASE STUDY · ORIGINAL

Case study: reading the Dynamo paper

A learner’s reading of Amazon’s 2007 Dynamo paper: consistent hashing with virtual nodes, sloppy quorums and hinted handoff, vector clocks, Merkle-tree repair and gossip, and what to sketch from it.

If you sketch a key-value store in an interview, you will probably end up drawing pieces of Dynamo whether you know it or not: a hash ring, replicas on the next few nodes, read and write quorums. The paper is worth reading in full because it shows those pieces as answers to specific problems, and because it is candid about the costs.

This is a learner's summary in my own words. Sections marked What the paper reports describe the 2007 paper's claims. Sections marked Commentary are my reading of what matters for design practice. One clarification up front: Dynamo, the internal system in this paper, is not the same as DynamoDB, the later public service. The 2022 DynamoDB paper (in further reading) describes a different replication design.

What the paper reports: the requirements

Dynamo was built for internal services that need a simple primary-key interface and must keep accepting writes during failures. The running example is the shopping cart: a customer should be able to add an item even if disks are failing, network links are flapping or a data center is offline. The paper describes performance targets in terms of the 99.9th percentile, with an example service requirement of responding within 300 ms for 99.9% of requests at peak load.

From that, the authors choose availability over strong consistency. Dynamo is "always writeable": conflicting versions of an item may exist, and conflicts are resolved when the item is read, often by the application, rather than by rejecting writes.

What the paper reports: the techniques

Partitioning: consistent hashing with virtual nodes

Keys are hashed (MD5) onto a ring. Each physical node owns multiple positions on the ring, called virtual nodes or tokens. A key is stored on the first node clockwise from its hash and replicated to the next N-1 distinct physical nodes; that list is the key's preference list. Virtual nodes spread load more evenly, let a recovering or new node take a little load from many others, and let more capable machines take more tokens.

A later section is especially useful: the team compares three token strategies and reports moving from random tokens to a scheme with a fixed number of equal-sized partitions, each node holding an equal share. The reported benefits are better load balance, far smaller membership metadata to gossip, and simpler bootstrapping and archival, because a partition can be moved as a file. The cost is that membership changes need coordination.

Replication and sloppy quorums

Each operation involves N replicas. A write succeeds once W replicas acknowledge; a read returns once R replicas answer. The paper notes that R plus W greater than N gives quorum-like behavior, and reports (3, 2, 2) as a common configuration. Any node can coordinate a request; a client can also route directly to a coordinator using a membership-aware library.

Crucially, the quorum is sloppy: operations use the first N healthy nodes from the preference list. If one intended replica is down, the next node on the ring takes the write instead.

Hinted handoff

A node that accepts a write on behalf of an unreachable replica stores it with a hint naming the intended owner, in a separate local store. When the owner comes back, the substitute delivers the data and can delete its copy. The paper notes this works best when membership churn is low and outages are short.

Versioning with vector clocks

Each version of an object carries a vector clock: a list of (node, counter) pairs. If one version's clock descends from another's, the older one can be discarded. If neither descends from the other, they are concurrent, and a read returns both to the client. For the shopping cart, the application merges carts, which the paper admits means deleted items can reappear. Clocks are truncated once they exceed a size threshold (the paper gives 10 pairs as an example), accepting a small risk of misjudging ancestry.

The paper reports how often this matters: over 24 hours of shopping cart traffic, 99.94% of requests saw exactly one version. It attributes most divergence to many concurrent writers (often automated clients) rather than to failures.

Anti-entropy with Merkle trees

To repair replicas that drift, for example after a hinted replica is lost, nodes compare Merkle trees: hash trees whose leaves are hashes of keys. Each node keeps one tree per key range it hosts. Two nodes compare roots; if they match, the range is in sync. If not, they descend only into differing branches, so the data exchanged is proportional to the differences, not the data set. The paper notes the weakness: when ranges change on joins and leaves, trees must be recomputed, which the fixed-partition scheme mitigates.

Membership and failure detection by gossip

Nodes are added and removed by an administrator, explicitly, because the authors observed that most outages are transient and should not trigger rebalancing. Membership changes propagate by gossip: each node contacts a random peer about once per second and they reconcile histories. Some nodes act as seeds to prevent the ring from splitting into disjoint views. Failure detection is local: a node treats a peer as unavailable if it stops responding, and routes around it.

Other reported details

The storage engine on each node is pluggable (the paper mentions Berkeley DB and MySQL). During reads, a coordinator that sees stale replicas writes back the latest version (read repair). Some services used an in-memory write buffer to cut tail latency, with one replica doing a durable write to limit the durability risk.

FIG. 1ORIGINAL SKETCH
put(key, ctx)1replica 12replica 22replica 32handoff later3Merkle sync4ClientCoordinatorN=3, W=2Node ANode B (down)Node CNode Dhint: for Bnext healthynode
A Dynamo-style write: the coordinator sends to the first N healthy nodes on the preference list, a substitute holds a hinted replica while one owner is down, and gossip plus Merkle repair keep replicas converging.

Commentary: what to take into your own sketches

Each technique answers a named failure. The paper's summary table pairs problems with techniques: partitioning with consistent hashing, write availability with vector clocks, temporary failures with sloppy quorum and hinted handoff, permanent failures with Merkle trees, membership with gossip. That pairing is the best way to study it. In an interview, introduce a mechanism only after naming the failure it handles.

The real decision is the conflict policy. Accepting writes during a partition means two versions can exist. Someone has to merge them. Vector clocks only tell you that a conflict happened; they do not resolve it. A cart can union items. A bank balance cannot. If you propose a Dynamo-style store, say which data tolerates merges and which needs a single leader. Consistency and idempotency is the companion read.

Sloppy quorums weaken the quorum guarantee. With strict quorums, R plus W greater than N means a read overlaps the latest write. With sloppy quorums, the W writes may land on substitutes outside the usual preference list, so a read of the usual owners can miss them until handoff completes. This is a deliberate trade for availability, and it is a good follow-up answer to have ready.

The partitioning lesson is operational. The move to fixed, equal-sized partitions is the part most worth remembering. It mirrors the fixed-partition approach in partitioning and ordering: moving whole partitions is easier to reason about, back up and repair than moving arbitrary key ranges.

Explicit membership is a control-plane choice. Dynamo separates "this node is unreachable right now" (local, fast, routed around) from "this node has left" (an operator decision). That distinction is the heart of the database control plane question, and it maps to cluster health monitoring, where a flapping node should page someone without triggering a data migration.

ChoiceDynamo-style (leaderless, sloppy quorum)Leader per partition (consensus replicated)
Writes during a partitionAccepted on any reachable nodes; conflicts possible.Only the side with the leader and a majority accepts writes.
Conflict handlingVector clocks detect; client or application merges.No conflicts for single-key writes; one order is decided.
Read your writesNot guaranteed with sloppy quorums until repair.Reads from the leader see the latest committed write.
Good fitCarts, session state, preferences: mergeable data where availability wins.Balances, inventory, metadata where one answer must win.

Commentary: what to sketch

For the key-value store question, draw the ring with virtual nodes and a preference list of three, then walk a put and a get with N, R and W. Then take one node down and show hinted handoff. Finally show a concurrent write producing two versions and say who merges them. That four-step sketch covers most follow-ups an interviewer will try.

TAKE THIS TO YOUR NEXT SKETCH

  • Dynamo chooses write availability over consistency; every mechanism follows from that choice.
  • Learn it as pairs: consistent hashing for placement, sloppy quorum and hinted handoff for temporary failures, Merkle trees for permanent drift, gossip for membership.
  • Vector clocks detect conflicts; your application still has to define the merge, so only use this model for mergeable data.
  • Sloppy quorums can miss recent writes until handoff completes; be ready to explain that trade.
  • The paper’s move to fixed, equal-sized partitions and explicit membership is the operational lesson most worth carrying over.

PRACTICE WITH THIS

Now sketch one.

OFF-SITE READING · NOT WRITTEN BY US

Further reading

Next: Case study: reading the Haystack photo storage paper