Skip to content

Multi-tenant isolation

How a system serving many customers keeps one tenant's data, load and failures from reaching another: which resources each tenant gets to itself, and how the shared ones enforce the boundary.

On this page

What it is

A tenant is the unit you keep apart from the others: in a business-to-business product it is usually a customer organization with many users, but a tenant can also be an individual, and one customer can hold several tenants. A multitenant deployment serves more than one of them from shared infrastructure. Isolation is what keeps those tenants apart on three fronts: data (a response for one tenant must not carry another tenant's rows), performance (one tenant's heavy usage should not slow the rest, the noisy-neighbor problem) and reliability (a failure or a bad upgrade should not take out every customer at once). Sharing infrastructure lowers cost, and each of these three risks is the price of that sharing.

The AWS SaaS Lens names three shapes. In the silo model a tenant gets dedicated resources, such as its own database or a whole separate stack, while still sharing identity, onboarding and operations with the other tenants. In the pool model tenants share compute, storage and messaging, which is the classic meaning of multi-tenancy and where the economies of scale come from. The bridge model mixes the two: one service might be siloed because its data is regulated or its load is spiky, while another is pooled because it is cheap and uniform.

Treat isolation as a spectrum you choose per component rather than a single switch. One middle point shares the application tier and the network but gives each tenant a separate database. The AWS guidance stresses that getting past a login screen or an API is authentication, not isolation; the boundary still has to be applied on every access to a shared resource, ideally by a mechanism outside the view of the developer writing each query, because an accidental crossing of the tenant boundary is a realistic mistake.

sql
-- Example (PostgreSQL 17): make the database enforce the tenant boundary
ALTER TABLE invoices ENABLE ROW LEVEL SECURITY;

-- app_current_tenant() returns the tenant this connection is acting for;
-- how your stack sets that value is up to you
CREATE POLICY tenant_rows ON invoices
  TO app_role
  USING (tenant_id = app_current_tenant());

-- With no WITH CHECK clause, the USING expression is applied to writes too.
-- app_role must be an ordinary role: owners, superusers and BYPASSRLS roles
-- are not filtered by this policy.

Row-level security is one database-side mechanism for a pooled table, and the one we'd reach for first in PostgreSQL. In PostgreSQL 17 a table has no policies by default, so anyone with table privileges sees every row. Once row security is enabled on a table, each read or write must be allowed by a policy, and a table with row security on but no policy denies all rows. A policy's USING clause filters the rows a command can see, and its WITH CHECK clause (which defaults to the same expression) rejects inserted or updated rows that would land outside the boundary. Two gaps matter for a design: superusers and roles with the BYPASSRLS attribute skip the policies, and so does the table's owner unless the table is altered to FORCE ROW LEVEL SECURITY. An application that connects as the owner has switched the mechanism off.

When to use it

Pool by default when you have many tenants of similar size and no regulatory reason to separate them: one set of infrastructure costs less to run than one per customer, even after you buy larger tiers for the combined load, and moving a user between tenants can be a change of identifiers rather than a data migration.

Silo a component when the data's domain demands it (some compliance regimes require a database per tenant), when one tenant's load would otherwise hurt the others, or when a customer will pay for dedicated resources. A dedicated deployment also lets you roll an upgrade out tenant by tenant, which limits the damage of a bad release. One way to offer both is a tier: trial and standard customers on pooled infrastructure, premium customers on their own.

Whatever is shared needs resource governance. The noisy-neighbor guidance from Azure treats this as a quota problem: measure usage per tenant as well as in total, alert on spikes, apply throttling or rate limits per tenant so a single customer is kept from consuming the whole capacity, let tenants buy reserved capacity, and when the pattern is persistent, add shards or stamps and rebalance tenants across them so their peaks don't coincide. Telling customers what the limits are matters too, so their clients retry sensibly instead of treating a throttled call as an outage.

When not to

Don't silo everything by reflex. If one tenant's stack costs a fixed amount, a hundred tenants cost roughly a hundred times that, and every configuration change or patch has to reach a hundred deployments. Automation helps, but a shared deployment that updates once is simpler to operate when tenants are many and small.

Don't build tenancy machinery you don't need. A system with a handful of large enterprise customers who each want their own environment is often better served by separate deployments from infrastructure as code than by a pooled design with row-level policies, per-tenant limiters and shard routing. And if a product has one tenant today, your own company, a full isolation design can wait: keep a tenant identifier in the data model if a second customer is plausible, and add the enforcement when that customer arrives.

Don't rely on row-level security as the whole answer when your application connects with a role that bypasses it, or when operations that work on the whole table (such as TRUNCATE) are in play, since those are not subject to policies. Close those gaps first: connect as an ordinary role rather than the owner or a superuser, or force row security on the owner, and keep whole-table privileges away from the application role. Where that is not possible, put the boundary somewhere else, such as the application's data access layer, a schema per tenant, or a database per tenant.

Compared

ModelWhat tenants shareCost and operationsMain riskWhen it is the right call

Pool (shared everything)

App tier, database, network

Lowest cost; one deployment to update; shared limits reached sooner

A missed filter leaks data; a heavy tenant slows the rest

Many similar tenants, no compliance demand for separation

Database per tenant (shared app tier)

App tier and network only

Moderate; schema changes run once per database

The app tier is still shared, so quotas are still needed

Database load dominates and must not cross tenants

Silo (dedicated stack)

Identity, onboarding, operations tooling

Highest cost; upgrades roll out tenant by tenant

Fleet-wide reporting and maintenance get hard

Regulated data, or a customer paying for dedicated capacity

Bridge or tiered

Varies per component or per tier

Two code paths to maintain and test

Complexity: knowing which tenant runs where

Most tenants are small, a few are large or regulated

In a picture

tenant IDstandardpremiumTenant requestAPI gatewayShared servicePer-tenantlimiterTier?Pooled DB withRLSDedicated DB
A bridge design: the gateway and service are pooled, a per-tenant limiter guards the shared capacity, and the tier decides whether a tenant's data lives in a pooled table behind row-level security or in its own database.

How to say it in an interview

The common mistake

Quiz

A design shares one application tier across all customers but gives each customer its own database. Which description fits?
In PostgreSQL 17, row security is enabled on a table but no policy has been created yet. What does an ordinary application role see when it selects from the table?
In a pooled system, one tenant's nightly export is making other tenants' requests time out. What should the design add first?
Which situation most favors giving a tenant a dedicated stack rather than pooled infrastructure?

Questions that use this

Related

Sources

  1. AWS Well-Architected SaaS Lens: Silo, Pool, and Bridge Models
  2. AWS Well-Architected SaaS Lens: The isolation mindset
  3. Azure Architecture Center: Tenancy models for a multitenant solution
  4. Azure Architecture Center: Noisy Neighbor antipattern
  5. PostgreSQL 17 documentation: Row Security Policies
Sign in to report a mistake