Multi-tenant isolation is the decision you make before the second customer signs—and the one teams regret when they copy the enterprise playbook on day one.
A tenant is a customer’s slice of your product: their users, data, config, and billing. Isolation means one tenant cannot read or change another’s data, and one noisy tenant cannot starve the rest. Overbuilding means a database per tenant, a cluster per tier, and a migration story you cannot staff before you have ten logos on the homepage.
This note is for teams shipping a B2B SaaS MVP or early growth product from Noida—or anywhere—with senior engineers and a written SOW, not a platform team of forty.
The Three Isolation Shapes

| Model | What it is | v1 fit | Pain later |
|---|---|---|---|
| Shared schema | One database, tenant_id on rows, enforced in app + DB |
Almost always yes for early SaaS | Leaks if one query forgets the filter |
| Schema per tenant | Same cluster, separate Postgres schemas | Regulated mid-market, moderate tenant count | Migration and connection pool complexity |
| Database per tenant | Dedicated DB (or cluster) per customer | Enterprise / dedicated box contracts | Ops cost, provisioning, schema drift |
Default for v1: shared schema with defense in depth—tenant from the token at the edge, enforced again at the data layer. Upgrade a single tenant only when contract, compliance, or measured noisy-neighbor pain justifies it—not because a diagram looked cleaner in a deck.
If you are still choosing the primary database, see PostgreSQL vs MongoDB. Most B2B products we scope end on Postgres with RLS or strict repository guards; document stores need the same discipline in application code.
Where Isolation Actually Happens
Multi-tenant isolation is not one middleware call. It is a chain:
- Edge — JWT or session carries
tenant_id. The gateway does not trust query parameters for tenant. - Application — Every repository method receives tenant context from request scope, not from caller args alone.
- Database — Postgres row-level security (
SET LOCAL app.tenant_id+ policies) or equivalent guards on every table that holds tenant data. - Cache and search — Keys and indexes are prefixed or filtered by tenant. A shared Redis without a prefix convention is a future breach.
- Object storage — Path prefix per tenant; signed URLs scoped to that prefix.
- Jobs and queues — Message envelope includes tenant; workers set context before touching data. See designing webhooks you can operate for the same idempotency discipline on inbound events.
- AI / RAG — Retrieval filters by tenant before embeddings hit the prompt. See RAG architecture.
Miss any one layer and the others do not matter. The classic leak is perfect SQL in the API and a cache key that is only user:123.
Row-Level Security in Plain Terms
On Postgres, RLS lets the database reject rows that do not match the current tenant setting—even if a developer ships a query without a WHERE tenant_id = $1.
Pattern
- Middleware opens a transaction and runs
SET LOCAL app.current_tenant = '<uuid>'. - Policies on tenant tables:
USING (tenant_id = current_setting('app.current_tenant')::uuid). - Tests that deliberately omit tenant context should see zero rows, not an error buried in logs.
RLS is not a substitute for code review. It is the seatbelt when someone adds a report query at 11pm.
When to Move a Tenant to a Dedicated Box
Split one tenant out when you can name the trigger:
| Trigger | Example split |
|---|---|
| Contract | Customer paid for dedicated DB and audit boundary |
| Compliance | Data residency requires a region-specific cluster |
| Noisy neighbor | One tenant’s batch jobs dominate CPU and hurts others |
| Migration | Legacy import so large that shared maintenance windows fail |
The move is a project: snapshot, CDC or dual-write, reconciliation, cutover flag—not a weekend pg_dump. The same phased discipline applies as in legacy cutover without a big-bang.
What to Put in the SOW
| Write down | Why |
|---|---|
| Isolation model for v1 | Shared schema + RLS vs dedicated |
| Tenant source of truth | Token claim name, never body |
| Tables in scope for v1 | Not “everything eventually” |
| Upgrade path | What would justify schema or DB split |
| Test requirement | Cross-tenant access tests in CI |
What belongs in a software SOW applies to platform work as much as features.
FAQ
Is MongoDB multi-tenant different?
Same rules: tenant in the token, tenant on every document filter, tenant on every index design. The database will not RLS for you; repositories and integration tests must.
Can we use one database per tenant from day one?
You can. You will spend the first year provisioning and patching N databases instead of shipping product. Most teams regret it before customer twenty.
Does OrgPlaza inform this?
OrgPlaza is a multi-tenant workplace product; isolation and tenant-scoped culture data are part of that surface. This article is the pattern, not a product changelog.
The Bottom Line
Multi-tenant isolation for v1 is shared schema, tenant in the token, RLS or strict data access, tenant-scoped cache and queues. Split schema or database when a contract or measurement demands it—not when a slide deck shows a cluster farm.
Designing tenant boundaries for a new SaaS or a split from a monolith? See software development or contact us for an estimate.
