Skip to main content
Custom SaaS

What Is Multi-Tenancy in SaaS? A Founder's Technical Guide

Multi-tenancy in SaaS explained: what it means, the three architecture models, how to choose the right one, and what happens when you get it wrong.

Written by
Jahja Nur ZulbeariFounder & Technical Architect
Published
Updated
Reading time
9 min
Single building with multiple separate illuminated floors each a different tenant - what is multi-tenancy SaaS architecture

Multi-tenancy is the defining architectural concept of SaaS. If you are building a SaaS product, you will make multi-tenancy decisions in the first week of development, and those decisions are expensive to reverse. They are also among the most consequential SaaS platform architecture decisions you will make during the build phase.

The Short Answer

Multi-tenancy means one application instance serves many customers, with their data kept isolated. Instead of deploying a separate system for each customer, a multi-tenant SaaS shares infrastructure while enforcing strict data boundaries between customers. It is how Salesforce, Slack, and every other SaaS company at scale operates.

The alternative, single-tenancy, deploys a separate system per customer. This is occasionally required by enterprise contracts but is operationally expensive and rarely the right starting point.

Why Multi-Tenancy Matters for SaaS Architecture

Without multi-tenancy, each new customer requires a new deployment. At 10 customers, that is manageable. At 1,000 customers, you are running 1,000 separate databases, 1,000 application instances, and 1,000 independent upgrade processes. This does not scale.

Multi-tenancy makes SaaS economics work:

  • Shared infrastructure: one database server handles all customers, not one per customer
  • Centralised updates: deploy once, all customers are on the latest version
  • Predictable scaling: infrastructure scales with total load, not with customer count
  • Efficient support: one codebase to debug, not N separate deployments

The Three Multi-Tenancy Models

Model 1: Shared Database, Row-Level Security

Every table in the database has a tenant_id column. Every query filters by tenant_id. A database-level policy (Row Level Security in PostgreSQL) enforces that users can only read and write their own tenant’s rows.

-- Every table has this column
ALTER TABLE projects ADD COLUMN tenant_id UUID NOT NULL REFERENCES tenants(id);

-- Row Level Security policy
CREATE POLICY tenant_isolation ON projects
  USING (tenant_id = current_setting('app.current_tenant_id')::uuid);

Pros: Simple to implement, cheapest to operate, good for most SaaS products.

Cons: A single missing tenant_id filter on a query causes a data leak. Requires disciplined code review and testing. Performance can degrade with very large tables if indexing is not managed correctly.

Best for: Most SaaS products: B2B tools, productivity apps, analytics platforms.

Model 2: Shared Database, Separate Schemas

Each tenant gets their own database schema (a namespace within the same database). The application switches the active schema based on the authenticated tenant.

-- Tenant A's tables live in schema_tenant_a
-- Tenant B's tables live in schema_tenant_b
SET search_path TO schema_tenant_a;
SELECT * FROM projects; -- Only returns Tenant A's projects

Pros: Stronger logical isolation than row-level security. Schema-per-tenant enables per-tenant schema customisation (adding columns for specific tenants). Easier data export and migration per tenant.

Cons: More complex to manage at scale (schema migrations must run across all tenant schemas). Higher database overhead with thousands of tenants. Migration tooling needs to handle N schemas.

Best for: Products with per-tenant customisation requirements, or regulated markets where logical isolation must be demonstrable.

Model 3: Separate Database Per Tenant

Each tenant has a dedicated database. The application connects to the correct database based on the authenticated tenant.

Pros: Maximum data isolation: a bug in one tenant’s query cannot affect another tenant’s data. Enables true data residency (Tenant A’s database in Frankfurt, Tenant B’s in London). Simplifies per-tenant backup and restore. Required by some regulated enterprise contracts.

Cons: Most expensive: infrastructure costs scale linearly with customer count. Operational complexity for database migrations (must run against every tenant database). Connection pooling complexity. Onboarding a new tenant requires provisioning a new database.

Best for: Enterprise SaaS with strict data isolation contracts, healthcare products with patient data isolation requirements, government and defence contracts.

Choosing the Right Model

Factor Row-Level Security Separate Schemas Separate Databases
Operational cost Low Medium High
Data isolation strength Logical Logical Physical
Migration complexity Low Medium High
Per-tenant customisation Difficult Possible Easy
Enterprise contract compliance Usually sufficient Often sufficient Always sufficient
Recommended starting point ✓ Most products Specific cases Enterprise tier only

The decision rule: Start with row-level security. It is sufficient for the vast majority of SaaS products and significantly cheaper to operate. Move to separate schemas or separate databases only when you have a specific requirement (a regulated enterprise contract, a data residency obligation, or a per-tenant customisation need) that row-level security cannot satisfy. This choice also affects the cost of your custom SaaS development significantly.

