SaaS & Engineering

Multi-Tenant SaaS Architecture: How to Choose a Tenancy Model

Compare the three main multi-tenancy models for SaaS, a shared database, schema per tenant, and database per tenant, with trade-offs for isolation, cost, scaling, and compliance, plus practical tips for PostgreSQL.

By Cinnamon Digital ·

Most SaaS products should start with a shared database where every tenant-owned row carries a tenant ID, enforced by row-level security. Separate schemas or databases per tenant offer stronger isolation, but at a higher operational cost that early-stage products rarely need. The right choice depends on your customers' isolation requirements, scale, and the size of your team.

The three main models

1. Shared database, shared schema

All tenants share the same tables. Every tenant-owned table has a tenant_id column, and every query filters by it.

  • Pros: Simplest to build and operate, lowest cost, one migration updates everyone, and easy cross-tenant reporting for your own analytics.
  • Cons: A missed filter can expose data between tenants, one heavy tenant can slow others, and some enterprise or regulated customers may require stronger separation.

2. Shared database, schema per tenant

Each tenant gets its own schema with identical tables inside one database.

  • Pros: Stronger logical separation, easier per-tenant backup and restore, and simpler data deletion.
  • Cons: Migrations must run across every schema, the number of database objects grows with each tenant, and connection pooling and tooling become more complex.

3. Database per tenant

Each tenant has a dedicated database, sometimes on dedicated infrastructure.

  • Pros: Strongest isolation, per-tenant performance tuning, data residency options, and a straightforward story for security reviews.
  • Cons: Highest cost and operational overhead, migrations and monitoring across many databases, and harder cross-tenant reporting.

Comparison

Shared schemaSchema per tenantDatabase per tenant
IsolationLogical (policies)Logical (schemas)Physical
Cost per tenantLowestLow to moderateHighest
MigrationsOne runOne per schemaOne per database
Noisy-neighbor riskHighestModerateLowest
Per-tenant restoreHardModerateEasy
Best forMost B2B and B2C SaaSMid-size tenant counts with stronger separation needsEnterprise, regulated, or data-residency customers

The hybrid model

Many mature SaaS platforms combine models: most customers live in a shared database, while large or regulated customers get a dedicated database on a premium plan. To make this possible later, design from day one so that:

  • Every tenant-owned table has a tenant identifier.
  • All data access goes through one layer that knows the current tenant.
  • Tenant routing, meaning which database a tenant lives in, is a lookup rather than hard-coded.

Making the shared model safe in PostgreSQL

If you choose a shared schema, defend against cross-tenant leaks at several layers:

  1. Row-level security policies that compare each row's tenant_id to the current tenant set for the session or derived from the authenticated user.
  2. Indexes that start with tenant_id on large tables, so per-tenant queries stay fast.
  3. Foreign keys that include tenant_id where practical, so records cannot reference another tenant's data.
  4. Automated tests that log in as one tenant and confirm they cannot read or change another tenant's records.
  5. Per-tenant rate limits and quotas to reduce noisy-neighbor problems.

Platforms such as Supabase build on PostgreSQL row-level security, which makes this pattern a natural fit.

Other tenancy decisions

  • Identity: Can one user belong to several tenants? Most B2B products need this, so model memberships separately from users.
  • Configuration: Store per-tenant settings, feature flags, and plan limits in their own tables.
  • File storage: Prefix object storage paths with the tenant ID and apply the same access rules as the database.
  • Background jobs: Pass the tenant ID explicitly to every job and log it for debugging.
  • Data deletion: Plan how to export and fully delete a tenant's data when a customer leaves.

Where to start

Write down your likely customer mix for the next two years, including whether any will require dedicated infrastructure or data residency. If not, start shared, enforce isolation in the database, and keep the door open for dedicated tenants later. If you want help designing or reviewing your architecture, our custom SaaS backends team builds multi-tenant platforms on PostgreSQL, Supabase, and Node.js.

Multi-tenancy questions

Related service
Custom SaaS Backends
Backend architecture and implementation for SaaS products.