System design concepts · Running It for Real

Multi-Tenant SaaS Architecture: Isolation Models Explained

When you sell software to thousands of businesses, they all share your system, but none of them should ever see, slow down or pay for another. That's the whole art of multi-tenancy.

What you'll be able to explain
  • Define tenants and explain silo, pool and bridge models
  • Isolate tenant data with defence in depth
  • Stop noisy neighbours with per-tenant quotas and fair scheduling
  • Route, onboard, migrate and delete tenants as a lifecycle
  • Measure cost per tenant and design tiered plans

What a tenant is

A tenant is a customer organisation that uses your product with its own users, data and settings: a school using an LMS, a restaurant chain using a POS, a company using a ticketing tool. Multi-tenancy means many tenants share one deployment of your software rather than each getting a separate copy.

Why share? Cost and speed. One deployment is cheaper to run, every tenant gets new features at once, and you operate one system instead of five thousand.

The price: isolation becomes your responsibility. A bug, a missing filter or one tenant's traffic spike can now affect everyone.

Analogy

An apartment building is multi-tenant. Residents share the foundation, lifts and water mains (cheap), but each flat has its own lock (data isolation), its own electricity meter (cost attribution), and a building rule that one flat's party can't cut the water pressure for everyone else (noisy-neighbour control). A villa per family is the single-tenant alternative: perfect isolation, very expensive.

Tenancy models

Pool (fully shared)All tenants share services and databases; rows tagged with tenant_idBridge (mixed)Shared services; per-tenant schemas or databases for some dataSilo (dedicated)Each tenant gets its own stack or database, run by the same automation
From fully shared to fully separate. Most SaaS products mix them by tier.
Pool Bridge Silo
Cost per tenant Lowest Medium Highest
Isolation Logical (code must enforce it) Partial Physical
Noisy-neighbour risk Highest Medium Lowest
Onboarding Instant (insert a row) Fast (create a schema) Slower (provision resources)
Ops at 10,000 tenants One system to run Many schemas to migrate 10,000 stacks to upgrade
Fits Freemium, SMBs Mid-market Enterprise, regulated, data residency

A common winning pattern: pool by default, silo for the top tier. Small customers share; a large bank pays for a dedicated database in its required region, deployed by the same code and pipeline.

Isolating data

In the pool model, every row carries tenant_id, and every query must filter by it. One forgotten WHERE tenant_id = ? leaks data across customers, the worst bug a SaaS company can ship. Use defence in depth:

  1. Tenant context from the token: the tenant ID comes from the authenticated token, never from a URL parameter the user can edit.
  2. A data-access layer that requires it: repository methods that take a tenant context and add the filter automatically; raw queries flagged in review.
  3. Database row-level security (Postgres RLS): the database itself refuses rows from other tenants, even if the app forgets.
  4. Per-tenant encryption keys for sensitive data: a leaked row is unreadable without that tenant's key, and deleting the key "crypto-shreds" the tenant's data.
  5. Tests that try to cross tenants: automated tests that log in as tenant A and request tenant B's resources.
CLIENTUser of tenant 42NETWORKGatewaytoken → tenant_id=42SERVICEServicetenant contextSERVICEData layeradds tenant filterDATABASEPostgresRLS policyJWTX-Tenant: 42 (signed)SET app.tenant = 42
Tenant context flows from the token through every layer; the database enforces it again with row-level security.

Caches, search indexes, queues and object storage need the same care: prefix cache keys with the tenant (t42:product:9), filter search by tenant, and keep tenant files under per-tenant prefixes with matching access policies.

Noisy neighbours

One tenant runs a giant export, imports 5 million records, or gets featured on TV. In a shared system, everyone else slows down. Defences:

Layer Control
API Per-tenant rate limits and quotas by plan (Rate Limiting Algorithms and Overload Protection)
Workers Per-tenant concurrency caps; fair queuing so one tenant's 1M jobs don't delay another's 10
Database Per-tenant statement timeouts and connection limits; move heavy tenants to their own shard
Storage Quotas on records, files and bandwidth
Placement Spread big tenants across shards; isolate whales in dedicated cells
PROBLEMTenant A1,000,000 jobsCLIENTTenant B12 jobsCLIENTTenant C40 jobsQUEUE / LOGLane AQUEUE / LOGLane BQUEUE / LOGLane CSERVICEFair schedulerround-robin / weightedWORKERWorkers
Fair queuing: each tenant has its own lane, and workers take turns across lanes so one flood can't block everyone.