Backendcore
Multi-tenancy
Isolate customers’ data, costs and limits across database, index, cache, logs and models.
What it is and why it exists
Tenancy touches every layer: rows (tenant_id + RLS), indexes (namespaces or filters), caches (tenant in the key), queues (fairness), rate limits and budgets (per tenant), traces (access control), and sometimes models (per-tenant prompts, fine-tunes or dedicated deployments).
Quick prototype
A tenant_id column and good intentions.
In production, at scale
Tenant resolved from auth on every request, enforced in the data layer (RLS / mandatory filters), tenant-scoped keys everywhere, per-tenant quotas and cost attribution, noisy-neighbour protection, and automated isolation tests.
Vendors and tools
| Postgres RLS | Database-enforced isolation |
|---|---|
| Pinecone namespaces / Qdrant tenants | Vector isolation |
On AWS: SaaS Lens patterns (silo, pool, bridge); IAM session tags for tenant-scoped access; DynamoDB leading-key conditions.
How it fails
- One code path that forgets the tenant filter
- Shared cache keys
- One tenant’s batch job eating everyone’s rate limit
What the interviewer asks next
Silo vs pool?
Silo: separate resources per tenant — strong isolation, higher cost and ops. Pool: shared resources with tenant keys — efficient, isolation depends on code. Many SaaS products pool small tenants and silo large or regulated ones.