SD-12 · Back to the write-up
Design a Key-Value Store
Hash keys onto a ring of virtual nodes, keep 3 copies in 3 zones, answer after 2 of them agree, and repair the third in the background.
Follow a request
Quorum write
Quorum read + repair
Node down · hinted handoff
Anti-entropy repair
Concurrent writes
Clients
Coordination
Storage, 3 zones
Background
Client serviceClient library
CoordinatorStateless, many
MembershipGossip + ring
Replica AZone a node
Replica BZone b node
Replica CZone c node
Anti-entropyMerkle trees
SnapshotsObject storage
The numbers, at a glance
1 write ≈ 200,000/s at peak4 reads ≈ 800,000/s
1.0MClient ops
0.6MReplica writes
1.6MReplica reads
2.2MReplica total
5% of all copies60 nodes, 15,360 tokens
A quorum write, in order
N = 3, W = 2. The coordinator answers after 2 acks; the third replica finishes in the background.
Client
Coordinator
Replica A
Replica B
Replica C
1 PUT key + context
2 write v6
3 write v6
4 write v6
5 ack (log synced)
6 ack (log synced)
7 204 + new context
8 late ack
RequestResponseAsync, does not block
Who accepts a write
The decision this question is really about.
PUT
leader in zone a
followers b, c
leader dies → 5 s pause
+ Linearizable; no conflicts.− Writes pause on failover; one zone takes every write.
PUT
headmiddletail
one slow link = slow writes
+ Strong; simple reads.− 3 hops per write; a slow node slows all.
PUT
ABC (late)
ack after W = 2
+ Any 2 of 3 answer; no failover.− Versions, siblings and repair needed.
How it grows
Add a box only when a number forces you to. Highlighted boxes are new at each stage.
Client
Single node
Client
CoordinatorsGossip membership
Storage nodes × 20
Client
CoordinatorsGossip membership
Zone a × 20Zone b × 20Zone c × 20
Client
CoordinatorsGossip membership
Zone aZone bZone c
Anti-entropySnapshotsMonitoring
Was this walkthrough useful?Your vote tells us what to improve next.