System design case study C03 · Dynamo · Replication

Design a Distributed Key-Value Store

Build the thing underneath half of the other designs: a horizontally scalable, highly available get/put store. This case study pulls together partitioning, replication, quorums and failure detection.

What you'll be able to explain
  • Partition keys with consistent hashing and virtual nodes
  • Replicate with tunable quorums
  • Detect failures with gossip and handle temporary failures with hinted handoff
  • Repair divergence with read repair and Merkle trees
  • Choose the storage engine for each node

Scope

Functional

  • put(key, value), get(key), delete(key); values up to ~1 MB.
  • Optional TTL per key.

Non-functional

  • Always writable (AP leaning), tunable consistency per request.
  • Scale horizontally to hundreds of nodes and petabytes; add nodes without downtime.
  • p99 < 10 ms within a region.

Size

  • 10 PB of data, RF = 3 → 30 PB raw; at 10 TB per node → ~3,000 nodes.
  • 2M ops/s; ~1,000 ops/s per node on average, comfortably within one node's capacity.

API and request path

PUT /kv/{key}?w=2      body: value       → {version}
GET /kv/{key}?r=2                        → {value, version} or siblings
DELETE /kv/{key}                         → writes a tombstone
CLIENTClientSERVICECoordinatorany nodeDATABASEReplica 1ownerDATABASEReplica 2DATABASEReplica 3NETWORKGossipmembershipput(k, v)
Any node can coordinate; it forwards to the N replicas that own the key.

The 30-second summary

Say it in the interview

"A Dynamo-style leaderless store: consistent hashing with virtual nodes for partitioning, N = 3 replicas across zones, tunable W/R per request with a W = 2, R = 2 default. Gossip handles membership, hinted handoff covers temporary failures, and read repair plus Merkle-tree anti-entropy repair divergence. Nodes use LSM storage. It favours availability; conflicts are detected with vector clocks."

Follow-up questions the interviewer may ask

  1. How does a new node join?
  2. How do you detect and repair divergent replicas?
  3. How do you support strongly consistent reads for some keys?
  4. How are deletes handled?

Model answers to each of these are in the book.