All visualizationsSystem Design · 12 of 34
Consistent hashing — the ring that barely moves
Add a server: 2 of 8 keys re-home. Kill one: 1 moves. The naive modulo would have reshuffled nearly everything.
💡
THE BIG IDEA
Sharing keys across servers with hash % N works until the day N changes — then almost every key relocates at once and your caches stampede. Consistent hashing’s answer is a circle: hash servers AND keys onto it, give each key to the first server clockwise, and suddenly adding or losing a machine moves only the keys standing in one small arc. Watch the ring absorb growth and failure — every "keys remapped" count in this theatre is machine-verified.
Press ▶ Play to watch it run step by step, or use the arrow buttons to go at your own pace.
1
8 things need homes — user sessions, cached images, carts — spread across a few cache servers. The obvious answer is hash(key) % number_of_servers. It works beautifully… until the number of servers changes.
Change % 3 to % 4 and almost EVERY key lands on a different server: a stampede of cache misses, all at once, usually at the worst moment (you scaled because load was high). Consistent hashing exists to kill that stampede.
0 / 2³²ravilogopriyaarjunsarademokirandev
the circle = the whole hash space, 0 at 12 o’clock
1/9
UP NEXT IN SYSTEM DESIGN
The Consistent-Hashing Ring
Keys walk clockwise · a server joins (one arc moves) · a server dies (one arc slides) · vnodes + replication
Consistency & Quorums — One Balance, Three CopiesThe Consistent-Hashing Ring