Consistent Hashing
In short: plain sharding with hash(key) % num_nodes reassigns almost
every key the moment num_nodes changes, because the modulus itself changed.
Consistent hashing places both nodes and keys on the same hash
ring (a fixed range like 0..359, wrapping around), and assigns each key
to the first node it meets going clockwise. Adding a node only steals the arc
of keys between it and the previous node clockwise — every other key's
nearest node never changes. With few nodes, one node's arc can still end up
much bigger than another's by chance; virtual nodes (each real node
placed at many positions on the ring) fix that by averaging away the luck.

Only k6 moves — from C to the new D, because D's ring position (16)
sits between B (12) and C (19), right where k6 (15) already was. k1,
k3 and k4 land on positions D can't reach, so their owners don't change
at all.
Add a node without reshuffling the whole cluster
Quarry compares how many of 8 keys actually move when a third node joins, under consistent hashing versus plain modulo sharding:
Consistent hashing moves 1 key; modulo sharding moves 7 of the same
8 — because hash(key) % 2 and hash(key) % 3 agree on almost nothing, even
though only one node was added.