LumenForgee

Multi-tenant isolation models: pool, bridge and silo

Every multi-tenant platform answers the same question, explicitly or by accident: what stops one customer from seeing another customer's data, or from slowing everyone else down? The answer is an isolation model, and the most useful models let different tenants sit at different levels without separate code.

Contents
  1. The three models
  2. Establishing tenant context
  3. Row-level security as a second line
  4. Performance isolation and noisy neighbours
  5. Moving tenants between tiers
  6. Data location and tenant-level operations
  7. Worked example: hardening a pooled platform
  8. Common pitfalls
  9. FAQ
  10. Checklist
  11. Primary sources

Key facts

  • Common isolation models are pool (shared resources), bridge (shared infrastructure with per-tenant schemas or namespaces) and silo (dedicated resources per tenant).
  • PostgreSQL row-level security lets the database enforce per-row access policies in addition to application checks.
  • Data isolation and performance isolation are separate problems; strong data isolation alone does not prevent noisy neighbours.
  • Tenant identity should come from the authenticated session or token, never from a request parameter the client controls.

The three models

Multi-tenant isolation models
ModelWhat is sharedStrengthsCosts
PoolDatabases, tables, workersLowest cost per tenant; simple operationsIsolation depends on correct filtering; noisy neighbours
BridgeClusters and services; separate schemas or namespacesClearer data boundaries; per-tenant backup and restoreMore objects to manage; migrations per schema
SiloLittle or nothingStrong isolation; per-tenant capacity and locationHighest cost; fleet management overhead

Most platforms end up with a mixture. Small tenants live in the pool because dedicated infrastructure would cost more than they pay. A few large or regulated tenants need dedicated databases, specific data locations or independent maintenance windows. The design goal is to make the tier a property of the tenant rather than a fork in the code.

Establishing tenant context

All isolation starts with knowing which tenant a request belongs to. That identity must come from something the client cannot forge — a claim in a signed token, or the authenticated session — and be resolved once, at the edge of the application. Taking a tenant ID from a URL parameter or header without checking it against the authenticated identity is one of the most common causes of cross-tenant data leaks.

Once resolved, the tenant context travels with the request: into database sessions, background jobs, log fields, metrics labels at a bounded level, and outbound calls. A job that runs later on behalf of a tenant needs the context stored with the job, not looked up from whatever is in memory.

Row-level security as a second line

In a pooled database, the application adds WHERE tenant_id = ... to every query. One forgotten filter exposes everyone's data. PostgreSQL row-level security adds a second line of defence: policies attached to the table restrict which rows a session can see or modify, regardless of the query.

PostgreSQL: tenant policy using a session setting
ALTER TABLE invoices ENABLE ROW LEVEL SECURITY;
ALTER TABLE invoices FORCE ROW LEVEL SECURITY;

CREATE POLICY tenant_isolation ON invoices
  USING (tenant_id = current_setting('app.tenant_id')::uuid)
  WITH CHECK (tenant_id = current_setting('app.tenant_id')::uuid);

-- per transaction, after authentication:
SET LOCAL app.tenant_id = '6f1c...';

A few details matter. Table owners and superusers bypass policies unless FORCE ROW LEVEL SECURITY is set and the application connects as a role without BYPASSRLS. With connection poolers in transaction mode, the tenant setting must be set per transaction (SET LOCAL), not per session, or a pooled connection may carry another tenant's context. And policies need tests: automated checks that a session for tenant A cannot read or write tenant B's rows.

Performance isolation and noisy neighbours

Data isolation does not stop one tenant from consuming shared capacity. A large export, a runaway integration or an expensive report can exhaust connections, CPU or queue capacity for everyone in the pool.

  • Quotas at every shared resource — request rate, concurrent jobs, connections, statement time and storage per tenant.
  • Separate workload classes — interactive requests and batch jobs use different queues and pools, so exports cannot starve page loads.
  • Fair scheduling — workers take jobs round-robin across tenants rather than first-in-first-out across the whole queue.
  • Visibility — per-tenant usage metrics, so support can see who is consuming what and customers can see their own limits.

Moving tenants between tiers

If tier is configuration, moving a tenant from pool to silo is a data migration, not a code change. The routing layer looks up the tenant's database or schema; the application connects accordingly. A move copies the tenant's data to the new location, catches up changes, briefly pauses writes for that tenant, switches the routing entry and resumes.

Rehearse the move with a test tenant before you need it. The first time a large customer asks for dedicated infrastructure or a specific region is not the moment to discover that tenant data is scattered across tables without a consistent tenant key.

Data location and tenant-level operations

Isolation choices also determine which operations can be performed per tenant. Customers may ask for their data to be exported, restored from a backup after an accidental deletion, or deleted completely at the end of a contract. In a silo, these are database-level operations. In a pool, they require tooling that can find every row belonging to a tenant across all tables, queues, caches, search indexes and backups.

Design for this early: a consistent tenant key on every table, including link tables and audit logs; documented locations where tenant data may be copied; and tested scripts for export and deletion. Backups complicate deletion, because removing one tenant from a shared backup is rarely practical; retention limits and clear contractual statements usually handle that.

Data-location requirements follow the same logic. If some tenants must keep data in a specific region, the tier model can include region as an attribute, and the routing layer can direct those tenants to infrastructure in that region.

Worked example: hardening a pooled platform

A B2B platform hosts around 900 tenants in one PostgreSQL database, with tenant filtering done only in application code. A code review finds one reporting endpoint that takes the tenant ID from a query parameter.

  1. The endpoint is fixed to use the tenant from the access token; a lint rule forbids reading tenant IDs from request input.
  2. Row-level security policies are added table by table, first in a permissive mode logged by tests, then enforced, with the application role lacking BYPASSRLS.
  3. The connection pooler runs in transaction mode, so the tenant setting is applied with SET LOCAL at the start of each transaction.
  4. Batch exports move to a separate worker pool with per-tenant concurrency of two jobs.
  5. Two tenants with data-residency requirements move to dedicated databases using the tier-migration runbook.

The platform keeps the cost benefits of pooling for most tenants, while one forgotten WHERE clause can no longer expose another customer's data.

Common pitfalls

  • Taking tenant identity from client-controlled input.
  • Relying solely on application-level filtering in a shared database.
  • Row-level security bypassed because the application connects as the table owner.
  • Session-level tenant settings with transaction-mode connection pooling.
  • No quotas, so one tenant's batch work degrades everyone.
  • Tier decided in code, making tenant moves a development project.

FAQ

Is schema-per-tenant always safer than pooling?

It gives clearer boundaries but adds operational work: migrations across many schemas, more database objects and connection management. It is a trade-off, not an upgrade.

Does row-level security hurt performance?

Policies add conditions to queries; with an index on tenant_id the overhead is usually small. Measure with production-like data.

How should tenant IDs appear in metrics?

Only where the number of tenants is bounded and the backend can handle it. Otherwise record per-tenant usage in logs or a dedicated usage store.

Checklist

  • Isolation model and tier criteria documented.
  • Tenant context derived from authenticated identity only.
  • Row-level security enforced with FORCE and without BYPASSRLS for the app role.
  • SET LOCAL per transaction when using transaction pooling.
  • Quotas and separate pools for interactive and batch workloads.
  • Tenant migration between tiers rehearsed.

Primary sources

  1. PostgreSQL documentation — Row Security Policies
  2. PostgreSQL documentation — CREATE POLICY
  3. PgBouncer documentation — Pool modes and features
  4. AWS Well-Architected — SaaS Lens
  5. OWASP API Security Top 10 (2023) — API1: Broken Object Level Authorization

Related research