System Design

Core Concepts

Consistent Hashing

It does not balance load. It bounds how much moves when membership changes, and those are completely different promises. Almost every mistake in this topic comes from confusing the two.

Why you are doing this at all

If you ask engineers what consistent hashing gives you, most will say it spreads load evenly across servers. That's the one thing it's bad at.

Here's the measurement. A hash ring puts nodes and keys on the same circle of hash values, and each key belongs to the next node along the circle. Take a ring with 100 nodes and one position per node, the version in the textbooks. Its busiest node carries 5.29 times the average load, and its emptiest carries almost nothing. That's close to the worst way you could spread load on purpose. Plain hash(key) % N, which hashes the key and takes the remainder after dividing by the node count N, spreads it five times more evenly.

The ring is good at something else. When you add a 101st node, only 0.99 percent of keys change owner, and that's the theoretical minimum. With hash(key) % N, 99 percent of them move.

What moves when a node joins
Top: with hash(key) % N, going from 4 nodes to 5 changes the node of 16 of the 20 keys, in red, and only 4 stay, in green. Bottom: on the ring, each key belongs to the next node clockwise. The new node E, in green, takes only the keys between B and itself, which C used to own. That is 4 of 20 keys, in red, the least that can move.Top: with hash(key) % N, going from 4 nodes to 5 changes the node of 16 of the 20 keys, in red, and only 4 stay, in green. Bottom: on the ring, each key belongs to the next node clockwise. The new node E, in green, takes only the keys between B and itself, which C used to own. That is 4 of 20 keys, in red, the least that can move.
Modulo N moves most keys. The ring moves only the minimum. Top: with hash(key) % N, going from 4 nodes to 5 changes the node of 16 of the 20 keys, in red, and only 4 stay, in green. Bottom: on the ring, each key belongs to the next node clockwise. The new node E, in green, takes only the keys between B and itself, which C used to own. That is 4 of 20 keys, in red, the least that can move.

Consistent hashing does not balance load. It bounds how much moves when membership changes. Membership is the set of nodes, and it changes whenever a node joins or leaves. The number of keys that move when it changes is called churn. Balance and churn are two different promises. Every confusion in this topic comes from expecting the first and getting the second.

Once you see that, the rest of the topic makes sense, because every technique below fills the same gap. Virtual nodes give each server many positions on the ring instead of one. They aren't an optional extra: they're the second mechanism that wins back the balance the ring gave up. Rendezvous hashing and jump hash exist because they give you both properties at once. Maglev exists because rendezvous is too slow at 1 million requests a second over thousands of backends, and jump hash can't remove a backend from the middle. Bounded loads exists because moving as little as possible does nothing about one popular key.

What the guarantee is actually for

The name undersells the property. It isn't really about hashing. It's about not having to coordinate.

The 1997 paper that named it, by Karger, Lehman, Leighton, Levine, Lewin and Panigrahy, was about web caching. There were many clients and a set of cache servers that changed without warning. There was no practical way to get every client to agree on the current membership. So they needed a function that many independent parties could each work out on their own, and get the same answer without talking to each other. When the parties disagreed about which servers were alive, the function still had to work reasonably well.

That's what you're really getting. So ask one question of any design, and the answer tells you whether you need this: is there something here that many uncoordinated parties have to agree on, while membership changes on its own? If yes, you want one of these algorithms. If no, you almost certainly want a lookup table.

The surprise in the timeline

Rendezvous hashing scores every node for each key and sends the key to the highest score. It's simpler than the ring, gives better balance, and needs no virtual nodes. Thaler and Ravishankar invented it at Michigan in 1996, a year before the ring, and published it in IEEE/ACM Transactions on Networking in 1998.

The ring won anyway. Akamai built a business on it, and ring implementations shipped in the databases people used. So if you've only ever seen the ring, that's an accident of history, not a sign that it's the better design. For small node counts, the 1996 algorithm is still the better choice.

When not to reach for this at all

This is the most common mistake, and the partitioning and sharding article covers it in more detail: if you already have a coordinator, you don't need a coordination-free algorithm.

A sharded transactional (OLTP) database has a shard map, a table that says which shard lives where. Notion, Figma, Pinterest and Vitess all route through one. A table of 480 rows is easy to read and easy to diff, and it lets you move one noisy tenant tonight, on purpose. Consistent hashing takes that away and gives you nothing in return. Nothing about that problem needs to be coordination-free: there's a control plane, the service that holds the map, and everybody reads it.

So the real scope is narrower than the topic's popularity suggests. It covers caches, content delivery network (CDN) tiers, layer 7 load balancers doing session affinity, distributed hash tables (DHTs) and peer-to-peer systems. Session affinity means sending all of one user's requests to the same backend. That list is most of it.

The toolkit

The guarantee, stated precisely

The ring treats the range of hash values as a circle. Each node hashes to one or more positions on it, and each key hashes to a position too. A key belongs to the first node position at or after its own, going clockwise and wrapping from the end back to the start. That's the whole algorithm.

So a new node takes only the keys between itself and the node position before it. A node that leaves hands its keys to the next node clockwise. Nothing else moves.

Removing a node from a ring
On the left, four nodes own two keys each: the blue dots before them, going clockwise. On the right, C is removed. Its two keys, in red, pass clockwise to D, so 2 of 8 keys move, the minimum. D now holds 4 keys, while A and B still hold 2.On the left, four nodes own two keys each: the blue dots before them, going clockwise. On the right, C is removed. Its two keys, in red, pass clockwise to D, so 2 of 8 keys move, the minimum. D now holds 4 keys, while A and B still hold 2.
The fewest keys move, and they all land on one node. On the left, four nodes own two keys each: the blue dots before them, going clockwise. On the right, C is removed. Its two keys, in red, pass clockwise to D, so 2 of 8 keys move, the minimum. D now holds 4 keys, while A and B still hold 2.

The right-hand ring shows the flaw that the rest of this article deals with. The guarantee held exactly: two of eight keys moved, which is 1/4, the minimum for a ring of four nodes. But all of the moved load went to one node, D, which now carries twice what each of the others carries.

This isn't bad luck in the drawing. It's how the ring works. With one position per node, all of a departing node's load lands on exactly one survivor, and you don't get to choose which. The same is true when a node joins. In our measurement over 200,000 keys, a node added with one position took keys from exactly one existing node. It wasn't the busiest node. It was whichever node came next, clockwise, after the new position.

The two numbers nobody measures

Here's the ring against the alternatives, measured rather than assumed.

