Serve many customers from one system while keeping their data apart, and their noisy neighbours in check.
Multi-tenancy means one system serves many customers (called tenants), while keeping each customer's data and experience separate.
A tenant is one customer organisation, such as a company that signed up for your app. Running a separate copy of your software for each one is safe, but it is costly: ten thousand customers would mean ten thousand deployments to update. Multi-tenancy shares the running system between tenants to cut cost and effort, and then adds walls so tenants cannot see or harm each other.
The main design question is where the walls go. There is a ladder from cheap and thin walls to costly and thick walls.
| Model | How data is kept apart | Good for | Watch out for |
|---|---|---|---|
| Shared tables | One set of tables, a tenant_id column on every row | Many small tenants, lowest cost | Every query must filter on tenant_id. One missed filter leaks data. Noisy neighbours. |
| Schema per tenant | One database server, a separate schema (set of tables) for each tenant | Medium number of tenants, some customisation | Thousands of schemas are hard to migrate and manage. |
| Database per tenant | Each tenant has its own database | Strong isolation, per-tenant backup and restore | Many databases to upgrade, monitor and pay for. |
| Stack per tenant (silo) | A separate copy of the app and data for each tenant | Large or regulated customers | Highest cost and most operational work. |
| Hybrid (bridge) | Small tenants pooled, large or special ones siloed | Most real SaaS products over time | Two code paths and two sets of tooling. |
| Part of the system | What to do |
|---|---|
| Cache keys | Include the tenant id in every key, or one tenant may read another's cached data. |
| Rate limits and quotas | Limit per tenant, so one customer cannot use everything. |
| Sharding | Use the tenant id (or a hash of it) as part of the shard key, and plan for one huge tenant. |
| Files and queues | Prefix object paths and queue names with the tenant. |
| Logs and metrics | Tag them with the tenant, but never log another tenant's private data. |
| Permissions | Roles are checked inside the tenant. See RBAC. |
Shared tables (tenant_id column). All tenants share the same tables and the same servers. Cheapest. Every query must filter on tenant_id.
A teaching sketch. The capacity, the cost units, the 50 ms base latency and the "how much noise others feel" factors are made-up, illustrative numbers. Real results depend on your database, your limits and your hardware. Row-level security and per-tenant rate limits can protect even the pooled model.
| Term | Meaning in easy words |
|---|---|
| Tenant | One customer organisation using the shared system |
| Multi-tenancy | Serving many tenants from one running system, with their data kept apart |
| Tenant id | The identifier that says which tenant a request or row belongs to |
| Pooled model | Tenants share the same tables, separated by a tenant id |
| Silo model | Each tenant gets its own full copy of the stack |
| Noisy neighbour | A heavy tenant that slows down others who share the same resources |
| Row-level security | A database feature that automatically limits which rows a user can see |
| Quota | A cap on what a tenant may use (requests, storage, seats) |
| Data residency | A rule that a tenant's data must stay in a certain country or region |
| Blast radius | How many tenants are hurt when something goes wrong |
| Offboarding | Removing a tenant and deleting their data safely |
| Choice | We gain | We lose |
|---|---|---|
| Shared tables | Lowest cost, simplest operations | Thinnest isolation, noisy neighbours, leak risk |
| Schema or database per tenant | Stronger walls, per-tenant restore | More objects to manage and migrate |
| Silo per tenant | Best isolation and customisation | Highest cost, many deployments |
| Per-tenant limits | Fair sharing, protection from abuse | Extra work, and some tenants hit limits |
| Tenant id from the token | Hard for a client to fake | Every service must read and respect it |
| Hybrid model | Right level for each customer | Two ways to run and to test |