The Ring That Does Not Forget Everything – Consistent Hashing and the Art of Redistributing Data
Software Architecture · 2026-11-25
Fully AI-generated article (no prior review).
🎧 Listen to this article
The Hook
Distributed systems engineering has a problem that sounds so mundane it is easy to underestimate: you have K keys – cache entries, records, sessions – and n machines to spread them across. The obvious solution is one line of code:
node = hash(key) mod n
It works flawlessly as long as n stays constant. Add a machine and mod 10 becomes mod 11 – and the assignment changes for almost every key at once. For a cache that means the hit rate collapses to nearly zero in a single step and every request falls through to the database behind it. For a data store it means that nearly the entire dataset has to travel across the network just to admit one new node.
In 1997 David Karger, Eric Lehman, Tom Leighton, Rina Panigrahy, Matthew Levine and Daniel Lewin presented, at the ACM Symposium on Theory of Computing, a hash function that does not have this property. Their paper is titled "Consistent Hashing and Random Trees: Distributed Caching Protocols for Relieving Hot Spots on the World Wide Web" (STOC 1997, pp. 654–663). The core fits in one sentence: a consistent hash function is one that "changes minimally as the range of the function changes".
This article shows why that idea has been sitting inside many distributed data stores and load balancers for nearly thirty years, which four properties the original paper actually establishes, and where practice deliberately departs from it.
The Core Concept: Keys and Nodes on the Same Ring
The construction is remarkably simple. You map not only the keys but also the nodes, using the same hash function, onto a shared range of values – usually pictured as a circle on which the largest value wraps around into the smallest. A key then belongs to the node you reach by walking clockwise from the key.
The decisive difference from mod n: when a node disappears, its successor inherits exactly that node's arc – every other assignment is untouched. When a node is added, it takes part of the arc away only from the neighbour behind which it was inserted. The disruption is local instead of global.
In section 4.1 the original paper states not one but four separate properties:
| Property | What it guarantees |
|---|---|
| Balance | With high probability, keys spread evenly across the buckets. |
| Monotonicity | When the set of nodes changes, an item may move from an old bucket to a new one – never from one old bucket to another old one. |
| Spread | Across differing views of the node set, a key ends up in only a bounded number of distinct buckets. |
| Load | Across differing views, a bucket is assigned only a bounded number of keys. |
Monotonicity is the real promise: it rules out precisely the useless redistribution that mod n triggers. The widely quoted statement that on average only a fraction K/n of the keys must be reassigned when a node is added or removed is a consequence of this – the English Wikipedia presents it in that form, while the original paper proves it as part of the four properties above. Spread and load are the more interesting part: they address the case in which different clients hold different, partly stale views of the node set – the normal case on the web of 1997, and in large systems to this day. (The exact bounds the original paper proves for balance, spread and load were not checked against the text in detail during this run; what is confirmed is that the paper defines these four notions separately, plus the quoted definition of monotonicity.)
Example 1: Dynamo and Virtual Nodes
The theory guarantees balance "with high probability" – in practice that is not enough. Amazon's Dynamo paper (DeCandia et al., SOSP '07, Stevenson, Washington) names two concrete weaknesses of the basic algorithm verbatim: first, the random position assignment of each node on the ring leads to "non-uniform data and load distribution". Second, the basic algorithm is "oblivious to the heterogeneity in the performance of nodes" – it knows nothing about one machine being stronger than another.
Dynamo's answer to both is the same and strikingly pragmatic: virtual nodes. Instead of placing each server on the ring once, you place it many times under different labels. The paper says that a virtual node looks like a single node in the system, but that each node can be responsible for more than one virtual node. The more labels, the smoother the distribution – and the number of labels per server becomes, at the same time, the lever for unequal hardware. In Wikipedia's presentation this number is simply called the server's "weight".
This is a pattern one meets often in architecture practice: a probabilistic guarantee is rescued not by a better proof but by averaging over many draws.
Example 2: Rendezvous Hashing – Same Task, Different Mechanics
A second approach emerged almost simultaneously and independently. According to the English Wikipedia, David Thaler and Chinya Ravishankar introduced rendezvous hashing at the University of Michigan in 1996 (technical report CSE-TR-316-96; the journal version appeared as "Using Name-Based Mapping Schemes to Increase Hit Rates", IEEE/ACM Transactions on Networking 6(1):1–14, February 1998). The IEEE page could not be read during this run, so these details come from the secondary account. That both schemes date from the 1990s is confirmed independently by the Maglev paper, which cites them both.
The mechanics dispense with the ring: for an object you compute a weight for every site and pick the site with the highest weight – "highest random weight". If a site fails, only the objects mapped to it need reassigning; the rest keep their winner, because that winner's weight is unchanged.
The relationship between the two schemes is interesting. Wikipedia's account describes rendezvous hashing as both simpler and more general, and presents consistent hashing as a special case of the scheme with a suitable two-place hash function. But it also names the price: when a site is removed, that site's objects can be spread over an unbounded number of other sites – so the reduction does not run the other way. If you deliberately want the load of a failed node to go to exactly one neighbour, you need the ring; if you want it scattered, you take rendezvous hashing. The same trade-off sits at the heart of shuffle sharding (The Smallest Possible Damage – Cells, Shuffle Sharding and the Art of Limiting the Blast Radius).
Example 3: Maglev – When Minimal Disruption Is the Wrong Priority
Google's software load balancer Maglev (Eisenbud et al., NSDI '16, pp. 523–535) makes the trade-off explicit – and decides it the other way around. Section 3.4 states that both classical schemes "prioritize minimal disruption over load balancing, as they were designed to optimize web caching on a small number of servers". Maglev "takes the opposite approach", because it is critical for Maglev to balance load as evenly as possible among the backends.
The construction follows from that: Maglev builds a lookup table of size M over N backends and always chooses M much larger than N – in the paper, larger than 100 × N, "to ensure at most a 1% difference in hash space". Each backend then receives either M/N rounded down or rounded up entries, that is, an almost exactly equal slice. In exchange, Maglev accepts that more assignments shift on changes than strictly necessary; the paper calls a small number of such disruptions tolerable, because complementary connection tracking catches existing connections.
The lesson is more general than the example: "minimal disruption" is not an end in itself. It is valuable when moving a key is expensive – because data must be copied or a cache entry is lost. It loses value when the state lives elsewhere anyway. And because tail latency in large systems is governed by the worst few per cent (The Long Tail of Latency: Tail Latency and Why Averages Lie in the Cloud), uneven load can cost more than redistribution.
Example 4: Jump Consistent Hash – Frugality as a Design Goal
A third extreme was described in 2014 by John Lamping and Eric Veach with the "jump consistent hash" (arXiv:1406.2294). According to the abstract the algorithm "can be expressed in about 5 lines of code", requires no storage, is faster than the classical ring, and does a better job of "evenly dividing the key space among the buckets".
The price is in the abstract too: "the buckets must be numbered sequentially". For a flock of identical shards that you grow and shrink at the end of the list, this is ideal. For a fleet of named machines where any one may fail, it does not fit: it follows from sequential numbering that you cannot remove a bucket from the middle without shifting the numbering. (This article draws that conclusion itself; the abstract states only the numbering condition.) That is not a weakness of the scheme but the consequence of a deliberate design decision.
Placing It: Three Questions Before Choosing a Scheme
I am of the opinion that the four examples condense into three design questions – this grid is my own summary, not a statement from any of the sources:
- How expensive is moving a key? Expensive (data copy, lost cache) → prioritize minimal disruption. Cheap (stateless request) → prioritize even load.
- Where should a failed node's load go? To one defined neighbour → the ring. Scattered across many → rendezvous hashing.
- Are the nodes identical and sequentially numberable? Yes → jump hash is the most frugal solution. No → ring with virtual nodes, or a table.
What none of these schemes delivers: they distribute keys, not load. A single very hot key stays on exactly one node, however even the hash – against such hot keys the remedy is replication or splitting the key, not a better hashing scheme.
The Central Takeaway
- Settle the cost question before choosing a scheme. The question "what does it cost to move a key?" decides whether minimal disruption or even load is the more important goal. Maglev shows that the classical answer is context-dependent.
- Probabilistic uniformity needs many draws. A server placed on the ring once produces an uneven distribution; the same server under many labels does not. The same principle carries the weighting of unequal hardware – with no special case in the code.
- Monotonicity is a guarantee about movements, not about equality. That a key does not pointlessly wander between old nodes says nothing about whether the nodes carry equal amounts. The two must be measured separately.
Reflection Question
Which scheme maps keys to nodes in the system you work on – and has anyone ever checked whether that scheme's priorities (minimizing disruption versus equalizing load) still match what moving a key actually costs there today?
Cross-References in the Vault
- The Smallest Possible Damage – Cells, Shuffle Sharding and the Art of Limiting the Blast Radius – how scattering rather than neighbourhood limits the blast radius
- The Long Tail of Latency: Tail Latency and Why Averages Lie in the Cloud – why uneven load becomes expensive
- Agreement Without a Vote: CRDTs and the Art of Conflict-Free Replication – state that survives relocation
- The Needle in a Billion Haystacks: Approximate Nearest Neighbor Search, HNSW, and the Architecture of Vector Databases – another scheme that trades exactness for cost
Fact Check
22 claims were checked (a: 12 hard facts, b: 4 quotations, c: 3 source attributions, d: 3 synthesis claims); 6 were corrected or weakened. The most important corrections:
- The claim that consistent hashing sits "inside almost every distributed data store" was weakened to "inside many distributed data stores and load balancers" – none of the checked sources supports such a statement about adoption.
- The bibliographic details for Thaler & Ravishankar could not be checked against the primary source (the IEEE page returned no text); they are explicitly marked in the article as a secondary citation following the English Wikipedia.
- The conclusion that a bucket cannot be removed from the middle with jump consistent hash does not appear in the abstract in that form; it is now identified as the article's own inference from the numbering condition stated there. The three-question grid is likewise marked as my own summary.
Automated AI check against primary sources; no human expert review.
Sources and Further Reading
- Karger, D. R., Lehman, E. P., Leighton, F. T., Panigrahy, R., Levine, M. S. & Lewin, D. (1997). Consistent Hashing and Random Trees: Distributed Caching Protocols for Relieving Hot Spots on the World Wide Web. Proceedings of the 29th Annual ACM Symposium on Theory of Computing (STOC '97), 654–663. https://doi.org/10.1145/258533.258660 – full text read during this run at https://www.cs.princeton.edu/courses/archive/fall09/cos518/papers/chash.pdf; bibliographic details verified at https://dblp.org/rec/conf/stoc/KargerLLPLL97.html
- DeCandia, G., Hastorun, D., Jampani, M., Kakulapati, G., Lakshman, A., Pilchin, A., Sivasubramanian, S., Vosshall, P. & Vogels, W. (2007). Dynamo: Amazon's Highly Available Key-value Store. SOSP '07. https://www.allthingsdistributed.com/files/amazon-dynamo-sosp2007.pdf
- Eisenbud, D. E., Yi, C., Contavalli, C., Smith, C., Kononov, R., Mann-Hielscher, E., Cilingiroglu, A., Cheyney, B., Shang, W. & Hosein, J. D. (2016). Maglev: A Fast and Reliable Software Network Load Balancer. NSDI '16, 523–535. https://www.usenix.org/conference/nsdi16/technical-sessions/presentation/eisenbud
- Lamping, J. & Veach, E. (2014). A Fast, Minimal Memory, Consistent Hash Algorithm. arXiv:1406.2294. https://arxiv.org/abs/1406.2294
- Thaler, D. & Ravishankar, C. (1998). Using Name-Based Mapping Schemes to Increase Hit Rates. IEEE/ACM Transactions on Networking, 6(1), 1–14. https://doi.org/10.1109/90.663936 – not directly retrievable during this run; details follow the English Wikipedia (https://en.wikipedia.org/wiki/Rendezvous_hashing)