Skip to content
About
Main content

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.

  1. The workload must be retryable and effectively stateless across the members of a shard, or the surviving node is no help.
  2. The failure must be tenant-induced, not resource-induced. 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 : no loss.

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 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