System Design · advanced
Consistent Hashing
Ring, virtual nodes, rebalancing.
Mental model
Consistent hashing maps both servers and keys onto a ring so that when you add or remove a server, only about 1/N of the keys move (instead of nearly all of them). Use "virtual nodes" — multiple ring positions per server — to spread load evenly.
How to study Consistent Hashing
Begin by restating the mental model in your own words, then connect it to a concrete system you have built or operated. Name the mechanism, the constraint it addresses, and the trade-off it introduces. Use System Design Primer, Consistent Hashing and Random Trees (Karger et al., STOC 1997), Consistent Hashing with Bounded Loads (Google Research) to check details, but close the source before writing your explanation. Retrieval is the learning step; rereading is only preparation.
Next, compare Consistent Hashing with Sharding. Ask what changes in correctness, latency, resource use, operability, and failure recovery. Complete Consistent-hash key router and preserve the command, input, output, and one failed attempt as evidence. Finish by explaining the idea without jargon to someone who has not studied the track.
Proof of understanding
- Explain the mechanism from first principles and identify the state it reads or changes.
- Give one situation where the concept is the right choice and one where it is not.
- Predict a realistic failure mode before running the drill, then compare the prediction with evidence.
- Connect the result to a roadmap or build artifact instead of treating the concept as isolated trivia.
Learn from primary sources
Practice and explain it back
Consistent-hash key router
Design a key router for a sharded cache using consistent hashing with virtual nodes. Show how add/remove of a node redistributes keys.
Expected evidence: Ring diagram + the algorithm for routing a key + the % of keys that move when N→N+1 nodes.
Open the interactive drill →Review prompts
- The ring already limits key movement to about 1/N. So why are virtual nodes needed?
Build evidence
Use a roadmap capstone to turn this concept into working evidence.