Consistent hashing vs rendezvous (HRW) hashing — which for what scale?
172 views
89 of 106
1
The problem
Question presented to candidate:
"Two ways to map keys to a changing set of servers: a consistent hashing ring with virtual nodes, or rendezvous hashing, also called highest random weight. How does each work, how do they compare on balance, movement and lookup cost, and which would you pick for 10 servers, for 1,000, and for a load balancer making a decision per packet?"
What a strong answer should cover:
Rendezvous (HRW): score every server with hash(server, key) and pick the highest; a ring maps the key to the next token clockwise
Both give minimal disruption: a join takes about 1/(N+1) of keys, a leave moves only that server's keys, spread over the survivors
Balance: HRW is even with no extra state; a ring needs many virtual nodes to get close
Cost: HRW is O(N) hashes per lookup; a ring is one hash plus an O(log(N·V)) binary search, at the price of an N·V-entry table
Replicas: HRW top-k scores give k replicas directly, and losing a server swaps exactly one member of each affected set
The scale rule: HRW for small and medium N or when lookups are cached or precomputed; ring, jump hash or a precomputed table when N is large and lookups are hot
Clarifying questions expected:
How many servers, and how often does the set change?
How many lookups per second, and can the result be cached per key?
Code / implementation expected: Optional — both are a few lines; the example measures them side by side on the same keys.
consistent-hashing
rendezvous
sharding
2
Try it yourself
Sketch your approach before you read the solution. That is what the interview tests.
Stuck? Get a hint.
A short nudge toward the approach. It will not give the answer away.
3
Solution
Target Audience: Readers who know the basic hash ring and virtual nodes; see What is consistent hashing? and What is consistent hashing with virtual nodes and when do you need it? if not.
Difficulty: Hard
Verified with: Node 22.22, Python 3.12, Go 1.24 and Java 21 (all four print identical output). History is cited from Thaler and Ravishankar (University of Michigan report, 1996; IEEE/ACM Transactions on Networking, 1998); GitHub GLB from the GitHub engineering blog.
How to read this doc: Every idea is explained in plain language first, then tagged with 📌 Interview term: so you also learn the words an interviewer expects. Numbers come from running the example; the Verified section quotes its full output.
1. Why This E
The solution is hidden so you can try first
13 min read · 12 sections
4
Read the code
Ring vs rendezvous (HRW) hashing: balance, movement, work per lookup, replica sets