Case study demo

Key-value store

Put and get keys on a small replicated store and see how quorum settings change consistency.

An interactive demo of how this system behaves. It runs in your browser.

Case study · Live model

How a replicated key-value store behaves

Five nodes share a hash ring, and each key is copied to 3 of them. Change how many copies a write waits for (W) and a read asks (R), crash a node, and see what stays correct.

Try it

Lab time 3.0 s
Coordinator, W = 2 · R = 2CoordinatorW = 2 · R = 2R + W > NNode A, 14 keysNode A14 keysNode B, 13 keysNode B13 keyshas user:42Node C, 10 keysNode C10 keyshas user:42Node D, 9 keysNode D9 keyshas user:42Node E, 10 keysNode E10 keys
  • Coordinator — W = 2 · R = 2 — healthy — R + W > N
  • Node A — 14 keys — healthy
  • Node B — 13 keys — healthy — has user:42
  • Node C — 10 keys — healthy — has user:42
  • Node D — 9 keys — healthy — has user:42
  • Node E — 10 keys — healthy
  • Write to a replica
  • W-th confirmation
  • Read from a replica
  • R-th answer
  • Read repair
  • Hint handed back, or a Merkle compare
  • Refused
Writes
6.7/s
0 refused, 0 timed out
Reads
16.3/s
0 refused
Write time
176 ms
typical, waiting for 2 of 3
Read time
184 ms
typical, waiting for 2 of 3
Stale reads
0
Healthy: every read saw the newest write
Hints waiting
0
0 handed back, 6 read repairs

Numbers add up:22 writes = 20 confirmed + 0 refused + 0 timed out + 2 in flight; the same for reads; no read is stale while R + W > N, every node is up and no hints were usedThe lab checks this sum as it runs, so a counting mistake would show here.

Controls

Quorums
2 of 3
2 of 3

R + W = 4. That is more than N = 3, so while every node is up, a read always asks at least one copy the last write reached. With a node down, a stand-in can count toward W, and a read can miss it.

Failures

A write for a down replica is kept by the next healthy node, counts toward W, and is handed back later. Off: only the 3 home nodes count, so a write is refused only if fewer than W of them are up.

A read that sees an old copy sends the newest one back to that replica.

Every 2 s, two nodes compare Merkle trees of the keys they share and copy what differs.

Nodes learn about a crash from each other, a few rounds later, instead of at once.

Traffic
8 a second
20 a second

Look up a key

ReplicaNode stateVersion it holds
1. Node Cupnone yet
2. Node Dupnone yet
3. Node Bupnone yet

Newest confirmed write: none yet.

Typical write and read time (ms)
WriteRead
062.51251882501s2s3s
Show data table
TimeWriteRead
1s166184
1s194192
2s185184
2s184184
3s184184
3s176184

What just happened

Nothing yet. Start traffic or run an experiment.

What this model simplifies
  • Five nodes with 8 points each on the ring, and N fixed at 3.
  • Messages take 20–150 ms, and 1 in 10 takes 300–700 ms, like a busy disk. Times are illustrative.
  • Versions are numbers given out by the coordinator. Real stores use timestamps or vector clocks, and two writers can clash.
  • Anti-entropy compares a Merkle tree with 8 leaves per pair of nodes, one pair every 2 s. Real stores keep deeper trees per key range.
  • Gossip sends heartbeats every 0.5 s, and a node is suspected after 2 s of silence. Real detectors, such as phi accrual, adapt that wait to the network.
  • With gossip on, the coordinator acts on what most nodes believe, and it never retries a request that got no reply. Real coordinators often try the next node after a timeout.
  • A stand-in node that keeps a hint counts toward W, as in Dynamo (a "sloppy quorum"). So with a node down, even R + W > N can give a stale read now and then.