What the lab models
Every key and every node point is placed with the same 32-bit hash a client library would use, so the numbers are real placements, not estimates. Load is the share of requests each node serves, with every key equally popular except, in the last level, one that takes 30% of all reads.
Why modulo hashing hurts
hash(key) % N spreads keys evenly and needs no state. The trouble is the N. Go from four nodes to five and a key stays put only if its hash gives the same remainder under both, which is about one key in five. The other 80% move. For a cache, every moved key is a miss that lands on the database at the worst moment: right when you were adding capacity because things were busy.
Consistent hashing
Put the nodes on a circle of hash values and send each key to the first node clockwise from it. Adding a node only takes over the arc just before it; removing one hands its arc to the next node along. Only about 1/N of the keys move, which is the least any scheme can manage.
With one point per node, though, the arcs are random lengths. One node can own a third of the ring while another owns a sliver, and when a node dies its single successor inherits all of its load. That is how one failure becomes two.
Virtual nodes
The fix is to give every server many points on the ring. Each owns lots of small arcs instead of one big one, so the totals even out roughly as 1/√V. When a server leaves, its arcs are scattered all over the ring and its load spreads across every survivor. The cost is the routing table: every client holds N × V entries and has to agree on them. Somewhere around 100–200 points per server is usually enough; Cassandra used 256 for years before lowering its default.
Hot keys
No placement scheme helps when a single key is the problem. Hashing decides where a key lives, not how popular it is, and a key with 30% of the traffic makes its owner 30% busier whatever you do with the ring. You have to change the key:
- Replicate it to the next k distinct nodes and let readers pick one. Load divides by k, and every write now updates k copies.
- Split it into suffixed keys,
celebrity#0tocelebrity#k, that hash independently. Same write cost, but the suffixes can collide on one node, which the lab will show you. - Bounded loads cap every node at c × the average and push overflow further round the ring. It can't split the hot key, but it can move everything else off the hot node. Tighter bounds push more keys away from their natural home, which costs an extra hop on lookup and more churn when the ring changes.
The levels are deterministic: the same settings always give the same placement, so you can change one thing at a time and see exactly what it did.