Rendezvous Hashing: A Ring-Free Answer to Key Placement

When an interviewer asks how to spread keys across a changing set of cache servers, most people reach for a consistent-hash ring. Rendezvous hashing, also called highest random weight (HRW) hashing, solves the same problem with less machinery, and naming it is an easy way to stand out.

The rule

For a key k, compute score(k, s) = hash(k + s) for every server s. The key belongs to the server with the highest score. That's it: no ring, no tokens, no virtual nodes.

def owner(key, servers):
    return max(servers, key=lambda s: hash64(f"{key}|{s}"))

Why it moves minimal data

If a server is removed, only keys whose winner was that server move, and each goes to its second-highest scorer, which is spread uniformly across the remaining servers. If a server is added, it steals only the keys for which it now scores highest, about 1/(N+1) of them. That's the same optimal movement a ring gives, and the balance is good without vnodes.

Replication comes for free

Need R replicas? Take the top-R scorers. They're automatically distinct physical servers, avoiding the ring pitfall where two clockwise vnodes belong to the same machine.

Weights

For heterogeneous servers, use the weighted form score = -w / ln(u), where u is the hash mapped to (0,1). A server with twice the weight wins about twice as many keys, and changing one weight still moves only the keys that should move.

The cost and how to answer it

A naive lookup is O(N) per key because you score every server. For tens or a few hundred servers that's negligible compared to a network round trip. For thousands, mention a hierarchical (skeleton) variant: group servers into clusters, pick a cluster by HRW, then a server inside it, for O(log N)-ish lookups.

When to pick which

Interview one-liner: "Score every server against the key and pick the max; removal only moves that server's keys, and top-R gives replicas."


Disclosure: I help build Linkjob AI interview copilot. This page is general system design study material.