One poison tenant took down all 999 others in a shared pool. Four cells cut that to 249; shuffle shards of 2 out of 16 workers left 4 tenants fully down.
One tenant wedged every worker
Belgavi's Book Store runs a small agent platform for the independent shops it supplies. Each shop is a tenant: it gets a help-desk agent that answers stock questions, drafts replies to customers and files CASE records. Sixteen workers sit behind one queue, and every request from every tenant can land on any worker.
One Monday a tenant uploaded a catalogue with a 400-page PDF embedded in a product description. Every request that touched it sent the agent into a tool loop that held a worker's model connection and memory until the request timed out. Retries from the agent framework put the same request back on the queue, a different worker picked it up, and within twenty minutes all sixteen workers were stuck on the same poison input. Every tenant on the platform was down, including the 999 that had done nothing unusual.
The operators had capacity, health checks and autoscaling. What they did not have was a limit on how far one tenant's requests could reach. That limit is what cells and shuffle sharding provide, and both are cheap to add before the incident and expensive to retrofit after it.
Two ways to bound the blast radius
A cell is a complete, independent copy of the serving stack (workers, queues, caches, sometimes the database) that owns a fixed subset of tenants. A thin routing layer maps each tenant to one cell and nothing else is shared. If a tenant breaks its cell, the other cells keep running. AWS describes this as reducing the scope of impact: with four cells, one bad tenant can hurt at most a quarter of the customers.
Shuffle sharding works inside a pool. Each tenant gets a small, fixed set of workers (its shard), chosen pseudo-randomly from the pool. Two tenants share a worker only when their shards overlap, and they share all of their workers only when their shards are identical. With 16 workers and shards of 2 there are 120 possible shards, so the chance that another tenant has exactly the poison tenant's shard is 1 in 120. The AWS Builders' Library article on workload isolation with shuffle sharding describes the technique as AWS applies it.
The two compose. Cells cap the worst case at one cell. Shuffle sharding inside the cell cuts the share of tenants inside that cell who lose everything.
The numbers for one poison tenant
The companion example places 1,000 synthetic tenants on 16 workers four ways and lets tenant T-0042 take down every worker in its shard. A tenant is down when all of its workers are down and degraded when only some are.
| Placement | Down | Degraded | Untouched | Exact chance of being down |
|---|---|---|---|---|
| Shared pool, every tenant on all 16 workers | 999 | 0 | 0 | 100% |
| 4 cells of 4 workers | 249 | 0 | 750 | 25% |
| Shuffle shards of 2 out of 16 | 4 | 244 | 751 | 1 in 120 |
| 2 cells of 8, shuffle shards of 2 inside | 16 | 214 | 769 | 1 in 56 |
The simulated counts sit close to the exact hypergeometric probabilities: with shards of k workers out of n, the share of tenants that overlap the poison shard in j workers is C(k, j) C(n - k, k - j) / C(n, k). For k = 2 and n = 16 that is 1/120 for a full overlap and 28/120 for a single shared worker.
Notice what happened to the combined design: it has more tenants fully down (16) than plain shuffle sharding (4), because a cell of 8 workers offers only 28 distinct shards. Cells buy independence from shared state and a hard cap; they do not improve shuffle-sharding odds inside a smaller pool. Choose cell size with both effects in mind.
A second bad tenant changes the arithmetic
Isolation numbers usually get quoted for one bad actor. With two poison tenants in the shuffle-sharded pool, four workers are down, and any tenant whose two workers are both among those four is down. There are C(4, 2) = 6 such shards, so roughly 6 in 120 tenants lose everything: the example counts 49, more than twelve times the single-tenant figure, not twice. Correlated failures (a bad model release that every tenant hits, a shared dependency) are worse still, because they ignore shards entirely. Shuffle sharding defends against a few tenants misbehaving, not against everything failing at once.
Placement must be stable and computed the same way everywhere
The shard is a function of the tenant id. The router, the admin tools and any client library that retries inside the shard must compute the same answer, in every process, after every restart. Python's built-in hash() of a string is salted per process, so it is the wrong tool. The example uses FNV-1a of the tenant id to seed a small PRNG and draws the shard with a partial Fisher-Yates shuffle:
def fnv1a(text):
h = 0x811C9DC5
for b in text.encode('utf-8'):
h ^= b
h = (h * 0x01000193) & 0xFFFFFFFF
return h
def place(tenant, cells, workers_per_cell, shard_size):
"""Return (cell, sorted worker indexes) for a tenant. Stable across processes."""
h = fnv1a(tenant)
cell = h % cells
rnd = mulberry32(h ^ 0x9E3779B9)
pool = list(range(workers_per_cell))
for i in range(shard_size):
j = i + int(rnd() * (workers_per_cell - i))
pool[i], pool[j] = pool[j], pool[i]
return cell, sorted(pool[:shard_size])A test in the example starts a fresh interpreter and checks that T-0042 lands on the same workers there. Any change to this function is a migration: every tenant may move, so caches go cold and in-flight work must drain. Version the placement function and keep the old one until the move is done.
Large or noisy tenants deserve explicit treatment rather than luck. A simple rule is to check, when assigning a shard, that no other tenant above a size threshold already has the identical shard, and to redraw if one does.
Degraded only helps if clients retry inside the shard
The 244 degraded tenants in the table have one dead worker and one healthy one. Whether they notice depends on the client. If a request that fails on a dead worker is retried on the other worker in the same shard, they see a latency blip. If the router picks one worker at random and gives up on failure, half of their requests fail. The companion lab shows the difference: with retries inside the shard, 0.8 percent of all requests fail in its default scenario; without them, 13.11 percent do.
The retry must stay inside the shard. A retry that escapes to the whole pool is exactly how the poison request reached all sixteen workers in the opening story. For agent platforms this matters more than for stateless APIs, because agent frameworks retry by design: a tool error is fed back to the model, which tries again.
What belongs in a cell for an agent platform
For an agent platform the cell boundary should include everything one tenant's runaway can exhaust:
- model-serving connections and their concurrency limits;
- the work queue and the worker pool;
- tool sandboxes and their CPU, memory and wall-clock limits;
- vector index and cache partitions;
- per-tenant budgets for tokens and tool calls.
The routing layer and the control plane that assigns tenants to cells stay outside, and they must be the simplest, most boring parts of the system. Static stability applies: if the control plane is down, existing assignments keep working.
Failure modes to design for
- Shared state leaks across cells. A single Redis or database behind every cell turns cells into a deployment detail. Count the shared dependencies before claiming isolation.
- Poison follows the retry. The agent framework, the queue and the client each retry; make sure all three stay inside the shard and stop after a small, fixed number of attempts per request.
- Hot tenant, small shard. A large tenant on 2 workers can overload them on a normal day. Shard size may differ per tier, as long as it is fixed per tenant.
- Placement drift. Two implementations of the placement function (router in one language, admin tool in another) that disagree on even one tenant send traffic to the wrong workers. Test them against shared fixtures, as the lab and the example do.
- Correlated failure. A bad model version or prompt template deployed to all cells at once bypasses both mechanisms. Roll changes out cell by cell.
Tradeoffs
| Choice | Gains | Costs |
|---|---|---|
| More, smaller cells | Smaller worst case per incident | More fixed overhead, fewer shards per cell, harder capacity planning |
| Larger shards | Each tenant survives more worker loss | More overlap between tenants, wider poison reach |
| Shuffle sharding only | Cheap, works in one pool | Shared dependencies still couple everyone |
| Cells only | Hard isolation, simple story | Up to a whole cell of tenants down at once |
How to verify it on your platform
Start with the arithmetic: for your worker count and shard size, compute the exact chance of a full overlap and decide whether it is acceptable. Then test the mechanism, not the math. In a staging cell, mark one synthetic tenant as poison (for example a tool that hangs), send traffic for all tenants, and count how many others see errors. The count should be close to the expectation; if it is near 100 percent, a retry or a shared dependency is escaping the shard. Finally, check placement parity: dump the shard for every tenant id from the router and from each other implementation and diff the files.
Jenya, who runs the platform's on-call rota, now runs that poison drill each quarter. The last one took down two workers, left four tenants fully down and 244 briefly degraded, and nobody outside the drill noticed.
Running the companion code
cd examples/python/agent_cells_shuffle_sharding
python example.py
python -m unittest -v test_example.pyThe example prints the four placements for one and two poison tenants with the exact probabilities. model.py is the reference model for the interactive lab and adds a seeded choice of poison tenants and the retry option.
Interactive experiment
Cells and shuffle sharding: how far one bad tenant reaches. Synthetic browser-local fixtures, adjustable inputs, decision traces and JSON export.