Design worker isolation for 5,000 customers on 30 workers. One customer's import routinely saturates all assigned capacity. Compare full-pool random routing, ten fixed groups of three, and three-worker shuffle shards. Quantify overlap and explain behavior after a worker failure.
Reliability & Failure Recovery · Staff
Every customer has three workers. Why do the same noisy tenants keep colliding?
The Failure Should Have Stopped There · Part 5 of 6 · 6 min read
Read the worked explanation ↓Think first
Design worker isolation for 5,000 customers on 30 workers. One customer's import routinely saturates all assigned capacity. Compare full-pool random routing, ten fixed groups of three, and three-worker shuffle shards. Quantify overlap and explain behavior after a worker failure.
Take a few minutes to form an approach, then compare it with the worked explanation.
Check the exercise numbers
C(30,3) = 4,060 hands. For a fixed tenant and one independently assigned other tenant, exact equality is about 0.0246%, while any overlap is 1 − 2,925 / 4,060 ≈ 27.96%. With 5,000 tenants and only 4,060 hands, some complete-hand reuse is unavoidable; the small pairwise probability does not mean the whole fleet has no collisions. A failed worker leaves affected three-worker tenants two choices, so their shifted traffic still needs spare capacity and local admission.
Reveal the worked explanation
Interview question. A job service operates 30 interchangeable workers and supports thousands of tenants. A tenant's jobs can overload workers. Static partitions leave some workers idle and ordinary random routing spreads one bad tenant's traffic widely. Explain shuffle sharding, choose the shard size and calculate what isolation it does, and does not, provide.
Imagine a support call from tenant North. Their exports have been slow for an hour. The on-call engineer sees no problem with North's requests. Another tenant has started a large scraping job that consumes CPU on their shared workers.
A straightforward first attempt is static partitioning. Divide the workers into ten groups of three and assign each tenant to one group. That bounds an overloaded tenant to three machines, but every tenant in that group is affected. Tenants may also distribute unevenly by actual work, leaving idle groups next to hot ones. A completely random worker selection on every request has the opposite problem: it uses capacity flexibly but permits noisy work to touch the whole fleet. Shuffle sharding looks for a middle ground by giving each tenant a stable, relatively small, distinct subset chosen from a larger worker pool.
Think of dealing cards. From 30 workers, assign each tenant a set of three distinct workers using a deterministic keyed placement function. For example tenant A receives workers 2, 11 and 28, while tenant B receives workers 4, 11 and 20. They share one worker but not their entire allocation. Keep the chosen set stable across requests so a tenant does not wander through all 30 machines. A routing library can derive the same assignment from tenant identity and a versioned membership map.
Here is the calculation that matters. With 30 workers and three in a hand, there are C(30,3) = 4,060 distinct hands. If two tenants were assigned uniformly and independently, the probability they receive exactly the same three workers is 1 / 4,060, around 0.0246%. That's encouraging, but it is not the probability they share any worker. The chance of at least one common worker is 1 - C(27,3)/C(30,3), about 27.96%. A noisy tenant saturating all three of its workers can affect another tenant on a shared worker, even when their hands differ. The size and severity of that effect depend on admission budgets and how the second tenant's work is scheduled over its healthy choices.
Do not tell the interviewer shuffle sharding makes collisions impossible. It reduces correlated blast radius when the allocation and scheduling policies make full dependence on all shared resources unlikely. If each tenant needs only one healthy worker for a task and can route around an overloaded choice, a partial overlap is less damaging. If a job requires all three assigned workers to coordinate, a single common hot worker might be enough to stall progress. The algorithm's isolation properties cannot be separated from the workload's execution semantics.
How should work choose among the three workers? For stateless requests, a client or router may pick the healthiest member of the tenant's hand with a bounded policy and avoid sending extra requests into a known full queue. For stateful workers, jobs may have sticky ownership or cached local state. Randomizing every task inside the hand may balance arrivals but can still create unfairness without per-tenant admission. Give each tenant a budget and make workers enforce local capacity limits. Shuffle sharding is not a substitute for rate limiting, worker fairness, authentication, or task cancellation.
What if ten large tenants share a small hand size but the rest are tiny? A uniform three-worker allocation may be a bad fit. You can assign differentiated hand sizes for customer classes, or move heavy tenants to dedicated capacity, provided you can quantify how those changes affect overlap and total utilization. Larger hands allow a tenant to use more worker capacity and tolerate individual worker failures, but also increase its potential interference footprint. Smaller hands improve isolation yet cap the tenant's peak parallelism. When fleet membership changes, deterministic placement may remap many tenants unless the assignment scheme is designed for stable membership updates.
Now imagine a worker dies. Every tenant whose hand includes that worker suddenly has only two available choices. Their tasks may shift simultaneously onto the remaining members. Health-aware routing and spare capacity need to handle this correlated movement. Replacing a failed worker can temporarily change a hand, but the policy must not accidentally give a hot tenant access to the entire fleet during recovery. Test how the system behaves when one worker fails, when all of a single tenant's workers are saturated, and when an entire availability zone is unavailable. Worker placement across zones matters more than neat combinations on paper.
It's worth contrasting shuffle sharding with a cell. A self-contained cell has separate data-plane resources and, ideally, independent state. Shuffle sharding is usually a subset-allocation strategy inside a shared pool. It allows controlled overlap and better packing but therefore does not promise the hard failure boundary of a cell. You might place several cells across a region and use shuffle sharding within each cell for stateless workers. Do not shuffle workers across cells if doing so destroys the independence you built the cells to provide.
For an interview, I would show the collision arithmetic, then ask how much useful work a customer loses when one shared worker gets hot. Measure the affected-tenant count, worst-case overlap, per-tenant p99, worker CPU, queue age and fairness under deliberate noisy-neighbor load. A product might accept a 28% chance of touching at least one common worker because the other two still provide healthy capacity. Another product might not. Shuffle sharding becomes an engineering choice only when you connect the combinations to actual customer isolation and capacity contracts.
Go deeper
There are two common construction approaches: stateless deterministic assignments from tenant IDs and fleet membership, or stateful allocation that searches for hands with bounded overlap. The latter may improve worst-case overlap guarantees for a bounded tenant population at the cost of coordination and metadata maintenance. Uniform independent hands are a useful baseline for probability calculations but can concentrate large tenants by chance. Account for weighted work cost and placement constraints, including ensuring members of one hand are not all in one zone. A change in membership requires an explicit assignment-version and draining policy, especially for stateful jobs.
Check your reasoning
- Explain a stable small hand drawn from a larger worker fleet.
- Calculate `C(30,3)=4060` and full matching-hand probability `1/4060`.
- Separate any-worker overlap `1-C(27,3)/C(30,3)` from total collision and interpret the results.
- Connect hand size and overlap to task execution semantics, fairness and failure.
- Evaluate membership changes, zone placement and why shuffle shards differ from self-contained cells.
Common mistake: Only one of 4,060 worker hands matches exactly, so fewer than 0.03% of tenant pairs share any worker.
Read the answer explanation
Full-hand collision is rare but partial overlap is about 27.96% for independently chosen three-worker hands — Matching all three workers is different from sharing at least one of three choices. The latter is much more likely.
Apply it elsewhere
Apply shuffle sharding to a notification provider with three outbound delivery gateways per account. Decide how to preserve stable assignments during rolling deployments and prevent one spammer from saturating shared outbound IP reputation.
Compare your approach
State the deterministic subset assignment, distinguish full-hand collision from partial overlap, calculate the combinatorics correctly, connect overlap to workload availability and fairness, and handle capacity, membership and zone failure.
One more constraint
When two tenants independently receive three distinct workers from a 30-worker fleet, is the chance of sharing at least one worker equal to `1/4,060`?
Quick revision
Shuffle sharding gives each tenant a stable small hand of workers from a larger shared pool. It reduces shared-fate collisions without requiring fixed isolated partitions. With 30 workers and a three-worker hand there are 4,060 combinations, so exact hand collision probability for two independent tenants is 1/4,060. Any-worker overlap is much more common, about 27.96%. Actual isolation depends on routing, task semantics and tenant admission. Larger hands improve available parallelism while increasing the interference footprint. Cells remain a stronger isolation boundary.
References
- Shuffle Sharding: Massive and Magical Fault Isolation · AWS Architecture Blog
- Cell-based architecture FAQ: shuffle sharding · AWS Well-Architected
- Workload isolation using shuffle-sharding · AWS Builders Library