Consistent Hashing (Ring) Playground

Servers & keys hash onto a ring: which server holds each key? Add/remove a server, then count how many keys move (vs hash%N). Virtual nodes: what do they do…

Why it matters

Distributed caches, database sharding and load balancers must know which server owns a key. With hash % n, adding one server changes the owner of nearly every key: every cache goes cold at once. The ring moves only about 1/n. Dynamo, Cassandra and many Memcached clients use it.

The key idea

Servers and keys on one ring

Common mistakes

Try it in this playground