The idea in one minute#
Redundancy protects against failures of infrastructure. It does nothing against failures that travel with the traffic: a poison request that crashes every server it reaches, a customer who sends a hundred times their usual load, a bad deploy. Those hit every replica, because every replica serves everyone.
Cell-based architecture limits the blast radius: split the service into independent, identical, complete copies (cells), each serving a fixed subset of customers. A failure in one cell reaches only that cell’s customers. Shuffle sharding goes further: each customer is assigned a small, random combination of workers, so two customers almost never share the same full set — a poison customer can take down its own workers, while nearly every other customer still has at least one healthy worker.
An analogy#
A ship divided into watertight compartments survives a hull breach (cells). Shuffle sharding is like giving each passenger a personal set of two lifeboats chosen at random from forty: even if a fire destroys two specific lifeboats, almost nobody else has lost both of theirs.
A picture#
flowchart TB
R[":i-route: <b>Cell router</b><br/><small>thin, simple: customer → cell</small>"]
subgraph C1["Cell 1 — customers A–F"]
A1[":go: app"] --> D1[(":postgresql: db")]
end
subgraph C2["Cell 2 — customers G–M"]
A2[":go: app"] --> D2[(":postgresql: db")]
end
subgraph C3["Cell 3 — customers N–Z"]
A3[":go: app"] --> D3[(":postgresql: db")]
end
R --> C1 & C2 & C3
X[":i-skull: Poison request<br/>from customer H"] -.->|"only cell 2 affected"| A2
class R queue
class A1,A2,A3 compute
class D1,D2,D3 memory
class X warnHow it really works#
Cells#
A cell is a complete, independent instance of the service — compute, storage, queues, caches — sized to a fixed maximum. Customers (or tenants, or users by hash) are mapped to cells by a thin cell router.
| Design rule | Why |
|---|---|
| Cells share nothing stateful | Otherwise the shared part is a single blast radius |
| Fixed maximum cell size | Scale by adding cells, not growing them; every cell is a tested size |
| A thin, simple, highly reliable router | It is the one shared component; keep logic minimal and data cached |
| Deploy cell by cell | A bad release reaches one cell first (Module 8) |
| A canary cell with internal or low-risk customers | First to get every change |
| Migration tooling | Customers must be movable between cells (rebalancing, noisy tenants) |
Blast radius with C cells: one cell failing affects 1/C of customers. AWS uses cells
extensively (many services are built from dozens of cells per region); Slack, DoorDash and
others have described moving to cellular architectures to contain zonal and deploy failures.
Costs: more operational units to run and observe, harder cross-customer features (global search, analytics), the router as a new component, and capacity fragmentation.
Shuffle sharding#
With N workers and each customer assigned a random set of k, the number of distinct shards
is C(N, k) (“N choose k”). If a customer’s requests crash every worker they reach, they take
down their k workers — and another customer is completely cut off only if their own shard
is the same k workers.
| Workers N | Shard size k | Distinct shards C(N,k) | Chance another customer has the identical shard |
|---|---|---|---|
| 8 | 2 | 28 | 3.6% |
| 8 | 4 | 70 | 1.4% |
| 100 | 5 | 75,287,520 | 0.0000013% |
Compare with simple sharding (4 fixed groups of 2 workers): a poison customer takes out their group, and 25% of customers share it.
Shuffle sharding needs the client (or router) to retry on another worker in the shard when one fails, so that partial overlap (sharing one of two workers) costs a retry, not an outage. Route 53 and other AWS services use it; it also applies to queues, database connection groups and rate-limit pools.
What still crosses cells#
Cells contain failures that come with the traffic. They do not help with:
- A bad change pushed to all cells at once — the deploy must be staged per cell.
- A shared dependency outside the cells (an identity provider, a payment processor).
- Global control planes (the router’s configuration, DNS) — keep them out of the request path where possible (static stability: cells keep working if the control plane is down).
A worked example#
A multi-tenant API with 2,000 tenants runs on 8 workers. One tenant starts sending a malformed request that crashes any worker that parses it.
- All workers shared: within seconds all 8 crash-loop. 100% of tenants down.
- 4 cells of 2 workers: the poison tenant’s cell is down; 500 tenants (25%) are down.
- Shuffle sharding, k = 2: the poison tenant’s 2 workers crash. Tenants whose shard includes one of them retry on their other worker and see a brief slowdown; tenants whose shard is the identical pair — about 1 in 28 — are down. In the program’s run that is 82 tenants, instead of 500 or 2,000, while about 900 see one retry and stay up.
The program computes the combinatorics and simulates the poison tenant.
Code#
// shuffle.go — blast radius of a poison tenant: shared fleet vs cells vs shuffle sharding.
package main
import (
"fmt"
"math/big"
"math/rand"
)
func choose(n, k int64) *big.Int { return new(big.Int).Binomial(n, k) }
func main() {
fmt.Println("Distinct shards C(N, k):")
for _, c := range [][2]int64{{8, 2}, {8, 4}, {20, 3}, {100, 5}, {1000, 6}} {
fmt.Printf(" N=%4d k=%d → %s\n", c[0], c[1], choose(c[0], c[1]).String())
}
const workers, tenants, k = 8, 2000, 2
r := rand.New(rand.NewSource(9))
// Shuffle-shard assignment: each tenant gets k distinct random workers.
shards := make([][]int, tenants)
for t := range shards {
shards[t] = r.Perm(workers)[:k]
}
poison := 0
dead := map[int]bool{}
for _, w := range shards[poison] {
dead[w] = true
}
down, degraded := 0, 0
for t := 1; t < tenants; t++ {
hit := 0
for _, w := range shards[t] {
if dead[w] {
hit++
}
}
switch hit {
case k:
down++
case 0:
default:
degraded++ // a retry on the other worker succeeds
}
}
// Simple sharding: 4 cells of 2 workers; tenant t in cell t%4.
cellDown := 0
for t := 1; t < tenants; t++ {
if t%4 == poison%4 {
cellDown++
}
}
fmt.Printf("\nOne poison tenant crashes every worker it reaches (%d tenants, %d workers):\n", tenants, workers)
fmt.Printf(" shared fleet: %4d tenants down (100%%)\n", tenants-1)
fmt.Printf(" 4 cells of 2 workers: %4d tenants down (%.0f%%)\n", cellDown, 100*float64(cellDown)/float64(tenants-1))
fmt.Printf(" shuffle sharding k=2: %4d tenants down (%.1f%%), %d see a retry but stay up\n",
down, 100*float64(down)/float64(tenants-1), degraded)
}Remember this#
- Redundancy does not help against failures that travel with traffic: poison requests, noisy tenants, bad deploys.
- Cells are complete, independent copies serving fixed subsets of customers; blast radius is
1/C. - Keep the router thin and statically stable; deploy cell by cell; make customers movable.
- Shuffle sharding gives each customer a random combination of
kofNworkers; full overlap is1 / C(N,k). Clients must retry within their shard.
Try it#
- Run
shuffle.go. Setkto 3. How do “down” and “degraded” change? - With 1,000 tenants and 12 workers, find the smallest
kfor which fewer than 1% of tenants share the poison tenant’s exact shard. - Sketch a cell design for a service you know. What is shared between cells, and can you remove it?
Check yourself#
- Why does adding replicas not protect against a poison request?
- What must be true of the cell router?
- With 8 workers and shards of 2, what is the probability that another tenant shares a given tenant’s exact shard?
- Name two failures cells do not contain.