How do Consistent Hashing algorithms work and what problems do they solve in distributed systems?

Instruction: Describe the concept of Consistent Hashing and its application in managing distributed systems efficiently.

Context: This question tests the candidate's knowledge of consistent hashing, a crucial concept in the scalability and performance of distributed systems.

Updated

Official answer

Consistent hashing maps keys and node positions into a shared hash space. In a ring scheme, a key belongs to the first node position encountered clockwise, wrapping around at the end. Adding a position moves the keys in its predecessor-to-new-position interval to the new owner; removing one transfers its interval to its successor.

This limits remapping compared with taking hash(key) modulo a changing node count. Under balanced assumptions a new node takes a fraction of keys, but the exact amount depends on positions and virtual-node policy. “Only the closest data moves” is imprecise: ownership follows defined intervals.

Multiple virtual positions per physical node can improve balance and support heterogeneous capacity. They do not eliminate hot keys or guarantee balanced request cost. Monitor bytes, request load and movement, not just key counts.

Routing agreement, data transfer, concurrent writes, replica placement and failure recovery are separate requirements. The word consistent here does not mean linearizable data consistency, and the hash function alone supplies neither replication nor durable failover. Define membership versions and the authoritative owner during migration, then test stale routing, node loss and partial transfers.

Related Questions