Systems / 2026 / Live in the browser
Consistent Hash Lab
A vnode ring, jump hash, rendezvous hashing and bounded loads, compared with hash % n on one seeded key set: how evenly each spreads keys and how many move when a cache node joins.
01
The problem
Sharding a cache with hash(key) % n means adding an eleventh node to ten gives about 90% of keys a new owner. Every moved key is a cold miss, so a routine scale-up sends most of the traffic straight to the database.
02
How I approached it
Each scheme is a small dependency-free module on MurmurHash3, checked against the reference vectors: the vnode ring from Karger et al. (STOC 1997) with binary-search lookup, jump hash from Lamping and Veach (2014) on a 64-bit BigInt LCG, weighted rendezvous hashing with the -w / ln(u) score, and bounded loads from Mirrokni, Thorup and Zadimoghaddam (SODA 2018), which caps every node at ceil((1 + eps) * m / n) keys. The tests assert the defining property directly: when a node joins, no key moves between two nodes that were already there. The page reruns all five on every slider change and draws the ring's arcs per node.
03
The outcome
Over five seeds of 20,000 keys on 10 nodes, modulo moves 90.8% of keys on a join while the consistent schemes move 8.9% to 10.0% against an ideal 9.1%. Jump hash and rendezvous keep the busiest node within 4% of its fair share; a 100-vnode ring still runs 1.29x, and bounded loads pulls it under its 1.25x cap at the cost of 0.4% of keys cascading. Zero dependencies, 13 tests.