System Design Basics
Design Key-Value StoreMediumWrite Code
3/10
Consistent Hashing

Description

Design a distributed key-value store similar to DynamoDB or Redis Cluster. The system must handle partitioning data across multiple nodes, replication for fault tolerance, and consistency trade-offs. Focus on the data partitioning strategy, replication model, and how reads/writes work.

Requirements

01Choose a partitioning strategy and explain why (consistent hashing vs range-based)
02Define the replication factor and how replicas stay in sync
03Explain the read/write path step by step
04Discuss consistency levels (strong vs eventual) and their trade-offs
05Handle node failures — what happens when a node goes down?

Example

# Strong answer covers:
# - Consistent hashing with 128+ virtual nodes per physical node
# - N=3 replicas, leaderless with quorum (W=2, R=2)
# - Write: hash key → find 3 nodes on ring → write to all → ack after W=2 succeed
# - Read: query R=2 replicas → return latest version (vector clock comparison)
# - Hinted handoff for temporary failures, Merkle trees for anti-entropy repair
Python 3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Ln 33, Col 1