Back of envelopeBalance and churn, measured, 100 nodes and 200,000 keys
Adding one node, so the ideal churn is 1/101 = 0.99 percent

  scheme                    max/avg   min/avg   moved   donors
  ─────────────────────────────────────────────────────────────
  hash(key) mod N             1.06x     0.95x   98.99%     100
  ring, 1 position/node       5.29x     0.01x    ~1.0%       1
  ring, 16 positions          1.73x     0.49x    ~1.0%      16
  ring, 64 positions          1.34x     0.71x    ~1.0%      44
  ring, 256 positions         1.16x     0.85x    ~1.0%      87
  ring, 1024 positions        1.08x     0.92x    ~1.0%     100
  rendezvous (HRW)            1.06x     0.95x    ~1.0%     100
  jump consistent hash        1.06x     0.94x    ~1.0%     100

mod N is perfectly balanced and moves everything.
The plain ring moves the minimum and is five times unbalanced,
with a node holding 1 percent of the average.
Rendezvous and jump get both properties, for free.

Balance figures are the expected worst case over 200 independent
ring layouts. Churn for the rings is the average: one layout
moved between 0.44 and 1.28 percent. Every consistent scheme
averages the 0.99 percent minimum.

Three things to note in that table.

The plain ring's min/avg is 0.01x. One of your hundred machines holds 1 percent of an average share, which is almost nothing, while another holds five times its share. You pay for both.

mod N spreads keys as evenly as anything in the table. Its failure has nothing to do with balance. It fails on churn alone: one new node moves 99 percent of the keys.

The donors column is the one that matters when you run the system. It counts how many existing nodes gave up keys when one node was added. At one position per node, the answer is one. So adding a machine to relieve an overloaded machine only works if you add it in exactly the right place, and with a random hash you can't choose the place. At 1024 positions per node, all 100 nodes give up some keys, and adding capacity finally does what you expect.

Churn and balance, measured
Each dot is one scheme on 100 nodes as a 101st joins. Across is the share of keys that change owner, and up is the busiest node against the average. The purple ring dots all sit at 1%, and come down only as the position count rises. Rendezvous and jump hash, in green, sit at the bottom with no tuning. hash(key) % N, in red, is balanced and moves 99%.Each dot is one scheme on 100 nodes as a 101st joins. Across is the share of keys that change owner, and up is the busiest node against the average. The purple ring dots all sit at 1%, and come down only as the position count rises. Rendezvous and jump hash, in green, sit at the bottom with no tuning. hash(key) % N, in red, is balanced and moves 99%.
Every consistent scheme moves the minimum. Only some of them balance. Each dot is one scheme on 100 nodes as a 101st joins. Across is the share of keys that change owner, and up is the busiest node against the average. The purple ring dots all sit at 1%, and come down only as the position count rises. Rendezvous and jump hash, in green, sit at the bottom with no tuning. hash(key) % N, in red, is balanced and moves 99%.

Virtual nodes, and what they cost

The standard fix is to give every physical node many positions on the ring instead of one. These positions are the virtual nodes. The table above shows them working: 16 positions take you from 5.29x to 1.73x, and 1024 positions get you to 1.08x.

What virtual nodes change
On the left, each node has one position, so the new node E, in green, takes its whole arc from one node, C. On the right, each node has three positions. E gets three as well, and takes a small slice, in red, from each of three different nodes.On the left, each node has one position, so the new node E, in green, takes its whole arc from one node, C. On the right, each node has three positions. E gets three as well, and takes a small slice, in red, from each of three different nodes.
With more positions, a new node takes a little from many nodes. On the left, each node has one position, so the new node E, in green, takes its whole arc from one node, C. On the right, each node has three positions. E gets three as well, and takes a small slice, in red, from each of three different nodes.

Real systems pick numbers in this range for that reason. Envoy's ring hash load balancer sets minimum_ring_size to 1024 entries by default and caps it at 8 million. Its documentation gives the arithmetic: with a minimum ring size of 1024 and 16 hosts, each host gets 64 positions. Dynamo also gives each node many positions, which it calls tokens. Cassandra uses the same word and sets the count with num_tokens.

On a replicating ring, the ring also decides which nodes hold each key's copies. There, raising this number costs you availability, not performance. A range is the stretch of keys between two neighbouring positions, and its copies go on the next distinct nodes clockwise.

Why more positions mean more peers
At replication factor 3, each range is copied to the next three distinct nodes clockwise. On the left, with one position per node, A, in purple, shares ranges only with the two nodes on each side, in red. If A and any one of them fail together, a range loses quorum. On the right, with three positions per node, A has different neighbours at each position, and shares a range with all 7 other nodes.At replication factor 3, each range is copied to the next three distinct nodes clockwise. On the left, with one position per node, A, in purple, shares ranges only with the two nodes on each side, in red. If A and any one of them fail together, a range loses quorum. On the right, with three positions per node, A has different neighbours at each position, and shares a range with all 7 other nodes.
More positions give each node more neighbours to share ranges with. At replication factor 3, each range is copied to the next three distinct nodes clockwise. On the left, with one position per node, A, in purple, shares ranges only with the two nodes on each side, in red. If A and any one of them fail together, a range loses quorum. On the right, with three positions per node, A has different neighbours at each position, and shares a range with all 7 other nodes.
Back of envelopeThe availability price of virtual nodes, 100 nodes at RF 3
A range's replicas are the next 3 distinct nodes clockwise.
Two nodes failing costs quorum on a range if both hold it.
So the risk is exactly: what fraction of node PAIRS co-own
some range. Computed by enumeration, not sampling.

  positions/node   distinct peers   P(2 failures lose a quorum)
  ──────────────────────────────────────────────────────────────
               1              4.0                        4.0%
               4             14.9                       15.1%
              16             47.4                       47.8%
              32             71.7                       72.4%
              64             91.5                       92.5%
             128             98.4                       99.4%
             256             99.0                      100.0%

At 256 positions every node shares a range with 99 of the
other 99 nodes. Any two simultaneous failures anywhere in
the cluster cost quorum on some range. There is no unlucky
pair, because every pair is unlucky.

This reasoning led to a real decision you can read for yourself. Apache Cassandra changed the default num_tokens from 256 to 16 in version 4.0, under CASSANDRA-13701. Two arguments drove it. First, Netflix engineers published a paper, "Cassandra Availability with Virtual Nodes," showing that 256 tokens lowers availability, which is the effect above. Second, 256 token ranges make repair painful. Repair is the background job that makes replicas agree, and repair and streaming both work one range at a time.

They accepted 1.73x imbalance instead of 1.16x, to bring the risk in the last column down from 100 percent to 48 percent. Then they won back some balance another way. A token allocation algorithm places tokens deliberately instead of at random. That's how 16 became "the smallest value which still provides an acceptable distribution."

