🔴 Redis Advanced

What is consistent hashing and how does it compare to Redis Cluster's approach?

Answer

Consistent hashing places both nodes and keys on a conceptual ring. Each key is assigned to the nearest node clockwise on the ring. When a node is added or removed, only the keys on one segment of the ring are remapped — O(K/N) keys on average, rather than remapping all keys. This minimizes data movement on topology changes. Redis Cluster uses a different approach: fixed hash slots assigned to nodes. When a node joins, an administrator explicitly migrates a subset of slots to it. This gives more predictable, operator-controlled data distribution. The tradeoff: consistent hashing is more self-organizing; Redis Cluster's slot model is more explicit and compatible with the CRC16 + modulo calculation that all clients implement deterministically. Redis intentionally chose fixed slots over consistent hashing for simpler, auditable behavior and to enable hash tags for key co-location.