---
title: "Multi-Tenant SaaS Architecture: How to Choose a Tenancy Model"
description: "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."
canonical_url: "https://cinnamon.digital/insights/multi-tenant-saas-architecture"
---

> Index of every page on this site: [llms.txt](https://cinnamon.digital/llms.txt)

**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

<table>
<thead>
  <tr>
    <th>
      
    </th>
    
    <th>
      Shared schema
    </th>
    
    <th>
      Schema per tenant
    </th>
    
    <th>
      Database per tenant
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Isolation
    </td>
    
    <td>
      Logical (policies)
    </td>
    
    <td>
      Logical (schemas)
    </td>
    
    <td>
      Physical
    </td>
  </tr>
  
  <tr>
    <td>
      Cost per tenant
    </td>
    
    <td>
      Lowest
    </td>
    
    <td>
      Low to moderate
    </td>
    
    <td>
      Highest
    </td>
  </tr>
  
  <tr>
    <td>
      Migrations
    </td>
    
    <td>
      One run
    </td>
    
    <td>
      One per schema
    </td>
    
    <td>
      One per database
    </td>
  </tr>
  
  <tr>
    <td>
      Noisy-neighbor risk
    </td>
    
    <td>
      Highest
    </td>
    
    <td>
      Moderate
    </td>
    
    <td>
      Lowest
    </td>
  </tr>
  
  <tr>
    <td>
      Per-tenant restore
    </td>
    
    <td>
      Hard
    </td>
    
    <td>
      Moderate
    </td>
    
    <td>
      Easy
    </td>
  </tr>
  
  <tr>
    <td>
      Best for
    </td>
    
    <td>
      Most B2B and B2C SaaS
    </td>
    
    <td>
      Mid-size tenant counts with stronger separation needs
    </td>
    
    <td>
      Enterprise, regulated, or data-residency customers
    </td>
  </tr>
</tbody>
</table>

## 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](https://cinnamon.digital/services/custom-saas-backends) team builds multi-tenant platforms on PostgreSQL, Supabase, and Node.js.

## Sitemap

See the full [sitemap](https://cinnamon.digital/sitemap.md) for all pages.
