Key takeaways
- Multi-tenancy is a spectrum, from fully shared to fully isolated.
- A shared database with a tenant ID suits most early-stage SaaS products.
- Enforce tenant isolation in the database, not only in application code.
- Design for moving large or regulated tenants to dedicated infrastructure later.
Most SaaS products serve many customers from one codebase. How you separate those customers' data and workloads is one of the earliest architectural decisions you make, and one of the hardest to change later.
This guide compares the common multi-tenancy models and the details that make each one safe to run. If you're still validating the idea, see how much it costs to build an MVP first.
The three main models
| Model | How it works | Isolation | Cost per tenant | Operational effort |
|---|---|---|---|---|
| Shared database, shared schema | All tenants in the same tables, separated by a tenant_id | Logical | Lowest | Lowest |
| Schema per tenant | One database, a separate schema for each tenant | Stronger | Medium | Medium (migrations per schema) |
| Database per tenant | Each tenant gets its own database | Strongest | Highest | Highest |
Some products go further and give large customers their own application stack. That's usually a premium tier rather than the default.
Shared database, shared schema
Every table that holds tenant data has a tenant_id. Every query filters by it.
Good for: early-stage products, many small tenants, fast iteration.
Risks: a single missing filter can leak data across tenants, and a heavy tenant can slow everyone down.
Enforce isolation in the database
Don't rely on developers remembering WHERE tenant_id = ?. In PostgreSQL, row-level security can enforce it:
ALTER TABLE invoices ENABLE ROW LEVEL SECURITY;
CREATE POLICY tenant_isolation ON invoices
USING (tenant_id = nullif(current_setting('app.tenant_id', true), '')::uuid);The application sets app.tenant_id at the start of each request, and the database refuses to return other tenants' rows even if a query forgets the filter.
The nullif(..., '') matters. On a pooled connection that has had the setting before, PostgreSQL can return an empty string instead of NULL, and casting '' to uuid raises an error. With nullif, a request with no tenant set simply matches no rows. Wrap the expression in a small SQL function so every policy uses the same safe version.
Schema per tenant
Each tenant gets its own set of tables inside one database.
Good for: moderate numbers of tenants that need some customisation or easier per-tenant export and restore.
Watch out for: migrations must run across every schema, and connection pooling gets more complex as tenant numbers grow.
Database per tenant
Good for: enterprise or regulated customers who require separation, data residency in a specific region, or very different usage patterns.
Watch out for: provisioning, migrations, backups and monitoring multiply with every tenant. You need automation from day one.
A hybrid approach
Many products combine models:
- Standard tiers on a shared database.
- Enterprise customers on dedicated databases, sometimes in their preferred region.
Design a tenant directory that records where each tenant's data lives, so the application can route requests and you can move a tenant later.
Beyond the database
Identity and access
- Resolve the tenant from the subdomain, custom domain or authenticated session, never from a value the client can edit freely.
- Support roles within a tenant (owner, admin, member) and, for business customers, single sign-on.
- Strengthen login with modern methods; see passkeys vs OTP.
Noisy neighbours
- Rate-limit APIs per tenant.
- Push heavy work into queues with per-tenant concurrency limits.
- Monitor resource use per tenant so you can spot and move outliers.
Configuration and feature flags
Store per-tenant settings, plan limits and feature flags centrally. Avoid forking code for individual customers.
Data export and deletion
Customers will ask for their data and expect it deleted when they leave. Build export and tenant deletion early; privacy laws like India's DPDP Act make it an obligation, as covered in our DPDP checklist.
Observability
Tag logs, metrics and traces with the tenant ID. When a customer reports a problem, you should be able to see their requests in seconds.
Testing
Add automated tests that try to read and write across tenants and must fail. Treat any cross-tenant access as a critical bug.
Choosing a model
| If you… | Start with |
|---|---|
| Expect many small customers and need to move fast | Shared schema with row-level security |
| Need per-customer customisation and easy restores | Schema per tenant |
| Sell to enterprises with strict isolation or residency requirements | Database per tenant for those customers |
Where to start
Add tenant_id and tenant-aware request handling from the first commit, enforce isolation in the database, and keep a tenant directory so you can move customers later.
Our custom software team designs and builds SaaS platforms, from first architecture decisions to production. Talk to us about your SaaS product.
Frequently asked questions
What is multi-tenant architecture?
It's a design where one running application serves many customers (tenants), with each tenant's data and configuration kept separate. It's how most SaaS products keep costs down and ship updates to everyone at once.
Which multi-tenancy model is best?
There's no single best model. A shared database with a tenant ID column is simplest and cheapest. Separate schemas or databases give stronger isolation and per-customer flexibility at higher operational cost. Many products mix models by customer tier.
How do you prevent one tenant seeing another tenant's data?
Scope every query by tenant, enforce it centrally rather than in each query, use database features such as PostgreSQL row-level security, and test for cross-tenant access in automated tests.
What is the noisy neighbour problem?
When one tenant's heavy usage slows the system down for everyone else. Rate limits, per-tenant quotas, background job queues and the option to move large tenants to dedicated resources address it.
Can we start single-tenant and switch later?
You can, but it's costly once you have many customers. Adding a tenant ID and tenant-aware design early is cheap and keeps your options open.

Written by
Co-Founder & CTO
Excels in developing innovative hardware and software solutions. With expertise in IoT, embedded systems, and data analytics, committed to tackling real-world challenges through advanced technology.