Balance against availability
Top, in purple: the busiest node falls from 5.29x the average at one position to 1.08x at 1,024. Bottom, in red: the chance that two failed nodes share a range climbs from 4% to 100% by 256 positions. Cassandra moved from 256 to 16, which keeps 86 percent of the balance gain at 48 percent of the risk.Top, in purple: the busiest node falls from 5.29x the average at one position to 1.08x at 1,024. Bottom, in red: the chance that two failed nodes share a range climbs from 4% to 100% by 256 positions. Cassandra moved from 256 to 16, which keeps 86 percent of the balance gain at 48 percent of the risk.
The positions that fix balance also raise the risk of losing quorum. Top, in purple: the busiest node falls from 5.29x the average at one position to 1.08x at 1,024. Bottom, in red: the chance that two failed nodes share a range climbs from 4% to 100% by 256 positions. Cassandra moved from 256 to 16, which keeps 86 percent of the balance gain at 48 percent of the risk.
Naive

Raise the position count until the distribution looks acceptable

This is reasonable, and it's what the table invites: 1024 positions get you to 1.08x, so use 1024. It works until the ring is also choosing your replicas. At that point you've traded away your tolerance for a second node failure without noticing. The instinct isn't wrong. It improves one number while a second number gets worse, and nobody is watching the second one.

Senior

A measured compromise, with deliberate token placement

You pick the position count by looking at both numbers, balance and quorum risk. For a replicating store, that lands near Cassandra's 16, not near 256. Then you win back some of the lost balance without raising the count, by placing tokens deliberately instead of at random. This is what Cassandra 4.0 ships, and it's the correct standard answer.

The cost is the 1.73x imbalance. Your busiest node carries 73 percent more than the average, most of another node's worth of work, and you size every machine in the fleet for that node.

Staff

Stop asking the hash function for balance

There are two premises to question here, and they lead to different places.

The first premise is that you need a tuning parameter at all. You don't. Rendezvous and Maglev are balanced by design, at 1.06x and about 1.01x, as long as Maglev's table is much larger than the backend count. They have no position count to get wrong, so there's no availability setting hidden inside a balance setting. If you're choosing an algorithm rather than inheriting one, this removes the balance tradeoff instead of managing it. It doesn't remove the availability one if rendezvous also picks each key's replicas. Each key then gets its own top three, so nearly every pair of nodes shares some key, which is the 256-position row of the availability table.

The second premise goes deeper. Every scheme so far treats balance as something you hope a good hash gives you. That's why balance is a ratio you measure afterwards. Bounded loads, a version of the ring that caps each node, makes balance a constraint: no node ever holds more than (1 + e) times the average, where e is a margin you choose. The paper proves a maximum load of 2, with a constant expected number of moves per update. Compare the two: 5.29x hoped for, against 2x guaranteed. And the cap holds whatever the keys are, even if someone picks them to cause trouble, not only when they're evenly spread.

What you give up rules it out for some systems. Placement now depends on current load, so it's no longer a function of the key alone. Two clients with different views of load will route the same key differently. For a cache, that costs a duplicate fetch. For a store, two nodes can accept writes for the same key, and their copies drift apart. So bounded loads belongs in front of caches and load balancers, not in front of stored state.

Rendezvous hashing, which you should probably use more

For each key, you compute a score for every node as hash(key, node), and send the key to the node with the highest score. That's the whole algorithm, and it fits on one line. Its other name is highest random weight (HRW).

There's no ring, no virtual nodes, no sorted structure, and no memory beyond the node list. Balance is 1.06x with no tuning, which the ring can't reach even at 1024 positions per node. Churn is the theoretical minimum. Removing a node only affects the keys it scored highest for, and each of those moves to the node with its next-highest score.

It also gives you two things the ring struggles with. Weights are easy. You multiply each node's score by a capacity factor, so a bigger machine wins more keys. The Cache Array Routing Protocol did it this way in 1998, and so does the current Internet Engineering Task Force (IETF) draft on weighted HRW. And an ordered replica list is free: sort the nodes by score and take the top k. On a ring, you have to walk clockwise and skip positions that belong to a node you already have. That's fiddly, and it's where a lot of buggy implementations go wrong.

Rendezvous hashing for one key
Every node gets a score, hash(user:42, node). D scores highest, in green, so user:42 lives on D. The top three scores, (1) D, (2) B and (3) C, are the replica list. If D leaves, user:42 goes to B, and no key that D did not win moves.Every node gets a score, hash(user:42, node). D scores highest, in green, so user:42 lives on D. The top three scores, (1) D, (2) B and (3) C, are the replica list. If D leaves, user:42 goes to B, and no key that D did not win moves.
The highest score wins, and the next scores are the replicas. Every node gets a score, hash(user:42, node). D scores highest, in green, so user:42 lives on D. The top three scores, (1) D, (2) B and (3) C, are the replica list. If D leaves, user:42 goes to B, and no key that D did not win moves.

The cost is that every lookup computes one hash per node, so it's O(N). With 16 backends, that's nothing. With 5,000 nodes and 1 million lookups a second, it's 5 billion hashes a second, which rules it out. That's the only reason not to use it.

Lookup cost as the backend count grows
Rendezvous, in orange, computes one hash per backend: 16 at 16 backends, and 5,000 at 5,000. The ring, in purple, does a binary search of log2(128 × N) steps, from about 9 to 20 across this range. Maglev, in green, is always one hash and one array read. The ring costs more than its line shows, because each step waits for the memory read before it.Rendezvous, in orange, computes one hash per backend: 16 at 16 backends, and 5,000 at 5,000. The ring, in purple, does a binary search of log2(128 × N) steps, from about 9 to 20 across this range. Maglev, in green, is always one hash and one array read. The ring costs more than its line shows, because each step waits for the memory read before it.
Rendezvous grows with the backend count, the ring grows slowly, and Maglev stays flat. Rendezvous, in orange, computes one hash per backend: 16 at 16 backends, and 5,000 at 5,000. The ring, in purple, does a binary search of log2(128 × N) steps, from about 9 to 20 across this range. Maglev, in green, is always one hash and one array read. The ring costs more than its line shows, because each step waits for the memory read before it.

Jump consistent hash, and the constraint that defines it

Lamping and Veach at Google published this in 2014, in a paper called "A Fast, Minimal Memory, Consistent Hash Algorithm." It takes a key and a number of buckets, n, and returns a bucket number. It's about five lines of code, uses no memory, runs in O(ln n), and gets both properties: we measured its balance at 1.06x, and its churn at the minimum.

