Multi-tenancy
Also called multi-tenant architecture.
One running copy of a software product serving many customers, called tenants, with each tenant's data kept apart.
Last updated
What it is.
In a multi-tenant product every customer company uses the same code and servers, but sees only its own users and data. Isolation can be done in rows (a tenant ID on every record), in schemas (one schema per tenant in a shared database) or in separate databases per tenant.
Single-tenant means each customer gets their own copy of the stack. It gives stronger isolation and custom upgrades, but costs more to run and keep in sync.
Why it matters
Multi-tenancy is what makes SaaS cheap to run and easy to upgrade: one deploy updates every customer. The risk is a leak between tenants, which is one of the worst bugs a B2B product can have. The isolation model also decides how easy it is to meet data location or enterprise isolation requests later.
In a product build
We pick the isolation model before the first table is created, since moving later is a migration of every row. We enforce the tenant check in one shared layer or in the database itself, and add tests that try to read across tenants.
Common mistakes.
- 01
Relying on every developer to remember a tenant filter in every query.
- 02
Forgetting tenant scope in caches, search indexes, file storage and background jobs.
- 03
Letting one large tenant's heavy jobs slow down everyone else, with no per-tenant limits.
Work it out with a tool.
Related terms.
- RBAC (role-based access control)An access model where permissions are attached to roles, and people get access by being given a role.
- ShardingSplitting one large dataset across several databases, called shards, by a key such as customer ID, so each shard holds only part of the data.
- Rate limitingCapping how many requests a user, API key or address can make in a given time, to protect a system and share capacity fairly.
- SSO (single sign-on)One login, managed by an identity provider, that gives a person access to many separate apps.
- Object storageA way of storing files as objects in buckets, each with an ID and metadata, reached over HTTP and built to scale to huge amounts of data cheaply.
Guides and pages
Browse the full glossary or read answers to common questions.