What Goes Wrong with Multi-Tenancy

Data Leaks from Missing Filters

The most common failure: a developer writes a query and forgets the tenant_id filter.

-- Wrong — returns all tenants' data
SELECT * FROM projects WHERE status = 'active';

-- Correct
SELECT * FROM projects WHERE status = 'active' AND tenant_id = $1;

In a row-level security model, PostgreSQL RLS policies prevent this at the database level, but only if RLS is enabled on every table and the application correctly sets the tenant context. One misconfigured table or one context that is not set is enough for a cross-tenant data exposure.

Background Jobs Without Tenant Scoping

Background jobs (sending emails, processing data, generating reports) often run outside the normal request/response cycle. If they are not scoped to a tenant, they may process data from all tenants, or expose one tenant’s data in another tenant’s notification.

Every background job must explicitly scope to a single tenant and process only that tenant’s data.

File Storage Path Predictability

If files are stored at predictable paths (e.g., /uploads/invoice-1234.pdf), an authenticated user from one tenant can potentially access another tenant’s files by guessing the path. All file storage paths should include the tenant ID and use pre-signed URLs with expiry for access.

Missing Multi-Tenancy in Third-Party Integrations

When you integrate third-party services (email, Slack, webhooks), the integration must be scoped per tenant. A tenant’s webhook should only fire for that tenant’s events. A tenant’s email sending domain should only send to that tenant’s users. These scoping failures are subtle and hard to catch in testing.

Multi-Tenancy and Enterprise Sales

Enterprise procurement processes often include security questionnaires with specific questions about multi-tenancy, and the SaaS security best practices guide covers how to prepare those answers correctly:

  • “Is customer data logically or physically isolated from other customers?”
  • “Can you provide a data isolation architecture diagram?”
  • “Is row-level security enforced at the database level?”
  • “Can you offer a dedicated single-tenant deployment?”

The ability to answer these questions credibly (with architecture documentation and a penetration test report) is often the difference between closing and losing enterprise deals.

Build the documentation alongside the architecture, not as an afterthought.


Zulbera designs and builds custom SaaS platforms with multi-tenant architecture as a default: row-level security enforced at the database level and a single-tenant enterprise tier available when required. If you are making multi-tenancy decisions on your current build, request a private consultation.

Frequently asked
What is multi-tenancy in SaaS?

Multi-tenancy is an architecture where a single instance of a SaaS application serves multiple customers (tenants) simultaneously, with each tenant's data completely isolated from all others. Instead of running a separate application and database for each customer, a multi-tenant SaaS shares infrastructure across all customers while enforcing strict data boundaries. This is the standard architecture for SaaS products; it enables cost-efficient scaling, centralised updates, and shared infrastructure maintenance.

What are the three types of multi-tenancy in SaaS?

The three multi-tenancy models are: (1) Shared database with row-level security: all tenants share one database, and a tenant_id column on every table enforces data isolation at the query level. Cheapest and simplest, suitable for most SaaS products. (2) Shared database with separate schemas: each tenant has their own schema within the same database. More isolation than row-level security, more complex to manage. (3) Separate database per tenant: each tenant has a dedicated database. Maximum isolation and performance, highest cost and operational complexity. Suitable for enterprise products with strict data residency requirements.

What is the difference between multi-tenant and single-tenant SaaS?

Multi-tenant SaaS serves all customers from a shared application instance and shared infrastructure: one codebase, one deployment, one database (with logical data isolation). Single-tenant SaaS deploys a dedicated application instance per customer: each customer gets their own server, database, and often their own URL. Single-tenant is more expensive to operate and scale but offers complete infrastructure isolation, which some regulated enterprise buyers require. Most SaaS starts multi-tenant and offers single-tenant as an enterprise tier at a significant price premium.

What happens if multi-tenancy is implemented incorrectly?

A misconfigured multi-tenancy implementation can expose one customer's data to another, a catastrophic privacy and compliance failure. Common failures include: missing tenant_id filter on a query (data leak), incorrect row-level security policy that allows cross-tenant reads, a background job that processes all tenants' data without scoping, or a file storage path that can be guessed to access another tenant's files. These failures are hard to detect in testing and devastating in production. Correct multi-tenancy requires disciplined architecture review and penetration testing before launch.

Next recommended reading
  1. 01Custom SaaSsame fieldThe Real Cost of a Failed Software Project (And How to Avoid Becoming a Statistic)13 min read
  2. 02Custom SaaSsame fieldB2B SaaS MVP: What's Different and What to Build First12 min read
  3. 03Custom SaaSsame fieldSaaS MVP Checklist: 47 Things to Verify Before You Launch10 min read

Building something like this?

The best decisions happen
before the first line of code.

We build custom saas systems for funded products and enterprise teams. If you are working through a decision like this one and want a technical second opinion, bring the hard version of the problem.