Labs

Consistent hashing ring

Add a node and count the keys that move, with and without virtual nodes, against hash mod N.

On the ring0 / 60 keys moved
N = 10V = 100
With hash % N0 / 60 keys moved
0123456789

Last change: 10 → 11 nodes, on the same 10,000 keys.

Moved · ring9.9%expected ≈ 9.1%
Moved · hash % N90.6%expected ≈ 90.9%
Hottest node ÷ average1.10×bounded-load cap example: 1.25×
Load std dev10.9%rule ≈ 1/√V = 10.0%

Share of the keys per node

node-09.6%
node-19.5%
node-28.5%
node-38.0%
node-410.0%
node-59.7%
node-69.4%
node-79.4%
node-86.5%
node-99.4%
node-109.9%

Going 10 → 11 nodes moved 9.9% of the keys on the ring and 90.6% with hash % N: one cache cluster stays warm, the other goes cold.

How it's calculated · assumptions

owner(key) = first vnode token clockwise from hash(key) · N → N+1 moves ~1/(N+1) on a ring, ~N/(N+1) with hash % N

Virtual nodes buy balance: spread ≈ 1/√V, so 100 vnodes ≈ 10%.

Keys "key:0…9999" and tokens "node-k#i" are hashed (FNV-1a + murmur3 finalizer) onto a 32-bit ring; every percentage is measured on these keys. Ticks outside the ring: vnode tokens (up to 400 drawn). Dots: 60 sample keys colored by owner, each parked at the token that owns it (the first clockwise from its hash); outlined dots moved on the last change. Rules of thumb from the consistent hashing concept.