
π System Design Interview Classics Β· Network
How a distributed cache spreads keys across nodes with consistent hashing, so adding or removing a node moves only a small share of keys.
Drawing diagramβ¦
Network view of a distributed cache: application servers use a client library that hashes each key onto a ring. Four cache nodes each own several virtual points on the ring. A key is stored on the first node clockwise and replicated to the next node. A configuration service tracks the ring and tells clients when nodes join or leave.
flowchart LR
A1[App Server 1] --- LIB1[Cache Client Library]
A2[App Server 2] --- LIB2[Cache Client Library]
subgraph RING[Hash Ring]
N1[Cache Node A - vnodes 1,5,9]
N2[Cache Node B - vnodes 2,6,10]
N3[Cache Node C - vnodes 3,7,11]
N4[Cache Node D - vnodes 4,8,12]
end
LIB1 --- N1
LIB1 --- N2
LIB2 --- N3
LIB2 --- N4
N1 -.replica.- N2
N2 -.replica.- N3
N3 -.replica.- N4
N4 -.replica.- N1
CFG[Config Service] --- LIB1
CFG --- LIB2
CFG --- RINGThe classic interview design for a service like bit.ly: short code generation, fast redirects from a cache, and click analytics processed separately.
How a one-to-one chat message is delivered in a WhatsApp-style system, with sent, delivered and read ticks, and push notifications when the receiver is offline.
How posts reach followers' feeds: fan-out on write for normal users, fan-out on read for celebrities, and a ranked feed built from a cache.
The core of a ride-hailing app: drivers stream their locations, a geo index finds nearby drivers, and a matching service offers the trip to the best one.
How a token bucket rate limiter decides whether to let an API request through, using Redis so all servers share the same counts.
A notification system that sends email, SMS and push messages at scale: one API, a queue per channel, user preferences, and retries.