Dynamo Key-Value Store

A leaderless, quorum-based key-value store for a shopping cart: any node coordinates, writes stay available through failures, and conflicts are resolved on read.

  • Quorum: N=3 · W=2 · R=2 typical
  • Success: 99.9995% of requests
  • SLA: 99.9% ≤ 300 ms at 500 req/s (p99.9)
  • Latency: sub-10 ms P99 reads and writes
  • Scale: petabytes · millions of QPS · thousands of nodes
  • Coordination: 30.4 ms client-driven vs 68.9 ms server-driven p99.9

Smart client

The client library holds the ring membership, hashes the key and sends the request straight to a node in the key's preference list, so no load balancer hop sits in front of the coordinator.

Hash ring

Consistent hashing with virtual nodes: every physical node owns many small arcs, and each key's preference list is the next N distinct physical nodes clockwise.

Coordinator

Whichever node receives the request coordinates it: appends to its WAL, inserts into its MemTable, replicates concurrently to the next N-1 clockwise nodes, and replies once W acknowledgments arrive.

WAL + MemTable

The LSM-tree write path on every replica: append to the write-ahead log, insert into the in-memory MemTable, and flush it at around 16 MB into an immutable SSTable.

SSTables

Immutable sorted files flushed from the MemTable. Background compaction merges them; a Bloom filter per SSTable tells reads which files can be skipped.

Quorum N / W / R

The rule the coordinator applies: write to N replicas, succeed at W acks, read from R replicas. N=3, R=2, W=2 is typical; W=1 succeeds if any node is reachable.

Replicas

The next N-1 distinct nodes clockwise from the key. Each appends to its own WAL and MemTable and acknowledges to the coordinator.

Vector clocks

Each version carries a list of (node, counter) pairs. If one clock descends from another the newer wins; if neither does, the writes were concurrent and both versions are kept.

Read path + repair

Reads gather R responses, compare vector clocks, return the newest value or all conflicting versions, and asynchronously push the newest version to any stale replica.

Gossip

Nodes periodically exchange membership and liveness with random peers; seed nodes help new nodes join. Every node learns about a dead node without a master.

Hinted handoff

When a home replica is unreachable, the write goes to the next healthy node with a hint naming the intended owner; the stand-in hands it back when the owner recovers.

Merkle sync

Each node keeps a Merkle tree per key range. Replicas compare tree roots and descend only into differing branches, syncing just the key ranges that differ.