Black Friday: 30% off every plan through November 30. See the prices
SysDesignPrep.com
Study guide

Updated 24 October 2026

Multi-tenancy

Designing SaaS systems that serve many customers from shared infrastructure: tenancy models from shared tables to dedicated stacks, tenant isolation for data and security, noisy neighbours, per-tenant limits, cells, enterprise requirements and tenant-aware operations.

Reading is half of it. Now try it in an interview.An AI interviewer asks you to design Slack, out loud or typed, and scores the answer for your level. Or watch a sample interview first, free with no sign-up to start.
Start an AI mock

Try it yourself, in a playground:Shuffle shardingFair queuing

Most B2B products serve thousands of customer organisations (tenants) from one system. Slack workspaces, Shopify stores and Salesforce orgs all share infrastructure while each customer expects its data to be private, its performance unaffected by others, and sometimes its own region or encryption keys. Multi-tenancy questions test isolation, fairness and operations, and they come up whenever a design says "for businesses".

Tenancy models

ModelHowIsolationCost per tenantOperations
Shared tablesone schema, tenant_id column on every rowlogical onlylowestsimplest; one migration for all
Schema per tenanta schema or database per tenant on shared serversstrongermediummany schemas to migrate
Database per tenantdedicated database instancesstronghighfleet management
Stack per tenant (silo)dedicated services and storagestrongesthighestmany deployments

Most systems use shared tables for the long tail of small tenants and offer dedicated resources to the largest or most regulated customers. Choosing the model per tier is a reasonable interview answer.

Data isolation

With shared tables, a missing WHERE tenant_id = ? leaks one customer's data to another, the worst bug a SaaS company can have. Defences in depth:

  • Tenant id in every key and every index, leading the primary key ((tenant_id, id)), which also co-locates a tenant's data.
  • Enforce in one place: a data-access layer that injects the tenant filter, or database row-level security policies.
  • Tenant from the token, never from a request parameter the client controls. See security and auth.
  • Per-tenant encryption keys for enterprise customers, which also enables deleting a tenant by destroying its key. See encryption and key management.
  • Tests that try to read across tenants.

Caches, search indexes, object storage paths, queues and logs need tenant scoping too.

Partitioning by tenant

Sharding by tenant id keeps each tenant's queries on one shard and makes tenant moves possible. The problem is skew: one giant tenant can outgrow a shard. Options: place big tenants on dedicated shards, split them by a secondary key, or use a directory that maps each tenant to its shard so it can be moved. See sharding and partitioning.

Noisy neighbours

One tenant's import job or traffic spike should not slow everyone else. Tools:

  • Per-tenant rate limits and quotas on API calls, storage, jobs and concurrent connections. See Design a Rate Limiter.
  • Fair queuing: background job and stream workers take work round-robin across tenants instead of first-in-first-out, so one tenant's million jobs do not block others. See Design a Job Scheduler.
  • Per-tenant resource accounting (CPU, queries, storage) to spot heavy users and bill accurately.
  • Isolation of heavy tenants onto separate pools once they cross a threshold. See hot keys and skew.

Cells

A cell architecture splits the system into independent copies (cells), each serving a subset of tenants with its own databases and services. A bug or overload affects one cell's tenants, not everyone, and capacity grows by adding cells. A thin routing layer maps tenants to cells. Slack, AWS and many large SaaS companies use cells to limit blast radius. See Design Slack.

Enterprise requirements

Large customers ask for:

Design the tenant model so these are configuration per tenant, not forks of the codebase.

Tenant-aware operations

  • Metrics, logs and traces tagged with tenant id, so "is it just this customer?" is one query.
  • Feature flags and rollouts targeted by tenant.
  • Tenant lifecycle: provisioning, plan changes, moving between shards or cells, export and deletion.
  • Cost per tenant to understand margins.

In the interview

When the product serves businesses, state the tenancy model, show tenant_id leading your keys, name how isolation is enforced, and mention per-tenant limits and fair scheduling. For large scale, add cells to limit blast radius.

Checklist

  • Tenancy model chosen per tier: shared for most, dedicated for the largest.
  • Tenant id leading every key; enforcement in one layer or with row-level security.
  • Tenant derived from the authenticated identity.
  • Per-tenant quotas, fair queuing and resource accounting.
  • Cells or tenant directories for blast radius and moves.
  • Residency, keys and audit as per-tenant configuration.

Questions people ask

What is multi-tenancy?

Multi-tenancy means serving many customer organisations (tenants) from one shared system, as Slack workspaces, Shopify stores and Salesforce orgs do. Each customer still expects its data to be private, its performance unaffected by others, and sometimes its own region or encryption keys. Multi-tenancy questions therefore test isolation, fairness and operations, and they come up whenever a design says "for businesses".

What is the difference between shared tables and a database per tenant?

Shared tables put every tenant in one schema with a tenant_id column on each row, while a database per tenant gives each tenant dedicated instances. Shared tables have the lowest cost per tenant and one migration for all, but only logical isolation; a database per tenant gives strong isolation at a high cost and needs fleet management. Most systems use shared tables for the long tail of small tenants and dedicated resources for the largest or most regulated customers.

How do you isolate tenant data in a shared database?

Put the tenant id in every key and index, leading the primary key as (tenant_id, id), and enforce the tenant filter in one place, with a data-access layer or database row-level security. A single missing WHERE tenant_id = ? leaks one customer's data to another, the worst bug a SaaS company can have. Take the tenant from the authenticated token, never from a client-controlled parameter, and write tests that try to read across tenants.

What is the noisy neighbour problem?

The noisy neighbour problem is when one tenant's import job or traffic spike slows everyone else on shared infrastructure. Per-tenant rate limits and quotas on API calls, storage, jobs and connections cap the damage, and fair queuing makes workers take work round-robin across tenants instead of first-in-first-out, so one tenant's million jobs do not block others. Per-tenant resource accounting spots heavy users, who can be moved to separate pools once they cross a threshold.

How do you shard a multi-tenant database?

Shard by tenant id, so each tenant's queries stay on one shard and tenants can be moved. The catch is skew: one giant tenant can outgrow a shard. Place big tenants on dedicated shards, split them by a secondary key, or keep a directory that maps each tenant to its shard so it can be moved.

How do cells help multi-tenant systems?

Cells limit blast radius: the system is split into independent copies, each serving a subset of tenants with its own databases and services, behind a thin routing layer that maps tenants to cells. A bug or overload then affects one cell's tenants rather than everyone, and capacity grows by adding cells. Slack, AWS and many large SaaS companies use cells for this reason.