Curriculum · Module 01, Scaling a Service
Consistent hashing
Spread keys over nodes so that adding or removing one node moves only a small share of them.
What each topic covers
- The simplest way to spread keys over nodes reshuffles almost everything when the cluster changes size.
- Hash nodes and keys onto the same circle, and let each key belong to the next node clockwise.
- Add and remove nodes, count the keys that move under the ring and under hash mod N, and sweep virtual nodes.
- Measured movement and imbalance with and without virtual nodes, and the problems consistent hashing does not solve.
- Estimate imbalance from the square root of the point count, then see why a bigger cluster needs more points for the same target.
- Two ways to place keys without a ring: highest score wins, and a precomputed lookup table with near-perfect balance.
- Three checks on who moves when a node joins, what virtual nodes fix and why a hot key stays hot, plus the papers.
Topics
Practise this lesson
13 interview questions on consistent hashing, with worked answers and sources.
Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms