If you're building a SaaS product, many customers will use the same application at the same time. Each customer, whether a company or an individual, is a tenant. Multi-tenant architecture is how you share infrastructure efficiently while making sure no tenant ever sees another's data.

The three common models

  • Shared database, shared tables: every record carries a tenant ID, and every query filters by it. Cheapest to run and simplest to update.
  • Separate schema per tenant: one database, but each tenant's tables live in their own schema. More isolation, more to manage.
  • Separate database per tenant: the strongest isolation and easiest per-tenant backup and restore, at a higher cost and operational effort.

Many products mix them: smaller customers share, while large or regulated customers get their own database.

What to weigh

  • Isolation and security: how strictly must data be separated?
  • Cost: shared models use resources more efficiently.
  • Noisy neighbours: one heavy tenant shouldn't slow down everyone else.
  • Compliance and data residency: some customers need their data in a particular country.
  • Operations: migrations, backups and monitoring across many tenants.

Essentials for any model

  • Tenant context on every request, checked at the data layer, not just in the interface.
  • Automated tenant onboarding and offboarding.
  • Per-tenant settings, plans and feature flags.
  • Usage metering that matches your billing.
  • Tests that prove one tenant can't read another's data.

Starting with an MVP

For most MVPs, a shared database with a tenant ID is the right start: it's quick to build and cheap to run. Design it so tenant context is enforced in one place, which keeps the option of moving large customers to their own database later.

Tenant isolation bugs are among the most serious a SaaS product can have. Test them as carefully as payments.