Skip to content
Latchkey

What Is Consistent Hashing?

Consistent hashing places both keys and nodes on a conceptual ring using a hash function, assigning each key to the next node clockwise. When a node joins or leaves, only the keys between it and its neighbor move, rather than nearly all keys as in plain modulo hashing. Virtual nodes are often added to spread load more evenly.

Why it matters

Naive key-to-node mapping reshuffles almost everything when the node count changes, causing huge cache or data churn. Consistent hashing keeps that churn proportional to the change, which is why distributed caches and shards rely on it.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →