GoldenrozBook a call

Multi-tenant architecture: isolation models, domains and billing

Multi-tenant architecture means one running application serves many customers, called tenants, while keeping each tenant's data separate. There are three isolation models: a shared schema with a tenant ID and Row Level Security, a schema per tenant, and a database per tenant. Most SaaS products should start with a shared schema and RLS, and reserve dedicated databases for customers who require them by contract.

A gold sphere set into a structure of stacked navy and white cubes.

What multi-tenancy is

A tenant is a customer organization. In a multi-tenant SaaS, every tenant uses the same deployed application and, in most designs, the same database. The system knows which tenant each request belongs to and shows only that tenant’s data.

The alternative is single-tenant: a separate deployment and database for every customer. That gives strong separation and simple reasoning, but every customer adds servers to run, migrations to apply and versions to keep in sync. Cost and operational work grow with the customer count.

Multi-tenancy trades that for one hard requirement: tenant isolation must be correct everywhere, every time. One query that forgets to filter by tenant shows customer A’s data to customer B. The architecture decision is mostly a decision about where that guarantee lives.

The three isolation models

Shared schema with Row Level Security

Every tenant-owned table has a tenant_id column. All tenants’ rows sit in the same tables. Postgres Row Level Security policies filter every query so that a user sees only rows whose tenant_id matches a tenant they belong to.

The important point is that the filter is enforced by the database, not by application code. A developer, or an AI coding agent, who writes a query without a tenant filter still gets only the current tenant’s rows. Our guide to Supabase Row Level Security shows the policies and a membership helper function.

Schema per tenant

Each tenant gets their own Postgres schema with a full copy of the tables, inside one database. The application sets the schema for each request.

Separation is stronger, and exporting or deleting one tenant’s data is straightforward. The cost is that every migration must run once per tenant. With 500 tenants, adding a column is 500 schema changes that must all succeed, and tenants can drift onto different versions when some fail.

Database per tenant

Each tenant gets their own database or their own database server. This is the strongest separation. It supports per-tenant backups, per-tenant regions and per-tenant encryption keys, and one tenant’s heavy usage cannot slow down another’s.

It is also the most expensive to run. Connections, migrations, monitoring and backups all multiply by the tenant count, and queries across tenants, such as platform-wide analytics, need a separate pipeline.

Comparison table

Shared schema with RLS Schema per tenant Database per tenant
Isolation enforced by RLS policies and triggers Schema boundaries and permissions Separate databases
Cost per tenant Lowest Low to medium Highest
Migrations Run once Run once per tenant Run once per tenant database
Onboarding a tenant Insert a row Create a schema and its tables Provision a database
Noisy-neighbor risk Highest, shared tables and indexes Medium, shared server Lowest
Per-tenant backup and restore Hard, needs filtered export Possible Simple
Per-tenant data residency No No Yes
Cross-tenant analytics Simple Awkward Needs a separate pipeline
Practical tenant count Thousands and up Tens to low hundreds Tens, or a few large customers
Main risk A wrong or missing policy Migration drift Operational load

How to choose

Start with a shared schema and RLS unless you have a specific reason not to. The reasons that justify more isolation are concrete:

  • A customer contract or regulation requires data in a dedicated database or a specific region.
  • A few tenants are so large that their load would affect everyone else.
  • Tenants need custom schema changes, which is a warning sign for a product in any case.

A hybrid is common in practice: most tenants share a schema, and the few enterprise customers who pay for it get a dedicated database running the same code. Design the tenant lookup so that it returns a database connection, and that upgrade path stays open.

Making shared-schema isolation hold

A tenant_id column alone is a convention, and conventions get forgotten. These controls turn it into a guarantee.

  • RLS on every tenant-owned table, with policies for select, insert, update and delete.
  • Membership checked in the database. A user’s tenants come from a memberships table or from token claims the user cannot edit, never from a value the client sends.
  • Triggers that set and protect tenant_id. A trigger can fill the tenant on insert and reject any update that tries to change it. In the platform Shai converted, tenant isolation is enforced in database triggers as well as policies.
  • Indexes that lead with tenant_id, so each tenant’s queries stay fast as the tables grow.
  • Unique constraints scoped to the tenant. A slug or an email is usually unique within a tenant, not across the platform.
  • Views created with security_invoker, so they do not bypass the policies.
  • Careful use of the service role. Background jobs that bypass RLS must apply the tenant filter themselves. Keep them few and review each one.
  • Automated tests as two tenants. Log in as a user of tenant A and try to read and write tenant B’s rows on every table.

What a white-label platform adds

A multi-tenant SaaS shows every customer the same product under your brand. A white-label SaaS lets each tenant present it as their own. That adds three parts on top of data isolation.

Custom domains

Each tenant wants the product on their own domain, with HTTPS. Doing this by hand per customer does not scale. Cloudflare for SaaS handles it: you register each tenant’s domain as a custom hostname on your zone, the tenant points a DNS record at your platform, and Cloudflare issues the certificate and routes traffic to your origin.

Your application then resolves the tenant from the request’s hostname on every request. Two details to plan for: some DNS providers do not allow a CNAME on a root domain, so tenants may need to use a subdomain such as app. or order., and login redirect URLs and cookies must work per domain.

Per-tenant billing

There are two separate money flows. The first is what the tenant pays you for the platform. The second is what the tenant’s customers pay the tenant through the platform.

Stripe Connect covers the second flow. Each tenant connects their own Stripe account, payments go to the tenant, and the platform takes an application fee from each transaction. The tenant owns the relationship with their customers and their payouts. Fee settings live per tenant, so different plans can carry different platform fees. Our marketplace development page covers payment flows in more depth.

Per-tenant branding and email

Logo, colors, product name, legal texts and email sender all become tenant settings. The rule is that nothing visible to an end user is hardcoded. Transactional email is the part teams forget: receipts and password resets must come from the tenant’s name and, ideally, the tenant’s sending domain.

Lessons from a two-week conversion

Shai turned a single-tenant consumer app into a multi-tenant white-label platform in about two weeks. The result had automatic custom domains through Cloudflare for SaaS, Stripe Connect with a platform fee, per-tenant branding, email and billing, and isolation at the database level. What we took from it:

  1. Isolate in the database first. Add tenant_id, policies and triggers before touching the interface. Once the database refuses cross-tenant access, the rest of the work is safe to do quickly.
  2. Backfill a default tenant. The existing customer becomes tenant one. Every existing row gets its ID, then the column becomes not null.
  3. Hunt for global assumptions. Unique constraints, cached settings, cron jobs, file storage paths and analytics events all tend to assume one customer.
  4. Resolve the tenant in one place. One function maps hostname to tenant. Everything else reads from it.
  5. Treat billing as its own project. Connecting accounts, fees, refunds and failed payouts have more edge cases than the data model.
  6. Move hardcoded strings to settings early. Brand names hide in emails, push notifications, page titles and error messages.
  7. Test as two tenants from the first day. A second tenant in staging catches leaks that a single test tenant never will.

The two weeks were possible because the app already ran on Postgres with RLS and had one codebase for all clients. A codebase with access control spread through application code would take longer.

What to do next

If you are starting a SaaS, begin with a shared schema, a tenant_id on every table and RLS from the first migration. See SaaS development for how we scope that. If you have a working single-tenant product and want to sell it to other businesses under their own brands, read about our white-label SaaS work and book the free one-hour consultation. Build projects start at $25,000 with a fixed price per phase.

Questions buyers ask

What is multi-tenant architecture?

It is a design where a single deployment of an application serves many customers, and each customer's data, settings and users are kept separate. The alternative is single-tenant, where every customer gets their own copy of the application and database.

Which multi-tenant database model is best?

For most SaaS products, a shared schema with a tenant ID column and Row Level Security is the best starting point because it has the lowest cost and the simplest operations. Schema per tenant and database per tenant give stronger separation but multiply migrations, connections and monitoring.

What is the difference between multi-tenant SaaS and white-label SaaS?

Multi-tenant describes the architecture: one system, many customers. White-label describes the product: each customer presents the system under their own brand, domain and emails, and often bills their own end users. A white-label platform is a multi-tenant system with branding, custom domains and per-tenant billing on top.

How do custom domains work in a multi-tenant app?

The tenant points a DNS record for their domain at your platform. A service such as Cloudflare for SaaS registers that domain as a custom hostname, issues a TLS certificate for it and routes traffic to your application. Your application then reads the hostname on each request to decide which tenant to load.

How long does it take to convert a single-tenant app to multi-tenant?

It depends on the size of the schema and how many places assume a single customer. Shai converted a consumer app into a multi-tenant white-label platform, with custom domains, Stripe Connect and per-tenant branding, in about two weeks. A larger or older codebase takes longer.

Written by

CTO and technology partner

Shai leads the technology side: business software, SaaS and mobile apps, payments and escrow systems, Postgres security, AI agents built with Claude Code and MCP, and IT and infrastructure projects with senior infrastructure engineers.

Keep reading

Talk to the person who will do the work

One hour, no sales team. You talk to Daniel or Shai, we look at your account or your product, and you leave with a clear next step.

Or send the details

Book a 1-hour consultationWhatsApp us