The Short Answer
What is multi-tenant architecture?
Multi-tenant architecture is a design in which one running copy of a software product serves many customers, called tenants, while keeping each tenant’s data separate. The alternative, single-tenant, gives each customer their own copy. Multi-tenancy is cheaper to run and easier to update. Single-tenancy gives stronger isolation at a higher cost.
Most SaaS products are multi-tenant. The real decision is how far down the sharing goes: the application only, the database server, or the tables themselves. The AWS SaaS Lens calls the two ends of this range the pool model, where tenants share resources, and the silo model, where each has its own.
Read the transcript
In most SaaS products, every customer shares the same database tables. Each row is tagged with the customer it belongs to. Forget that filter in one query, and a customer sees someone else’s data. That’s multi-tenancy. One running product serves many customers, and keeps them apart. So how far down should the sharing go? There are three models. Shared tables are cheapest, and scale to thousands of customers. A schema per tenant gives stronger separation. A database per tenant is the strongest, and costs the most. Start with shared tables, and design the risk out. Put the tenant on every table. Work it out once, from the user’s session. Apply the filter in one place. Have the database enforce it too. And test for leaks. Later, give the few large customers who need it their own database, running the same code. Isolation shouldn’t depend on every query being right. Enforce it once, at the centre. The full guide is free at loomstrat.com.
The Three Data Models
| Shared tables | Schema per tenant | Database per tenant | |
|---|---|---|---|
| How it works | All tenants in the same tables; every row has a tenant ID | One database; each tenant has its own set of tables | Each tenant has a separate database |
| Isolation | Enforced in code and database policy | Stronger; separated by schema | Strongest; separated physically |
| Cost per tenant | Lowest | Low to medium | Highest |
| Schema changes | Run once | Run for every schema | Run for every database |
| Practical tenant limit | Very high | Hundreds to low thousands | Tens to hundreds without heavy automation |
| Noisy neighbour risk | High unless controlled | Medium | Low |
| Per-tenant backup and restore | Hard | Possible | Easy |
| Data residency per tenant | Hard | Hard | Easy |
| Reporting across tenants | Easy | Harder | Hardest |
Microsoft’s guidance on tenancy models describes the same range and notes that a product can mix them, which is how most mature SaaS companies end up.
A Sensible Default
For a new B2B SaaS product, start with shared tables and a tenant ID on every row. It is the cheapest to run, the simplest to change, and it supports thousands of small customers. Add a database-per-tenant option later for the few large customers who require it and will pay for it.
The weakness of shared tables is that isolation depends on every query being correct. One missing filter shows a customer someone else’s data. That risk has to be designed out, not left to care.
Making Shared Tables Safe
- 1
Put the tenant ID on every table
Including child tables. Do not rely on joining back to a parent to find the tenant.
- 2
Resolve the tenant once, at the edge
Work out the tenant from the signed-in user’s session at the start of each request. Never accept a tenant ID from the request body or URL without checking it against the session.
- 3
Enforce it in the data layer
Apply the tenant filter automatically in one place so that an individual query cannot forget it.
- 4
Add database enforcement
PostgreSQL’s row-level security lets the database itself refuse rows that do not match the current tenant, as a second line of defence.
- 5
Scope everything else
Caches, search indexes, file storage paths, background jobs and logs all need the tenant in their key.
- 6
Test for leaks
Automated tests that sign in as tenant A and try to read tenant B’s records by ID, on every endpoint.
- 7
Guard admin tools
Support staff impersonation must be logged, time-limited and visible to the customer.
Row-level security is worth the effort. It means that a bug in application code results in an empty answer, not a data breach.
Noisy Neighbours
In a shared system, one tenant running a huge export can slow everyone. Controls: rate limits per tenant, query timeouts, separate queues for heavy background work, limits on plan size, and monitoring that reports usage by tenant so that you can see who is responsible.
What Enterprise Customers Ask For
| Requirement | What it needs |
|---|---|
| Data stored in a specific country | A regional deployment or a database per tenant in that region |
| Their own encryption key | Per-tenant keys; easiest with a database per tenant |
| Restore their data to a point in time | Per-tenant backup; hard with shared tables |
| Proof of isolation for a security review | Documented controls, leak tests, and ideally an independent penetration test |
| Single sign-on and role mapping | A per-tenant identity configuration; independent of the data model |
| Custom fields and workflows | A configuration layer per tenant; avoid separate code per customer |
Decide early that customers will differ by configuration, not by code. A separate code branch for one customer is the fastest way to turn a product into a set of bespoke projects.
The Hybrid Model
Many products end with tiers: standard customers pooled in shared tables, and enterprise customers each in a dedicated database, all running the same application code. A routing layer looks up which database a tenant uses. This works if the two paths are identical in code and automated in operations, so that a schema change reaches every database in one release.
Moving Between Models
Moving a tenant from shared tables to its own database is manageable if every table carries a tenant ID: copy that tenant’s rows, switch the routing, verify, delete the originals. Moving the other way, or adding tenant IDs to a product built for a single customer, is a much larger job. If you are turning a single-customer system into SaaS, treat it as a planned project; see legacy system modernisation.
Tenant design is one of the first things we settle in a SaaS platform build. The related guides on database choice and security and compliance basics cover the surrounding decisions.
Frequently Asked Questions
What is the difference between single-tenant and multi-tenant?
Single-tenant gives each customer a separate copy of the software and database. Multi-tenant serves all customers from one shared system while keeping their data apart.
Is multi-tenant SaaS secure?
Yes, when isolation is enforced centrally in the data layer and in the database, and tested. Most major SaaS products are multi-tenant.
Which multi-tenant model is best for a startup?
Shared tables with a tenant ID on every row. It costs least and changes fastest. Offer dedicated databases later to customers who need them.
What is row-level security?
A database feature that restricts which rows a query can see, based on a policy such as matching the current tenant. It protects against mistakes in application code.
What is a noisy neighbour in SaaS?
A tenant whose heavy usage slows the service for others who share the same resources. Rate limits and separate queues control it.
Can I switch tenancy model later?
Moving a tenant from shared tables to a dedicated database is practical if every table has a tenant ID. Retrofitting multi-tenancy into a single-customer system is much harder.