What Is Multi-Tenancy?
Multi-tenancy is the architectural principle where a single software instance serves multiple customers (tenants). Each tenant sees only their own data and experiences the application as if it were exclusive to them.
The opposite — single-tenancy — means a separate instance per customer. Simpler in isolation but expensive to operate and maintain.
Three Isolation Models
1. Shared Everything
All tenants share the database, schema, and tables. Isolation is enforced through a tenant_id column in every table.
Advantages:
- Lowest infrastructure costs
- Simple deployment and updates
- Efficient resource utilization
Risks:
- A missing
WHERE tenant_id = ?filter → data leak - Noisy neighbor: one tenant with high load affects all others
- Complex per-tenant backup/restore
Suited for: SaaS products with many small tenants and moderate compliance requirements.
2. Shared Compute, Separate Database
All tenants use the same application, but each has their own database (or schema in PostgreSQL).
Advantages:
- Stronger data isolation
- Easier tenant-specific backups
- Performance isolation at the database level
Risks:
- More database connections (connection pool per tenant)
- Schema migrations must run across all databases
- Higher infrastructure costs
Suited for: B2B SaaS with medium to large tenants and regulatory requirements.
3. Full Isolation (Silo)
Each tenant receives completely separate infrastructure — own compute, own database, own network.
Advantages:
- Maximum isolation and security
- No noisy-neighbor problems
- Compliance-friendly (data in own region)
Risks:
- Highest costs
- Complex deployment (N environments instead of one)
- Harder aggregation across tenants
Suited for: Enterprise customers with strict compliance or performance requirements.
Threading Tenant Context
The most common mistake: implementing tenant isolation only at the API level. In practice, tenant context must flow through the entire stack:
- API layer: Extract tenant from JWT or header
- Service layer: Pass tenant context in every service call
- Database layer: Row-Level Security (PostgreSQL) or automatic
tenant_idfilters - Cache layer: Tenant-specific cache keys
- Queue layer: Tenant ID in message headers
- Logging/monitoring: Tenant ID in every log entry
Scaling Strategies
Horizontal Sharding by Tenant
Large tenants get dedicated shards, small tenants are pooled on shared shards. The routing layer decides based on tenant ID.
Tier-Based Isolation
| Tier | Isolation | SLA | Price |
|---|---|---|---|
| Starter | Shared Everything | 99.5% | $ |
| Professional | Shared Compute, Separate DB | 99.9% | $$ |
| Enterprise | Full Silo | 99.95% | $$$ |
Auto-Scaling per Tenant
Demanding but feasible: compute resources scale per tenant based on their load. Kubernetes namespaces or separate deployments enable this.
Onboarding and Offboarding
Often underestimated:
Onboarding — What happens when a new tenant is created?
- Create database/schema
- Load initial data (configuration, defaults)
- Set up DNS/subdomain (if custom domains)
- Activate billing integration
Offboarding — What happens when a tenant cancels?
- Export data (GDPR: right to data portability)
- Delete data after retention period (GDPR: right to erasure)
- Release resources
- Archive audit trail
Conclusion
Multi-tenant architecture is a spectrum, not an either/or. Most successful SaaS products start with Shared Everything and offer higher isolation tiers as a premium feature. The key is to thread tenant context cleanly through the entire stack from the beginning — retrofitting is the most expensive option.