IT lexicon Database Consistent hashing (DB)

Consistent hashing (DB)

Database På svenska → Updated: 2026-05-29

A technique for distributing data over nodes so that when a node is added or removed, only a small fraction of the keys need to move. The solution to the problem that simple modulo hashing forces reshuffling of nearly everything on every topology change.

Problem: "node = hash(key) % N" means that if N changes (a node joins/leaves) almost all keys switch nodes → catastrophic reshuffling. Consistent hashing places both nodes and keys on a circular "ring" (the hash space); a key belongs to the next node clockwise. Add a node and it only takes over keys from its neighbor; remove one and the neighbor inherits → only ~1/N of the data moves. Improvement: virtual nodes (vnodes) give more even distribution and load balance. The foundation of Amazon Dynamo (2007) and thereby Cassandra, Riak, DynamoDB. Also used in CDNs, caches (memcached), and load balancers. A classic building block of scalable distributed systems. Related to vnode and gossip protocol.

← Back to the lexicon