Cell-Based Architecture
By Ankur NayakReviewed
A cell-based architecture splits a system into many independent copies, called cells or pods, each serving a subset of customers with its own data and dependencies. A failure, bad deploy or overload in one cell affects only that cell's customers, and capacity grows by adding cells.
How it works
Instead of one big shared system, build many small, identical, isolated ones. Each customer (or shop, or workspace) is assigned to a cell, and a thin routing layer sends each request to the right cell. Within a cell, everything a request needs is local.
Shopify's pods are a well-documented example. A pod is a set of shops on a fully isolated set of datastores; app servers, job workers and load balancers are shared, but each request talks to one pod. Sorting Hat, in the load balancers, matches each request to its pod and passes it on in a header. Each pod has an active and a recovery data centre, and Pod Mover can move a pod between them in about a minute.
Dropbox's Magic Pocket applies the same idea to storage: self-contained cells of about 50 PB, each with its own coordinating Master, located through a global block index.
The routing layer and the mapping of customers to cells are the parts that must be shared. They should be simple, highly available and easy to change, so customers can be moved between cells for balance or recovery.
Key points
- Many isolated copies, each serving a subset of customers
- A failure's blast radius is one cell
- A thin router maps each request to its cell
- Scale by adding cells; rebalance by moving customers
- Cells can be moved or evacuated independently
When to use it, and pitfalls
Use it for
- Multi-tenant SaaS where tenants are independent (shops, workspaces, accounts)
- Systems where one outage must not affect every customer
- Large storage systems that grow in fixed-size units
Watch out for
- Operations that span customers become cross-cell queries
- A huge tenant can outgrow a cell
- The router and mapping become critical shared dependencies
- Deploying to every cell at once defeats the isolation
Trade-offs
Shared compute, isolated data
Share stateless tiers across cells; isolate the stateful ones.
Pros: Flexible compute capacity; Data failures stay contained
Cons: Stateless tiers can still be a shared failure point
Used in
Related building blocks
Frequently asked questions
What is the difference between a cell and a shard?
A shard usually splits one database. A cell isolates a full slice of the system, such as all the datastores a set of customers need, so a failure in one cell can't affect others. Shopify moved from sharding to pods for exactly that reason.
How are requests routed to cells?
A small routing layer maps each customer to its cell. At Shopify, Sorting Hat in the load balancers matches each request to a pod and adds a header that the app servers use to pick the pod's datastores.
Sources
- A Pods Architecture To Allow Shopify To Scale · Shopify Engineering
- Inside the Magic Pocket · Dropbox Tech