Scalinghash ringrendezvous hashing

Consistent hashing

Definition

Consistent hashing places nodes and keys on the same hash ring and assigns each key to the first node clockwise from it, so a membership change remaps only about 1/N of the keys.

In practice

With plain hash(key) % N, changing N remaps almost every key, which empties caches and forces mass data movement. Consistent hashing keeps most keys where they are, which is why distributed caches, Dynamo-style databases and sticky load balancing use it.

With few nodes the ring is uneven, so each physical node is placed many times as virtual nodes to smooth the distribution. Hot keys remain a problem: consistent hashing spreads keys, not load per key.

Example

A cache cluster grows from 4 to 5 nodes; with consistent hashing about 20% of keys move to the new node instead of roughly 80% with modulo hashing.