How it works
Consistent hashing, introduced in a 1997 paper on web caching, maps both keys and node tokens into one fixed hash space. A token is a position in that space assigned to a node. Imagine the endpoints joined into a ring. For a key, move clockwise to the first node token; the physical node behind that token owns the key. After the last token, lookup wraps to the first.
Work through a small example: a ring from 0 to 99 with tokens A at 20, B at 50, and C at 80. A key hashing to 15 belongs to A. A key at 63 belongs to C. A key at 91 passes the top and wraps to A. A key at exactly 50 belongs to B, under the common rule that a token owns its own position. Real rings use a far larger space; Cassandra’s default partitioner produces 64-bit tokens. A sorted token array finds the successor by binary search, about 10 comparisons for 1,000 tokens, without scanning every node.
Every participant must use the same hash function and membership version or it may route the same key to different owners. Hash collisions and exact-boundary ties need deterministic rules. The ring describes logical ownership; the application still needs a protocol for reaching the owner and handling reads during transitions. It is also more machinery than modulo, since everyone must share a token list. Proxies such as HAProxy and Envoy offer ring-based balancing so requests for one key mostly keep reaching the same backend as the pool changes.
A key hashes just after the highest node token. Who owns it?
Lookup wraps around the ring, so the node at the lowest token is the clockwise successor.
Use this as a guide for self review; written answers are not graded.Keep in mind
- Successor lookup assigns one primary owner on a fixed hash space.
- Membership agreement is required for consistent routing.