It sounds better than everything above in every way. There's exactly one catch, and it decides where you can use it: buckets are numbered 0 to n-1, and the number is all the identity they have. You can grow to n+1 buckets and shrink to n-1. You can't remove bucket 3 from the middle without renumbering every bucket above it, and that moves keys that had no reason to move.

Removing a server from the middle of jump hash
Each bucket number points at a server. When s3 dies, the only way down is from 8 buckets to 7, which drops bucket 7. So s4 to s7 each shift down one bucket, in red, and the keys on five servers move, 5/8 of the total, when only the 1/8 on s3 had to.Each bucket number points at a server. When s3 dies, the only way down is from 8 buckets to 7, which drops bucket 7. So s4 to s7 each shift down one bucket, in red, and the keys on five servers move, 5/8 of the total, when only the 1/8 on s3 had to.
Jump hash can only shrink at the end, so a dead server forces a renumbering. Each bucket number points at a server. When s3 dies, the only way down is from 8 buckets to 7, which drops bucket 7. So s4 to s7 each shift down one bucket, in red, and the keys on five servers move, 5/8 of the total, when only the 1/8 on s3 had to.

So jump hash is excellent for a set of numbered slots that only grows or shrinks at the end, and that means logical shards. It's useless for a fleet of servers, where the failure you see is "server 37 died." The paper says as much: the numbering makes it better suited to data storage than to distributed web caching.

Maglev, for when a lookup has to be free

Maglev is Google's software network load balancer, published at NSDI 2016 by Eisenbud and colleagues. Its hashing scheme works differently. Instead of working out an answer for each request, it precomputes a lookup table, so every request is one array index.

Two hashes of each backend's name give it a permutation of the table's slots, its own order of preference. Then the backends take turns. Each one claims its next preferred slot that's still free, until the table is full. The result is near perfect balance and O(1) lookup. When a backend joins or leaves, a few more entries change than on a ring, so the disruption is small but not quite the minimum.

Building and reading a Maglev table
Two hashes of each backend name give its offset and skip, and so its order of preference over the 7 slots. The backends take turns, and each claims its next preferred slot that is still free, in teal. Dashed slots were already taken. The finished table, in purple, gives A three slots and B and C two each. A packet hashes its 5-tuple, the addresses, ports and protocol, to slot 4, and one read gives backend C.Two hashes of each backend name give its offset and skip, and so its order of preference over the 7 slots. The backends take turns, and each claims its next preferred slot that is still free, in teal. Dashed slots were already taken. The finished table, in purple, gives A three slots and B and C two each. A packet hashes its 5-tuple, the addresses, ports and protocol, to slot 4, and one read gives backend C.
The work happens when the table is built, so a lookup is one read. Two hashes of each backend name give its offset and skip, and so its order of preference over the 7 slots. The backends take turns, and each claims its next preferred slot that is still free, in teal. Dashed slots were already taken. The finished table, in purple, gives A three slots and B and C two each. A packet hashes its 5-tuple, the addresses, ports and protocol, to slot 4, and one read gives backend C.

The table size must be prime, and the paper keeps it at least 100 times the backend count, so no backend gets more than about 1 percent extra. Its 65,537-slot table therefore suits a few hundred backends, and a larger pool needs a larger prime. Envoy ships Maglev alongside its ring hash and publishes a comparison. Against a ring hash with a large ring of 256K entries, Maglev builds its table about 10 times faster and picks a host about 5 times faster.

The 5x has a mechanical cause, and it applies to any lookup structure: whether the structure fits in the CPU cache.

Back of envelopeWhy the table wins: it fits in cache
Maglev table, 65,537 entries, u16 backend index
  65,537 x 2 B                        = 128 KB
  → fits in L2 on any modern core
  lookup = 1 hash + 1 array read, no search

Ring, 256K entries, 8 B hash + 4 B index
  262,144 x 12 B                      = 3.1 MB
  → exceeds L2, lives in L3 or memory
  lookup = binary search, 18 steps,
           each a dependent pointer chase

Envoy's published numbers: Maglev is ~5x faster at host
selection and ~10x faster at table build.

Rendezvous at the same job
  N = 16 backends    16 hashes/lookup   fine
  N = 5,000 backends 5,000 hashes x 1M rps
                     = 5B hashes/s          dead

Three algorithms, three different reasons they win or lose,
and none of the reasons is the churn guarantee.

Consistent hashing with bounded loads

Every scheme so far decides placement from the key alone. So a single popular key gets one node, forever, whatever that does to the node. The churn guarantee says nothing about this, because nothing is moving.

Mirrokni, Thorup and Zadimoghaddam fixed this in a paper at SODA 2018. They add a capacity cap. Each node may hold at most (1 + e) times the average load. A key that hashes to a full node walks forward round the ring to the next node with room. They prove a maximum load of 2 times the average, while each update moves only a constant number of keys on average.

This one runs in production. Andrew Rodland at Vimeo built it into HAProxy 1.7 as the hash-balance-factor option. Vimeo ran it in production before it was merged, and reported that it cut their cache bandwidth by almost a factor of eight. Google reports using it in Cloud Pub/Sub.

The comparison, in one table

algorithmlookupmemorybalancechurnweightsordered replicasneeds node identity
hash % NO(1)none1.06xterriblenonono
ring, 1 positionO(log n)n5.29xminimalnoawkwardyes
ring, many positionsO(log vn)vn1.1 to 1.7xminimalvia position countawkwardyes
rendezvousO(n)n1.06xminimalmultiply the scorefree, sort by scoreyes
jump hashO(ln n)none1.06xminimalnonono, numbered slots only
MaglevO(1)table, 100x the backends or more~1.01xnear minimalvia permutation countnoyes
bounded loadsO(1) amortisedring plus counterscapped by constructionconstant per updateyesnoyes

The last column decides most real arguments. Jump hash can't express "node 37 died." That one fact, not speed and not balance, keeps jump hash out of server fleets, where the ring is still the usual choice.

The method

Ask six questions, in order. The first two usually settle it.

Six questions for choosing a scheme
Ask the questions in order, (1) to (6). Each arrow down is the answer that keeps you going. Each arrow to the right ends at an answer: the yellow boxes are a lookup table, the orange box is the extra machinery a store needs, and each purple box rules out an algorithm or prices one.Ask the questions in order, (1) to (6). Each arrow down is the answer that keeps you going. Each arrow to the right ends at an answer: the yellow boxes are a lookup table, the orange box is the extra machinery a store needs, and each purple box rules out an algorithm or prices one.
The first two questions usually end at a lookup table. Ask the questions in order, (1) to (6). Each arrow down is the answer that keeps you going. Each arrow to the right ends at an answer: the yellow boxes are a lookup table, the orange box is the extra machinery a store needs, and each purple box rules out an algorithm or prices one.

