Topic 212 / Advanced
Cell-based architecture
Chapter 13.4 · Cell-Based Architecture
What and why
A bulkhead (→ 153) partitions resources inside one service so that one failure can't exhaust what every other caller needs. Cell-based architecture applies that same containment principle to the entire stack: partition compute, data, and queues together into independent cells, each a complete, self-contained slice serving a bounded subset of tenants or users, so that nothing — not a bad deploy, not an overload, not a bug — in one cell can reach another cell's resources. Builds on: → 153 (bulkhead).
Diagram
┌──────────────┐
request ── router ──┤ which cell? │
└──────┬───────┘
┌──────────────────┼──────────────────┐
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Cell A │ │ Cell B │ │ Cell C │
│ compute+db │ │ compute+db │ │ compute+db │
│ +queue+cache │ │ +queue+cache │ │ +queue+cache │
└─────────────┘ └─────────────┘ └─────────────┘
nothing shared across cells except the router
How it works
- A lightweight routing layer maps each request's routing key (tenant ID, user ID range, or geography) to one cell, before the request reaches any application logic.
- Each cell is a complete vertical slice — its own compute, database, queue, and cache — not merely a database shard; nothing is shared across cells except the router itself.
- Blast-radius containment: an outage, bad deploy, bug, or overload inside one cell has no path to another cell's resources, because there is no shared state between them to carry the damage across.
- Cell routing must stay simple, highly available, and rarely change, because every cell depends on it — it is deliberately kept close to a stateless lookup rather than given complex logic that could itself become a shared failure point.
- Cell migration — moving a tenant from one cell to another to rebalance load or isolate a noisy tenant — requires copying that tenant's data into the new cell and then atomically flipping its routing entry; a non-atomic flip risks a tenant split across two cells mid-move.
- This is the bulkhead principle (→ 153) drawn around the whole stack instead of one resource pool, and the containment it buys is the system-wide version of the failure isolation taught generally in → 193.
Practical example
(illustrative). A platform with 100,000 tenants split across 10 cells of 10,000 tenants each: a bad deploy that would have taken down the whole platform in a single shared stack now affects at most one-tenth of tenants, contained to the one cell it landed in — the same arithmetic a bulkhead's resource-pool split uses, scaled up to whole stacks.
When to use it
- Use when: platform scale is large enough that blast-radius containment matters more than the resource efficiency lost to running several complete stacks instead of one.
- Avoid when: scale is small enough that one deployment's failure domain is already acceptable, or the operational cost of running N complete stacks isn't justified.
- Failure scenarios: the shared routing layer becoming a single point of failure if it isn't kept simple and highly available; a non-atomic cell migration leaving a tenant split across two cells; uneven cell sizing creating one cell that is itself a noisy-neighbor bottleneck for its own tenants.
- Simpler alternative: a single shared stack with per-tenant quotas (→ 211), when the overload risk doesn't justify duplicating the entire stack per cell.
Practice
(Process kind — design exercise; 20–30 min, no lab services). Design a cell-routing scheme for a hypothetical 50-tenant platform split into 5 cells: define the routing key, the steps to migrate one tenant between cells without a window where it belongs to both, and name exactly what is still shared across all cells. Done when you can name the one remaining single point of failure in your design and say whether it's acceptable.
Key takeaway
Cells are bulkheads drawn around the entire stack: blast radius shrinks to one cell's tenants, at the cost of running several complete stacks instead of one. Done when you can: design a cell-routing and migration scheme and name what it still shares across cells. Used next in Project 20.
References
Shopify, "A Pods Architecture To Allow Shopify To Scale" — see references.md.
Source directory