Multi-tenant architecture is a way to build SaaS where one application serves many customer companies, called tenants, while keeping each tenant's data separate. Most startups should begin with a shared database and a tenant ID on every row, enforced in the data layer, and move large or regulated customers to their own database later.
Key takeaways
- Multi-tenancy is a spectrum, not a switch: you can share the app, the database, the schema or nothing, and mix models for different customers.
- A shared database with a tenant ID is the cheapest to run and the easiest to change, but it needs isolation enforced below the application code.
- Tenant context must travel with every request, background job and cache key, or data will leak between customers.
- Billing, usage limits and noisy-neighbor protection belong in the architecture from the first release, not after the first big customer.
- Moving from single-tenant to multi-tenant is a data migration project; plan it tenant by tenant with a rollback path.
Single-tenant vs multi-tenant SaaS architecture
In a single-tenant SaaS architecture, each customer gets its own copy of the application and database; in a multi-tenant one, customers share the same running application and some or all of the data infrastructure. Microsoft's Azure Architecture Center describes the same range as tenancy models, and AWS calls the ends of it silo, pool and bridge: dedicated resources, shared resources and a mix of both.
| Single-tenant | Multi-tenant | |
|---|---|---|
| What is shared | Nothing, or only the code | The application, and usually the database |
| Cost per customer | High: infrastructure for every customer | Low: one platform for all customers |
| Releases | One deploy per customer; versions drift apart | One deploy for everyone |
| Isolation | Strong by default | Must be designed and tested |
| Customization | Easy per customer, hard to maintain | Through configuration and feature flags |
| Best for | A few large or regulated customers | Many small and mid-size customers, self-serve sign-up |
Most B2B SaaS products end up multi-tenant because one release for all customers is what keeps a small team fast. Single-tenant deployments still make sense for a handful of enterprise customers who pay for them and need them for compliance. If you are planning a SaaS product and want this decision made with you in the first sprint, see our SaaS development services.
Data isolation models: shared database, schema per tenant, database per tenant
There are three common ways to isolate tenant data, and the right one depends on customer size, compliance needs and how much operational work you can carry. You can also combine them: most tenants in a shared database, and the largest ones in their own.
| Shared database, tenant_id column | Schema per tenant | Database per tenant | |
|---|---|---|---|
| How it works | All tenants in the same tables; every row has a tenant_id | One database, a separate schema (set of tables) per tenant | A separate database for each tenant |
| Isolation | Logical: enforced by queries and row-level security | Stronger: tables are separate, the server is shared | Strongest short of separate servers |
| Cost per tenant | Lowest | Medium | Highest |
| Migrations | Once for everyone | Once per schema; many tenants mean long runs | Once per database; needs automation |
| Onboarding a tenant | Insert a row | Create a schema | Provision a database |
| Per-tenant backup and restore | Hard: data is mixed | Possible per schema | Simple |
| Noisy-neighbor risk | Highest | Medium | Lowest |
| Fits | Startups, self-serve plans, thousands of small tenants | Dozens to hundreds of mid-size tenants | Enterprise or regulated tenants, data residency |
Shared database with tenant_id. This is the default for most new SaaS products. Put a tenant_id on every tenant-owned table, include it in every index that matters, and enforce it below the application code. In PostgreSQL, row-level security lets the database itself filter rows by the current tenant, so a missing WHERE clause does not turn into a data leak.
Schema per tenant. Each tenant gets its own set of tables inside one database. It makes per-tenant restore and custom indexes easier, but every migration runs once per schema, and the database catalog grows with every tenant.
Database per tenant. Each tenant has its own database, sometimes in its own region. It gives the clearest answer to "where is our data" in security reviews and the simplest per-tenant restore. The price is automation: provisioning, migrations, monitoring and connection pooling all have to work across many databases.
Questions that decide the model:
- How many tenants do you expect in two years? Thousands of small accounts point to a shared database; a few dozen large contracts can justify separate schemas or databases.
- Do contracts or regulations require dedicated storage or a specific region? If even one target customer needs it, design so a tenant can be moved out of the shared pool.
- Do tenants need custom fields or workflows? Prefer configuration stored as data over per-tenant tables, which multiply migrations.
- Who will run the operations? Every database per tenant is one more thing to back up, upgrade and monitor; a small team should share as much as isolation allows.
- How will you restore one tenant's data after a mistake? If the answer matters to your customers, test it before launch, whatever model you choose.
Auth, roles and tenant context
Every request in a multi-tenant SaaS must answer two questions before it touches data: who is the user, and which tenant are they acting for. Getting the second answer wrong is how one customer sees another customer's records.
A practical request flow:
- Resolve the tenant. From the subdomain (acme.yourapp.com), a path segment or a claim in the user's token. Never from a value the browser can change freely, such as a hidden form field.
- Check membership. Confirm the signed-in user belongs to that tenant and load their role in it. One person can belong to several tenants with different roles.
- Set the tenant context. Store the tenant ID in request-scoped context and pass it to the data layer, for example as a session variable that row-level security policies read.
- Carry it everywhere. Background jobs, queues, caches, search indexes, file storage paths and logs all need the tenant ID. A cache key without it is a leak waiting to happen.
- Test isolation. Automated tests that sign in as tenant A and try to read, update and list tenant B's data through every API endpoint.
Roles live inside a tenant: an admin of one company has no rights in another. Keep platform roles, such as your own support staff, separate from tenant roles, and log every time support staff open a customer's tenant. For enterprise customers, plan for single sign-on per tenant, since each company will want to use its own identity provider.
Billing and usage metering
Billing in a multi-tenant SaaS is attached to the tenant, not to the user, and the architecture has to count what you charge for. Decide early which of these your pricing uses, because each one needs data that is hard to backfill.
| Pricing model | What the platform must track | Typical enforcement point |
|---|---|---|
| Flat plan | Plan and status per tenant | Feature flags per plan |
| Per seat | Active users per tenant | Inviting a user, monthly count |
| Usage-based | Events: API calls, documents, messages, storage | Metering pipeline, near-real-time limits |
| Hybrid | Seats plus usage above an included amount | Both of the above |
Write usage events to an append-only store with the tenant ID, the event type and a timestamp, and aggregate them for invoices; do not recompute usage from live tables at billing time. Keep the payment provider as the source of truth for payments, and your platform as the source of truth for plans, limits and usage. When a tenant goes over a limit, decide in the product whether to block, warn or bill the overage, and make that rule visible in the admin panel.
Scaling and noisy neighbors
A noisy neighbor is a tenant whose load slows the platform down for everyone else, and every shared model needs a plan for it. The AWS whitepaper on SaaS tenant isolation strategies treats this as part of isolation, not only performance.
Ways to contain it:
- Rate limits per tenant on APIs and heavy endpoints, tied to the plan.
- Separate queues or worker pools for long-running jobs such as imports, exports and reports, so one tenant's import does not delay another tenant's emails.
- Per-tenant metrics: request volume, slow queries, storage and job time by tenant ID, so you can see who is causing load.
- Tiered placement: move the largest tenants to their own database or cluster (the bridge model) while small tenants stay pooled.
- Indexes that start with tenant_id in a shared database, so queries scan one tenant's rows instead of the whole table.
Scaling a shared database usually goes in steps: query and index tuning, read replicas, moving heavy tenants out, then sharding tenants across several databases. A tenant ID on every row from day one is what makes the later steps possible.
Migration from single-tenant to multi-tenant
Migrating from single-tenant to multi-tenant is a data and operations project, done tenant by tenant, with both versions running in parallel for a while. The code changes are the smaller part.
| Step | What happens | Check before the next step |
|---|---|---|
| 1. Audit | List every table, file store, cache, job and integration that holds customer data | Nothing tenant-owned is missing from the list |
| 2. Add tenant context | tenant_id columns, request-scoped tenant context, isolation tests | Isolation tests pass on all endpoints |
| 3. Unify the code | One codebase for all customers; per-customer differences become configuration or feature flags | No customer-specific branches remain |
| 4. Migrate tenant by tenant | Copy one customer's data into the shared platform, reconcile record counts and totals, switch their traffic | Reconciliation report matches; rollback tested |
| 5. Retire old instances | Shut down single-tenant servers after a quiet period | Backups kept for the agreed retention time |
Start with a small, friendly customer, and keep each customer's old instance ready to take traffic back until their data has been checked. If the existing product is old enough that the codebase itself needs work first, see how we approach legacy software modernization.
How Join.To.IT can help
Join.To.IT designs multi-tenant SaaS from the first sprint. We choose the tenancy model by your compliance needs, customer size and cost targets: a shared schema, a schema per tenant or a database per tenant. Tenant isolation is enforced in the data layer, not only in the interface, and plans, seats and usage limits are part of the platform from the start. A SaaS MVP on a multi-tenant base starts from $9,600 and usually takes 2–4 months. We also take over existing SaaS products and plan migrations to multi-tenancy with the team that runs them. See our SaaS development services, read our SaaS tech stack guide or what a SaaS product costs to build.
FAQ
Which multi-tenant model is best for a startup?
For most startups, a shared database with a tenant_id on every row is the best start. It is the cheapest to run, a new tenant is one row, and migrations run once. Enforce isolation in the data layer, for example with row-level security, and keep the option to move a large or regulated customer to its own database later.
Is multi-tenancy secure?
Multi-tenancy is secure when isolation is designed and tested, not assumed. The common failures are a query without a tenant filter, a cache key without a tenant ID and a background job that runs with the wrong context. Enforce isolation in the database, test cross-tenant access on every endpoint, and log every time your staff open a customer's data.
How do you migrate to multi-tenant?
Audit every place that holds customer data, add tenant IDs and request-scoped tenant context, and cover isolation with automated tests. Then move customers one at a time: copy the data, reconcile counts and totals, switch traffic, and keep the old instance ready for rollback until the data is verified. Start with a small, friendly customer.
Does multi-tenancy work with HIPAA/SOC 2?
It can. HIPAA and SOC 2 require controls such as access management, encryption, audit logs and monitoring, and you have to show that tenant data is protected. HHS allows ePHI in the cloud under a business associate agreement and Security Rule safeguards (HHS cloud computing guidance). Regulated customers often ask for a dedicated database or region, so a model that can move them out of the shared pool helps. This is not legal advice.





