Rebalancing Without Reshuffling: How a Key Finds Its Node
Before a distributed store can read or write anything, it has to decide where the data lives. Every key has to map to a node, every client has to compute that mapping the same way the cluster does, and the mapping has to stay cheap — you cannot consult a directory for a billion keys. The natural first answer is to hash the key to a number and take it modulo the node count: hash(key) % N gives you a node index, it is a pure function any client can compute locally, and it spreads keys evenly across the cluster. For a cluster whose size never changes, it is genuinely hard to beat.
The trouble is that clusters change size constantly — you add capacity, a node fails, you scale back in — and hash(key) % N reacts to a size change catastrophically. The node a key lands on depends on N, so the instant N changes, the mapping changes for almost every key at once. Go from three nodes to four and the result of % 3 versus % 4 differs for roughly three-quarters of all keys, which means three-quarters of your data is suddenly on the wrong node and must be shipped across the network to wherever the new modulus says it belongs. One node joining forces a near-total reshuffle, saturates the network for the duration, and invalidates every client's routing table in a single step.
So the real design problem is not "how do I map keys to nodes" — modulo hashing does that fine. It is "how do I map keys to nodes in a way that barely moves when the set of nodes changes." This post is about the two answers that matter, and why Zaris uses the stronger one.
Why modulo hashing can't survive a resize
It is worth being precise about why the reshuffle is so total, because the instinct is to think a small change to N should cause a small change to the mapping. It does the opposite. The modulo operation folds the entire hash space into N buckets, and changing N re-folds the whole space along completely different boundaries — there is no relationship between a key's bucket under % 3 and its bucket under % 4. A key that was perfectly placed has no reason to stay placed; its position was an artifact of the old modulus, and the new modulus assigns it afresh with no memory of the old one. The fraction of keys that keep their node when N grows by one is only about 1/(N+1), so the bigger the cluster, the larger the share that stays put — but it is never most of them, and for small clusters it is a rout.
Consistent hashing: put the nodes on the ring too
The classic fix is consistent hashing, and its trick is to stop hashing into N buckets and instead hash into a large, fixed circular space — imagine the hash output wrapped into a ring. You place the nodes on that ring too, by hashing each node's identity, and a key belongs to the first node you meet walking clockwise from the key's position. Now the key's position on the ring never depends on N; it is fixed by the key's own hash. When a node joins, it drops onto one arc of the ring and takes over only the keys that fall in that arc — the keys between it and its predecessor. Every other key is undisturbed, so a join moves about 1/N of the data instead of nearly all of it. A departure is the mirror image: the failed node's arc folds into its successor, and nothing else moves.
Pure consistent hashing has two rough edges, both fixed by the same device. A handful of randomly-placed nodes carve the ring into uneven arcs, so load is lumpy; and when a node dies, its entire arc lands on one unlucky successor rather than spreading out. Both are solved with virtual nodes — each physical node is hashed to many positions on the ring, so its responsibility is sliced into many small arcs scattered around the circle. Load evens out, and a failure's keys redistribute across many survivors instead of one.
Fixed slots: name the buckets and move them on purpose
Zaris takes the idea one step further, the same step Redis Cluster takes, and it is worth seeing why the extra step earns its keep. Instead of an implicit ring whose boundaries shift as nodes come and go, introduce a fixed number of named slots — a large constant, independent of node count — and split the mapping into two halves. The first half, key to slot, is a pure stable function: CRC16(key) % SLOT_COUNT. It depends on nothing but the key, so it is identical on every client, forever, and never recomputes when membership changes. The second half, slot to node, is a small explicit assignment map the cluster owns and gossips to everyone.
// key → slot is a PURE, STABLE function — identical on every client, forever.
int slot = Crc16(key) % SLOT_COUNT; // SLOT_COUNT is a fixed constant, not the node count
// slot → node is a small explicit map the cluster owns and gossips.
Node owner = slotMap[slot]; // changes ONLY when a slot is deliberately reassigned
// Rebalancing moves whole slots, never individual keys:
slotMap[9123] = nodeD; // reassigns ~1/SLOT_COUNT of the keyspace in one line
// → only the keys currently in slot 9123 migrate; every key→slot mapping is untouched
That split is the whole payoff. Because key-to-slot never changes, a client can route any key to its owner with a local CRC and a lookup in a tiny table, with zero coordination — which is exactly what partition-aware routing relies on. Because rebalancing reassigns whole slots, the migration unit is a bounded, enumerable set of keys rather than a scattering, which is what lets a cutover hand off ownership precisely and track exactly what moved. Operators rebalance deliberately — "move these slots from the busy node to the new one" — instead of hoping a hash function spreads load well. And forcing related keys into one slot with a hash tag is trivial, because the slot is a first-class, addressable thing rather than a transient arc on a ring. The slot count caps the routing table at a known size no matter how large the keyspace grows.
Wrap-up
Mapping a key to a node with hash(key) % N is cheap and even, and it falls apart the moment N changes, because the modulus re-folds the entire hash space and relocates most of the data for a single join or departure. Consistent hashing fixes the big problem by fixing the key's position independent of node count — keys and nodes share a ring, a key belongs to the next node clockwise, and a membership change touches only about 1/N of the data, with virtual nodes smoothing out the lumps. Fixed slots, the model Zaris uses, keep that resilience and add deliberate control: key-to-slot is a stable pure function that never moves and every client computes identically, while slot-to-node is a small owned map, so rebalancing ships whole slots on purpose, clients route with no coordination, migrations are precise and enumerable, and colocation is just a matter of landing in the same slot. The question "which node owns this key?" should have an answer that a resize barely disturbs — and the way you get there is to stop letting the node count decide where a key lives.