Lesson 16 of 16 · Capstone
Capstone: cells for 10,000 tenants
Design a cell-based platform for 10,000 tenants currently on one shared platform: cell size and count, the global layer, placement rules, ring plan with canary analysis, the migration from today's platform, regulated customers, and the metrics that prove it.
The brief
Product: multi-tenant SaaS, 10,000 tenants (mostly small; ~50 large enterprises),
growing 40% a year. One shared platform in two regions today.
Pain: two platform-wide outages last year (a bad config push; a database failover),
one large tenant regularly slowing others, enterprise and public-sector
customers asking for isolation and residency.
Limits: the shared database cluster is near its connection and IOPS limits.
Goal: no single incident or change affecting more than ~2% of tenants; isolation
options for large and regulated customers; cost per tenant visible.
The whole school currently eats in one huge dining hall. When the kitchen floods, nobody eats. Design smaller dining rooms, decide who eats where, how a child moves room, how a new menu is tried, and how the special-diet children are served.
Your task
Write a design (two to three pages) using the outline in the cheat sheet. Be explicit about numbers and assumptions.
Reference design (one good version)
Cell model. A cell = one Kubernetes cluster per region plus its own PostgreSQL cluster, cache, queue and object storage prefix, in its own cloud account. Global layer: edge (anycast CDN + WAF), regional routers with a cached tenant → cell map, identity, tenant directory. No cross-cell calls on the request path.
Sizing. Load tests show the database hits its connection limit first at about 350 standard tenants per cell; run at 70% → ~250 tenants. Blast-radius cap of 2% of 10,000 = 200 tenants. Cell size = 200 small tenants. About 50 shared cells over two regions today (plus growth: ~70 within a year), cell classes small and large. Enterprises above 10% of a cell's capacity get dedicated cells (~15 initially).
Routing and moves. Tenant from subdomain or token claim; map published every 10 seconds, cached at routers and the edge; cells reject tenants they don't own. Move workflow (provision → copy → CDC → lag ≈ 0 → per-tenant write pause → flip → verify → 7-day rollback point), at most 20 concurrent moves.
Releases. Rings: 0 internal (2 cells), 1 canary (3 opted-in cells), 2 shared cells in waves of 25%, 3 regulated and large dedicated cells after a 24-hour soak. Every service uses Argo Rollouts canaries with Prometheus analysis comparing canary with stable (errors, p99, login success). Configuration and add-ons follow the same rings.
Special tenants. Regulated cells in dedicated accounts and regions, FIPS images, stricter policy bundle by label, last ring, Git-only changes, drift detection. Residency enforced by placement and failover rules.
Migration. Phase 1: today's platform becomes "cell 0"; build cells 1-2 from code; move internal tenants; prove the move workflow and the router. Phase 2: move tenants in batches of 50-100 per night, starting with small tenants; open new cells as they fill. Phase 3: move large tenants to dedicated cells with scheduled windows; shrink cell 0 to a normal cell or retire it.
Metrics. Max tenants affected per incident (target ≤ 2%); platform-wide incidents (target 0); releases stopped by canary analysis or ring gates before ring 2; time to open a cell; move success rate and pause duration; cost per tenant and idle share.
Risks. Router and directory as global dependencies (simple design, caching, staged map changes); more infrastructure cost (offset by right-sizing and visible cost per tenant); cross-tenant analytics need an asynchronous pipeline; operational load of many cells (full automation is a precondition, not a follow-up).
Presenting it
- Start with the two outages and the 2% goal.
- Show the sizing calculation explicitly; reviewers will check it.
- Present the migration as phases with the first one small and reversible.
Recap
- Size cells from the first measured limit and a blast-radius cap; add cells to grow.
- A thin global layer, cached routing and an automated move workflow make cells practical.
- Rings plus canary analysis keep releases safe; special tenants use the same code in dedicated cells.
- Migrate incrementally: today's platform becomes the first cell.
This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.