Short answer: Rendezvous hashing, or highest random weight, places a key on the node that maximizes a hash of the key mixed with the node id. Every node computes the same scores, so every client agrees. Adding or removing a node moves only the keys for which that node was the winner or becomes the winner. With a uniform hash each of n nodes carries a 1/n share in expectation, without virtual points on a ring. A lookup that scores every node is O(n) hash evaluations.
What the problem actually asks
Consistent hashing maps keys and nodes onto a circle and walks clockwise. The circle needs a sorted index and, for even load, many virtual points per machine. Rendezvous hashing skips the circle. The assignment is a tournament: the node with the largest hash(key, node) wins. Any client who knows the membership list can run the tournament and will name the same winner.
Membership changes are local in key space. A new node’s keys are exactly the keys whose new score beats every old score. An old node’s departure hands each of its keys to the next-best score. Keys that ranked some other node first stay put.
What the algorithm guarantees
For a hash that is independent and uniform across nodes, each node is the unique maximum with probability 1/n, ties aside. The expected fraction of keys that move when one node joins or leaves is 1/(n+1) or 1/n respectively. The result is exact once the hash is fixed: there is no cache disagreement between clients who see the same membership. Extra memory is the membership list. The time to place one key is proportional to the number of nodes scored.
A weight can bias the tournament. Replace the raw hash U in (0, 1) with the score weight / −ln(U) and take the maximum. Selection probabilities are then proportional to the weights. An unweighted ring with virtual nodes is the other way to bias load, and it is a different algorithm.
The working steps
- Keep the current set of node ids.
- For a key, compute hash(key, node) for each node, using the same hash function and the same mixing of the two inputs.
- Store the key on the node with the largest hash. Break a tie by a fixed rule, such as the smaller node id.
- On a membership change, recompute winners. Only keys whose argmax changed move.
- For weighted nodes, map the hash into (0, 1) and maximize weight / −ln(U).
Agreement requires every client to hash the same membership. A clockwise ring with virtual nodes is consistent hashing. Rendezvous hashing is the per-node score tournament.
Approaches that look simpler and fail
| Approach | Why it fails when each client hashes only the key |
|---|---|
| Take hash(key) modulo the node count | Changing the count moves most keys. The rendezvous score mixes in the node id so a membership change reassigns only the keys that named the changed node. |
| Let each client break ties at random | Two clients then store the same key on different nodes. The tie rule has to be a pure function of the key and the node ids. |
| Score a stale membership list | The winner is defined for a set of nodes. A client who missed a removal will read a node that no longer holds the key. |
| Expect O(1) placement while scoring every node | The tournament looks at the membership. A hierarchical or tree-backed variant is required before the lookup drops below linear in the number of nodes. |
A ring and virtual nodes are consistent hashing. A fixed modulo is ordinary hashing. Rendezvous hashing is the highest random weight.
A working example
This Python fragment scores hash(key, node) for every node and keeps the maximum. With one hash family, key cat lands on node b. Adding node c does not move it. It prints b b.
def mix(key, node):
h = 2166136261
for ch in node + "|" + key:
h ^= ord(ch)
h = (h * 16777619) & 0xFFFFFFFF
return h
def place(key, nodes):
return max(nodes, key=lambda node: (mix(key, node), node))
before = place("cat", ["a", "b"])
after = place("cat", ["a", "b", "c"])
assert before == after == "b"
print(before, after)
Where it is used
Rendezvous hashing, or highest random weight, picks a cache or a server by the top score of a hash of the key and the node. Clients agree without a ring walk. Consistent hashing is the ring alternative used by Cassandra and Dynamo.
When you can drop this algorithm
Drop a linear scan of thousands of nodes on a hot lookup path if a ring index is cheaper. Keep rendezvous hashing when membership changes should move about 1/n of the keys and clients must agree without a shared ring.
Why this stays published
We publish this so a search for rendezvous hashing returns the max hash of key and node, and the weighted score weight over minus ln U. Rendezvous hashing stores a key on the node with the highest hash of the key and the node id, so a membership change moves only the keys whose winning node changed.
本文由 HoHo 與 AI 協作整理,最後更新於 2026 年 11 月 13 日。