1. Is anything here about churn? If your set of destinations is stable and changes only when a person decides, you don't need this. Use a table. Say so out loud, because spotting this is worth more than reciting the algorithm.

2. Can the participants coordinate? If there's a control plane everyone already reads, the table wins on everything that matters when you run the system: you can read it, diff it and override one entry. Coordination-free algorithms are for when coordination isn't available.

3. Cache or store? This decides whether you can live with clients disagreeing about membership. For a cache, two clients with different views cause some duplicate work and a few extra misses. For a store, they cause two nodes to accept writes for the same key, with no error anywhere. The algorithm is the same. In the cache it's fine, and in the store it's a data corruption bug.

4. What does a lookup cost, times your request rate? This question rules out rendezvous above a few hundred nodes. It also pushes you to a precomputed table above a few hundred thousand requests a second. Do the multiplication.

5. Do you need weights, an ordered replica list, or removal from the middle? Any one of those rules out jump hash. Weights and replica lists point strongly to rendezvous.

6. Choose the balance mechanism, then price it. On a ring, you pick a position count. If that ring also places replicas, work out the availability cost before you pick a big number.

Worked examples, start to finish

Here are four systems. In each one, the obvious approach fails for a different reason, and only two of the four end with a ring.

A CDN cache tier, where the obvious approach evicts everything

Twenty cache nodes sit in front of an origin, the server that holds the real content. They take 500,000 requests a second with a 95 percent hit rate in steady state. So the origin sees 25,000 requests a second, and it's sized for roughly that. Routing is hash(url) % 20. Everybody writes that first, because it's one line and perfectly balanced.

Then one node restarts for a kernel patch.

Back of envelopeWhat one node restart does to the origin
20 nodes, 500,000 req/s, 95 percent hit rate
  steady state origin load                    = 25,000 req/s

hash(url) mod N, going from 20 nodes to 19
  a key stays put only if k mod 20 = k mod 19
  which over lcm(20,19) = 380 holds for 19 values
  → keys that keep their node       19/380  =  5%
  → keys that move                          = 95%
  new miss rate  0.95 + 0.05 x 0.05         ≈ 95.3%
  origin load  500,000 x 0.953              ≈ 476,000 req/s
                                              19x, an outage

Consistent hashing, same event
  keys that move                     1/20   =  5%
  new miss rate  0.05 + 0.95 x 0.05         ≈  9.8%
  origin load  500,000 x 0.098              ≈  49,000 req/s
                                              2x, survivable

The origin does not need to be 19 times bigger. It needs the
routing function to stop reshuffling the whole cache when one
machine reboots.

The origin load went up 19 times. The cache didn't get slower, and nothing was unbalanced. The routing function lost 5 percent of the capacity and threw away 95 percent of a warm cache in response. That's the whole argument for consistent hashing, and it's an argument about churn.

Origin load when one cache node restarts
One of 20 cache nodes restarts at the 1 minute mark. With hash(url) % 20, in red, 95 percent of keys move, and the origin jumps from 25,000 to 476,000 requests a second, 19 times normal. With consistent hashing, in purple, 5 percent move, and the origin peaks at 49,000, under its assumed capacity of 60,000, the grey dashed line. The shape of the decay is assumed.One of 20 cache nodes restarts at the 1 minute mark. With hash(url) % 20, in red, 95 percent of keys move, and the origin jumps from 25,000 to 476,000 requests a second, 19 times normal. With consistent hashing, in purple, 5 percent move, and the origin peaks at 49,000, under its assumed capacity of 60,000, the grey dashed line. The shape of the decay is assumed.
The routing function decides whether a restart is an incident. One of 20 cache nodes restarts at the 1 minute mark. With hash(url) % 20, in red, 95 percent of keys move, and the origin jumps from 25,000 to 476,000 requests a second, 19 times normal. With consistent hashing, in purple, 5 percent move, and the origin peaks at 49,000, under its assumed capacity of 60,000, the grey dashed line. The shape of the decay is assumed.

The decision is a ring with enough positions per node to be reasonably balanced. Add one rule for running it, which matters more than the choice of algorithm: a node that fails a health check stays on the ring. The stateful store example below explains why. While clients disagree about membership, they may fetch the same object twice. That's acceptable here, because fetching one object twice is the worst case.

A layer 7 load balancer, where the obvious approach is too slow

A service takes 1 million requests a second across 5,000 backends, and it needs session affinity. Every request in a session must land on the same backend, so that the backend's local cache is useful. Consistent hashing on the session ID is clearly the right family. So you reach for a ring, because that's the hashing option your proxy ships.

This time the failure has nothing to do with balance or churn. Both are fine. The problem is that you're now searching a data structure on the busiest code path you have, 1 million times a second, and the structure doesn't fit in the CPU cache. The "Why the table wins" worksheet above has the arithmetic. A ring of 256K entries is 3.1 MB, and a binary search through it is 18 memory reads. Each read depends on the one before, and most of them miss the cache.

Naive

Modulo the backend count

It's fast, balanced and one line. But every deploy that changes the backend count sends nearly every session to a new backend. That throws away every backend's local cache at once, and whatever sits behind the backends gets the same 19x spike as in the CDN example. It's the CDN mistake again. The failure doesn't care whether the thing being reshuffled is cache entries or sessions.

Senior

A ring with enough positions, which is what your proxy does

This is correct and standard. Envoy's ring hash defaults to a minimum ring size of 1024 entries and lets you go up to 8 million. With 5,000 backends, you need a large ring for decent balance, because fewer than a few positions per host puts you back near the 5.29x end of the table.

You pay the cost on every request, for as long as the service runs: a binary search over a structure too big for the L2 cache, plus the memory itself. At 8 million entries of 12 bytes each, that ring is 96 MB of memory per cluster, and it's rebuilt on every membership change.

Staff

Precompute the answer instead of computing it

The premise to question is that a lookup has to search a structure at all. It doesn't. Maglev moves the work: it builds a table when membership changes, and then each request costs one hash and one array read.

Here's the size of the trade. With 5,000 backends, the table needs at least 500,000 slots, so take the prime 500,009. At 2 bytes each, that's about 1 MB, a third of the 3.1 MB ring, and a lookup is one read instead of 18 that depend on each other. Envoy publishes the result of this swap with its default 65,537-slot table: roughly 5x faster host selection and 10x faster table build, against a 256K ring. At 1 million requests a second, that decides whether routing costs too little to notice or shows up in your flame graph, the profile of where CPU time goes.

