Shuffle sharding
How does combinatorial assignment isolate tenants without reserving capacity?
This is the sharpest idea in the article, and it is pure combinatorics. With n nodes, assign each tenant (a customer or client of the service) a random subset of k nodes. The number of distinct assignments is the binomial coefficient C(n, k) (the number of ways to choose k items out of n).
Two conditions make it work, and both are essential.
- The workload must be retryable and effectively stateless across the members of a shard, or the surviving node is no help.
- The failure must be tenant-induced, not resource-induced. Shuffle sharding isolates poison pills and hot tenants. It does not isolate a capacity shortfall, because every node still serves many tenants and there is no resource partition at all.
That is also its advantage over bulkheads: no multiplexing loss. Isolation comes from combinatorics instead of from reservation.
This is randomization replacing coordination once more, and here the randomness does something specific: it manufactures independence between tenants where the physical system offers none. It does the same job as jitter on a different axis. Jitter decorrelates in time; shuffle sharding decorrelates in assignment.
import random
def shard_for(tenant_id, nodes, k=2):
rng = random.Random(tenant_id) # stable per tenant
return rng.sample(nodes, k) # each tenant gets its own random pair