In this lesson · topic 4 of 7
Topic 4
What the ring balances and what it leaves
5 min read
Hover any measured value below to see its setup. Each is simulator output with a fixed seed, pinned by a test.
Movement when a node joins
Eight nodes with 100 virtual nodes each, 50000 keys, and one node added:
| Assignment | Keys moved |
|---|---|
| Consistent hashing ring | 10.1%measured |
| Hash mod N | 89.1%measured |
A ninth node ideally takes about a ninth of the keys, and the ring is close to that. Hash mod N moves most of them.
Imbalance and virtual nodes
Imbalance is the busiest node’s keys divided by the average. One means perfectly even. With eight nodes and 50000 keys:
| Assignment | Max over mean |
|---|---|
| Ring, 1 virtual node per node | 2.05measured |
| Ring, 256 virtual nodes per node | 1.12measured |
| Hash mod N | 1.02measured |
In this run, one point per node leaves the busiest node holding about twice its fair share. Many points bring it close to even. Hash mod N is the most even of all. It loses only because of what happens when N changes, which is why the choice depends on how often membership changes.
What it does not solve
Hot keys. Consistent hashing balances the number of keys, not the number of requests. One very popular key still lands on one node.
Different node sizes. The ring treats nodes alike unless you give bigger nodes more points.
Replication and failure. Real systems store copies on the next several distinct nodes clockwise and need a plan for what happens while a node is down. The Dynamo paper describes one design.
Strict load bounds. Even with many virtual nodes, a node can briefly exceed its share. Variants such as consistent hashing with bounded loads cap this.
Lookup cost. A ring lookup is a binary search over sorted points. Jump consistent hash is an alternative that needs no stored ring and almost no memory, at the cost of only supporting buckets numbered 0 to N-1, so it cannot remove an arbitrary node.