What you give up: when membership changes, Maglev moves a few more sessions than a ring would. You're trading a little churn for a lot of speed. That's the right trade for session affinity, and the wrong one for a cache tier, where every moved key is a miss. This is the first decision in the article where the churn guarantee is the thing to give up.

A stateful store, where the obvious approach breaks availability

Take a Dynamo-style key-value store such as Cassandra. It has 100 nodes and replication factor 3, so each key has three copies. Reads and writes use quorum, so two of the three replicas must respond. You know from the toolkit that one position per node gives 5.29x imbalance, so you set the position count high. 256 sounds thorough.

You've just made sure that any two nodes failing at the same time, anywhere in the cluster, cost quorum on some range. The availability worksheet in the toolkit works it out exactly: at 256 positions, 100 percent of node pairs share at least one range. No pair of nodes is safe to lose.

This failure is different from the previous two. Nothing is slow, nothing is unbalanced, and the churn guarantee holds. But the mechanism you added to fix balance turned "we tolerate two node failures" into "we tolerate one."

The decision is Cassandra's: 16 positions, not 256. You accept 1.73x imbalance instead of 1.16x. The chance that two failures lose quorum somewhere drops from 100 percent to 48 percent, and repair becomes manageable as well. Then you win back some balance by allocating tokens deliberately instead of at random.

Here's why 16 is a good number and not an arbitrary one. Going from 1 position to 256 improves balance from 5.29x to 1.16x. Sixteen positions get you to 1.73x, which is 86 percent of that whole improvement, at 48 percent of the quorum risk instead of 100 percent. The last 14 percent of the balance gain costs the other half of your availability.

This example has a second decision, and it causes more incidents than the first.

Naive

Remove a node from the ring when its health check fails

This feels like self-healing, and it's the first thing anyone builds, because the alternative sounds like keeping a dead node in your topology on purpose. The topology is the ring's current list of nodes and positions. The problem is what counts as a failure. A five-second garbage collection (GC) pause fails a health check, so the node leaves the ring. Every client recomputes, and the node's keys stream to a neighbour. Then the node comes back, and everything streams back. You've paid for two full topology changes to survive a pause that a retry would have covered. And this happens under load, because that's when pauses happen. So it happens exactly when you can least afford the streaming.

Senior

Explicit membership, with hinted handoff for transient failure

Ownership changes only when an operator says so. If a node is briefly unreachable, a write goes to the next available node along with a hint, a note saying where the write belongs. When the node returns, the hints are replayed to it. This is hinted handoff. Dynamo specified it in 2007, and the paper states the principle directly: a node outage rarely signifies a permanent departure and therefore should not result in rebalancing of the partition assignment. Amazon went further and removed its global failure detector. It found that with explicit join and leave, nobody needed a cluster-wide view of which nodes had failed.

This has costs. A machine that really is dead stays in the topology until a person acts, so you need an alert and a runbook. You also carry a backlog of hints that has to be replayed, and the replay can fall behind.

Staff

Stop deriving ownership from liveness at all

The premise to question is that liveness and ownership are one system. Liveness is whether a node is answering right now. Ownership is which node is responsible for a range. They aren't one system, and you can tell because they work on timescales five orders of magnitude apart.

A GC pause lasts a tenth of a second. A rolling deploy takes a couple of minutes. Decommissioning a machine takes hours to days. A mechanism that lets the first of those drive the third is off by a factor of about 100,000. No tuning of the health check threshold fixes an error that large. So build two systems. The first is a fast, noisy, cheap liveness signal that only ever changes where a request is sent. The second is a slow, durable ownership record with an audit trail, and it only changes when someone decides.

Liveness and ownership run on different clocks
On a log scale, a GC pause lasts about 0.1 seconds, a long one 5 seconds, and a rolling deploy a couple of minutes. Decommissioning a machine takes hours to days, about 100,000 times longer than a pause. The teal liveness signal should only steer requests. The yellow ownership record should change only when someone decides.On a log scale, a GC pause lasts about 0.1 seconds, a long one 5 seconds, and a rolling deploy a couple of minutes. Decommissioning a machine takes hours to days, about 100,000 times longer than a pause. The teal liveness signal should only steer requests. The yellow ownership record should change only when someone decides.
A GC pause and a decommission are five orders of magnitude apart. On a log scale, a GC pause lasts about 0.1 seconds, a long one 5 seconds, and a rolling deploy a couple of minutes. Decommissioning a machine takes hours to days, about 100,000 times longer than a pause. The teal liveness signal should only steer requests. The yellow ownership record should change only when someone decides.

Here's what you gain. Topology changes drop from however many times a day your slowest node pauses, to however many times a month you replace hardware. Each change you avoid is streaming and rebalancing you don't do, and one less chance to start the cascade in the celebrity key example below.

What you give up is automatic recovery when a node is lost for good. A dead machine now leaves you degraded until a person notices. This trade is only right if your alerting is better than your health checks at telling a pause from a death. It usually is, because the alert is allowed to be slow. It can wait minutes before it fires, and no pause lasts that long.

A celebrity key, where the algorithm is the cause

A cache ring has 20 nodes, and each can serve 100,000 requests a second. It carries 800,000 requests a second, spread evenly, so every node sits at 40 percent, with plenty of room.

Then one object goes viral and starts taking 150,000 requests a second on its own.

Back of envelopeOne popular key, and the cascade that follows
20 nodes, 100,000 req/s capacity each
  background load 800,000 / 20             = 40,000/node, 40%

One key arrives at 150,000 req/s
  its node:  40,000 + 150,000              = 190,000 req/s
                                             = 190% of capacity, dies

Remove the dead node from the ring
  the key moves to its successor, which also
  inherits the dead node's other keys
  successor:  40,000 + 40,000 + 150,000    = 230,000 req/s
                                             = 230%, dies faster

  → each removal makes the next node's job harder.
    This is a cascade, not a failover.

With bounded loads at factor 1.25
  new average  (800,000 + 150,000) / 20    = 47,500 req/s
  per node cap  1.25 x 47,500              = 59,375 req/s
  the key fills its node to the cap and
  overflow walks forward
  spare per node  59,375 − 40,000          = 19,375 req/s
  nodes it spans  150,000 / 19,375         ≈ 8 nodes
  → nobody exceeds 60% of capacity, nothing dies

The middle block is the one that matters. Removing the overloaded node doesn't shed its load. It concentrates it: the successor gets the celebrity key plus the dead node's ordinary keys. Every hash scheme in this article sends the celebrity key to exactly one new node. The churn guarantee is the reason: moving as little as possible means the key's load goes to one place. With one position per node, as here, the dead node's ordinary keys follow it to that same node.

One hot key, with and without bounded loads
In panel 1, the hot key adds 150,000 requests a second, in red, to the 40,000 n4 already carries, so n4 runs at 190 percent. In panel 2, n4 is removed, and n5 takes the hot key plus the rest of n4's keys, in grey: 230 percent. In panel 3, bounded loads caps every node at 59,375 a second, so the hot key, in green, fills n4 to n11 up to the cap, and no node passes 60 percent.In panel 1, the hot key adds 150,000 requests a second, in red, to the 40,000 n4 already carries, so n4 runs at 190 percent. In panel 2, n4 is removed, and n5 takes the hot key plus the rest of n4's keys, in grey: 230 percent. In panel 3, bounded loads caps every node at 59,375 a second, so the hot key, in green, fills n4 to n11 up to the cap, and no node passes 60 percent.
Removing an overloaded node makes the next one worse, and a cap spreads the key out. In panel 1, the hot key adds 150,000 requests a second, in red, to the 40,000 n4 already carries, so n4 runs at 190 percent. In panel 2, n4 is removed, and n5 takes the hot key plus the rest of n4's keys, in grey: 230 percent. In panel 3, bounded loads caps every node at 59,375 a second, so the hot key, in green, fills n4 to n11 up to the cap, and no node passes 60 percent.

The decision is bounded loads, and you can trust it because others run it. Vimeo put it into HAProxy 1.7 as hash-balance-factor and reported cutting cache bandwidth by almost a factor of eight. Google reports using the same algorithm in Cloud Pub/Sub. The cost is that placement now depends on current load, so it's no longer a function of the key alone. Two clients with different views of load can disagree about where a key goes. For a cache, that's fine. For a store, it isn't.

Where it goes wrong

These are ordered by how often they turn up. The first causes most of the misunderstanding, and the second causes most of the outages.

1. Believing it balances load

This is the thesis of the article. With the textbook ring, the busiest node carries 5.29x the average and the emptiest 0.01x. If a design says "consistent hashing" and doesn't say how many positions per node, nobody has thought about balance. Ask for the number, because there's no safe default. With too few positions you're at 5x, and with too many you have the availability problem from the stateful store example.

2. Removing a node from the ring because a health check failed

This is the mistake that causes real incidents. The Dynamo paper stated the principle in 2007, and nobody has put it more clearly since. A node outage rarely signifies a permanent departure and therefore should not result in rebalancing of the partition assignment or repair of the unreachable replicas. So Dynamo made membership changes explicit. An operator issues them through a tool, and gossip, nodes passing the news to each other, spreads them. Amazon also deleted its global failure detector. It had concluded that explicit join and leave made a cluster-wide view of failures unnecessary. Each node notices short failures locally, when it can't reach another node.

Three things go wrong when you tie membership to health checks instead.

A node that flaps, failing and recovering again and again, costs you two full reshuffles, out and back, for an outage that may have been a five-second GC pause. GC pauses are most likely under load, and that's when you can least afford the reshuffles.

A five-second pause, handled two ways
At the top, the pause fails a health check, so n7 leaves the ring and its keys stream to a neighbour. When n7 returns, they stream back, all for a 5 second pause. At the bottom, membership is explicit. Writes for n7 go to a neighbour with a hint, n7 stays the owner, and the hints are replayed when it returns.At the top, the pause fails a health check, so n7 leaves the ring and its keys stream to a neighbour. When n7 returns, they stream back, all for a 5 second pause. At the bottom, membership is explicit. Writes for n7 go to a neighbour with a hint, n7 stays the owner, and the hints are replayed when it returns.
Tying membership to health checks turns a pause into two topology changes. At the top, the pause fails a health check, so n7 leaves the ring and its keys stream to a neighbour. When n7 returns, they stream back, all for a 5 second pause. At the bottom, membership is explicit. Writes for n7 go to a neighbour with a hint, n7 stays the owner, and the hints are replayed when it returns.

Clients notice the failure at different times, so for a while they disagree about the ring. Mistake 3 is about that disagreement.

And it cascades, as in the celebrity key example. Removing the node moves its load onto a neighbour, and that makes the neighbour more likely to fail its own health check.

The rule is: liveness and ownership are separate concerns. When a node isn't answering, retry its requests elsewhere without changing who owns the data. That's what hinted handoff is for, and it's why Dynamo has it.

3. Using it for a store where clients disagree about membership

Consistent hashing is built for participants that don't coordinate, so disagreement isn't an edge case. It's the normal state of things. Whether that's safe depends entirely on what you're storing.

Two clients, two views of the ring
Client 1 has not seen node N join, and client 2 has, so they send key k to different nodes. In the cache, both nodes fetch k from the origin, k is fetched twice, and nothing is wrong. In the store, client 1 writes v1 to B and client 2 writes v2 to N. Both writes succeed with no error, and one key now has two values.Client 1 has not seen node N join, and client 2 has, so they send key k to different nodes. In the cache, both nodes fetch k from the origin, k is fetched twice, and nothing is wrong. In the store, client 1 writes v1 to B and client 2 writes v2 to N. Both writes succeed with no error, and one key now has two values.
The same disagreement costs a cache one fetch and a store its data. Client 1 has not seen node N join, and client 2 has, so they send key k to different nodes. In the cache, both nodes fetch k from the origin, k is fetched twice, and nothing is wrong. In the store, client 1 writes v1 to B and client 2 writes v2 to N. Both writes succeed with no error, and one key now has two values.

For a cache, the disagreement costs a duplicate fetch. For a store, two nodes accept writes for the same key, both writes succeed, and nobody gets an error. The two copies have now diverged, and no read will show it until something compares the two values. That's why real stores that use a ring also ship anti-entropy: Merkle tree comparison, read repair and vector clocks. The ring tells you who owns a key in steady state. It says nothing about disagreement, or about the move from one owner to the next. If you're storing state, you must add the machinery that handles both. If you're not going to, use a coordinated shard map.

4. Assuming the guarantee covers the move itself

This is a related mistake, and harder to spot. The ring says key K belongs to node B now that A is gone. It doesn't say how the data gets from A to B. Until it does, both nodes have a fair claim to the key: A still has the bytes, and B is the answer the ring gives.

Every production system fills this gap explicitly. Dynamo uses hinted handoff for short failures and Merkle tree anti-entropy for permanent ones. Cassandra has a protocol for moving tokens, and it streams whole ranges to the new owner. If your design says "and then the keys move to the new node," an interviewer will ask who serves reads during the move. "The ring handles it" isn't an answer.

5. Cranking virtual nodes without pricing the availability cost

The stateful store example covers this. It's on this list because you can't see it until two nodes fail and you find out you were never tolerating two failures. The cost of repair and streaming also grows with the position count, so you pay it all the time, not only when something fails. If the ring places replicas, the position count is an availability setting that also happens to affect balance.

6. Hashing the wrong thing

The algorithm is only as good as its input, and a person chooses the input.

If you hash a full URL that includes a cache-busting query parameter, every request is a unique key. Your cache hit rate is zero, and the ring is working perfectly. If you hash a session cookie that rotates, affinity stops working and nothing tells you. If you hash a user ID when you needed to keep a conversation together, one conversation ends up spread across the fleet.

All of these look like hashing problems, and none of them are. Write the key expression down, then ask what changes inside it that shouldn't.

7. Ignoring the hot key, because the guarantee says nothing about it

Minimal movement is a promise about what happens when membership changes. A popular key isn't a membership change. Nothing moves, the guarantee holds, and one node is overloaded. Three fixes work: bounded loads, copying the hot key to k nodes and picking one at random, or a small cache in front of the tier. The hash function won't notice the hot key on its own.

8. Reaching for a ring when a table would do

This is last because it's the least dramatic, though it's the most common waste. You'll build it, and it will work. But you'll have given up per-key placement, a table you can read, and the ability to move one tenant on purpose. In return you get freedom from coordination you didn't need. Ask question 1 of the method first.

If you memorise nothing else

factwhy it matters
It bounds churn, it does not balance loadthe single most common misunderstanding of the topic
Ring with one position per node: 5.29x imbalancethe textbook construction is unusable as written
hash % N moves 99 percent of keys when N changesperfectly balanced and still the wrong answer
Every consistent scheme moves 1/(N+1) when adding a nodethat is the theoretical minimum, and they all hit it
With one position per node, all moved load lands on one neighbouradding a machine does not relieve the machine you meant
At 256 positions and RF 3, every node pair co-owns a rangeany two failures cost quorum somewhere
Cassandra moved num_tokens from 256 to 16 in 4.0balance traded for availability and cheaper repair
Virtual nodes on a replicating ring are not logical shardsthe sizing rule inverts: more is not better here
Rendezvous hashing predates the ring and is better balanced1.06x, no tuning, free weights, free replica lists
Rendezvous is O(n) per lookupwhich is the only reason not to use it
Jump hash cannot remove a node from the middlenumbered slots only, so it is for shards, not servers
Maglev is fast because a lookup is one read from a small table128 KB at 65,537 slots; size it at 100 times the backends or more
Bounded loads caps each node at (1+e) times averagethe only scheme here that addresses a hot key
Never remove a node from the ring on a health checkliveness and ownership are separate concerns
Membership disagreement: fine for caches, corruption for storesthis decides whether you may use the family at all
If you have a control plane, use a lookup tablecoordination-free algorithms are for when coordination is absent

What is expected at each level

Mid-level

Be able to explain the ring: the hash space is a circle, nodes claim positions on it, and a key belongs to the next position clockwise. Be able to say why hash % N is a problem, in terms of how much moves when N changes. Know that virtual nodes exist, and roughly why.

You're not expected to bring up rendezvous hashing, Maglev, bounded loads or the availability cost of token counts unprompted. You are expected to answer sensibly when asked. If you're asked how even the distribution is, don't say it's even. Say it depends on the number of positions per node, and that with one each it's quite bad.

The mistake to avoid is describing it as a way to balance load. It's a way to limit churn, and it needs help to balance.

Senior

You drive this, and three things must come up without prompting.

The guarantee and its limit, in the same breath. "Adding a node moves about 1/N of the keys, which is the minimum, and balance is a separate problem I solve with virtual nodes." Stating only the first half is the most common miss at senior level, because it sounds exactly like a memorised blog post.

A position count, with a reason. Name a number. If the ring also places replicas, say that the number is an availability decision and not only a balance decision. A ring with one position per node lands badly, and so does refusing to name a number.

Membership handling that isn't a health check. Say that a short failure must not change the topology, and name the alternative: retry elsewhere, hinted handoff and explicit membership. This shows you've run a ring, not only read about one.

Two things disqualify you: describing consistent hashing as producing an even distribution, and having no answer for what happens to the data during a move.

Staff+

The question shifts from explaining the algorithm to deciding whether it belongs in the design at all.

Ask whether the problem is coordination-free. If there's a control plane every participant already reads, say that a lookup table beats every algorithm here, because you can read it and control each key, and that you'd rather have those. Reaching for a ring when you already own a config service is the expensive mistake in this topic, because nobody sees it and you can't undo it.

Separate the two promises explicitly and pick per axis. The axes are churn, balance, lookup cost, weights, replica lists and node identity. Each one rules something out. The load balancer example gives up some churn for speed, and the cache tier won't. The skill is saying which axis you're giving up, and what for.

Price the mechanism, not just the algorithm. Work out the virtual node count against availability at your replication factor, the ring's memory and rebuild cost at your node count, and the lookup cost times your request rate. Each of these is arithmetic, and each one can change an answer.

Say what happens during the transition and during disagreement. Say who serves reads while a range moves, and what two clients with different views of membership do to your data. If the answer to the second is "they both write," you've found a reason not to use this family.

And be able to say what you would not build. A team can lose a quarter to each of these.

One is a custom ring with virtual nodes and weighted placement, when rendezvous hashing was five lines and better balanced at that node count. Another is a rebalancing daemon tied to health checks. It turns every GC pause into two reshuffles, and every hot node into a cascade. A third is an anti-entropy and read repair system for a tier that was a cache, where a miss would have been fine.

Then there's moving from a working shard map to a hash ring because the ring seems more elegant, which gives up the ability to pin one tenant. There's a hand-rolled bounded-load variant, when HAProxy has shipped one since 1.7. And there's tuning the position count for balance without ever working out what it did to the number of node pairs that share a range.

Sources

Every number attributed to a company, paper or project below comes from that published source. The balance, churn and availability numbers come from a simulation written for this article: 100 nodes, 200,000 keys, and 200 random ring layouts for the balance figures.

Spot a mistake, or something unclear? . Or get in touch.

Article

Send feedback

Thank you for helping. We read every report and fix what is wrong.

How do you feel about oneby7?

Sign in to oneby7

Keep your progress, your streak and your code, on any device.

New here? This creates your account too.