download

One big tenant slows 200 others. How do you isolate them?

System design~15 minReviewed 3 Dec 2026Free · No sign-in

Question

Your multi-tenant SaaS API shares 1 PostgreSQL connection pool (60 connections) and one worker queue across 1 enterprise tenant (T-big) and 200 SMB tenants.

Normally, all 200 SMBs combined use 18 connections (45 ms p99), and T-big uses 6 connections. At 09:00, T-big starts a 10x bulk export demanding 60 connections, and SMB requests start timing out.

  1. Why did T-big starve the 200 SMBs, and what changes if you cap any single tenant at 20% of the shared pool?
  2. Compare Silo, Pool, and Bridge isolation models here, and add queue, cache, and database Row-Level Security safeguards.
Show hints (3)
  1. "COMPUTE POOL CAP"

    Take 20% of 60 connections (12). Subtract 12 from 60 to see how many connections stay available for the 200 SMB tenants.

  2. "COMPARE ISOLATION TIERS"

    Giving all 200 tiny SMBs separate databases costs too much. What if SMBs share a capped pool while T-big gets a dedicated silo?

  3. "ISOLATE CACHE AND ROWS"

    Namespace every cache key with tenant_id, split bulk exports onto their own worker queue, and enable PostgreSQL Row-Level Security.

Show checked explanation

Without per-tenant limits, T-big's 60-connection burst fills the entire shared pool and leaves 0 slots for SMBs. Capping any tenant at 20% (12 connections) leaves 48 connections for SMBs (30 spare above their 18-connection load). Use a Bridge model: keep SMBs on a capped pool, move T-big to a dedicated DB/worker silo, prefix cache keys, and enforce PostgreSQL Row-Level Security.

"SOLUTION · PYTHON"
POOL = 60
CAP = int(POOL * 0.20)  # 12 connections max per tenant
REQS = [("T-big", 60)] + [(f"smb-{i}", 1) for i in range(18)]


def allocate(cap):
    used, big, smbs = 0, 0, 0
    for tenant, need in REQS:
        allowed = need if cap is None else min(need, cap)
        take = min(allowed, POOL - used)
        used += take
        big += take if tenant == "T-big" else 0
        smbs += take if tenant != "T-big" else 0
    return big, smbs, 18 - smbs, POOL - used


for name, cap in (("unbounded", None), ("cap_20pct", CAP)):
    big, smb, wait, free = allocate(cap)
    print(f"{name:9} T-big={big:2d} SMBs={smb:2d} queued={wait:2d}"
          f" free={free:2d}")
"OUTPUT"
unbounded T-big=60 SMBs= 0 queued=18 free= 0
cap_20pct T-big=12 SMBs=18 queued= 0 free=30

Author-checked on CPython 3.12.10: ran the 60-connection pool bulkhead simulation, checked capacity and headroom math, and tested per-tenant token-bucket throttling and cache-key namespacing. Checked by an editor other than the author.

Walkthrough

This is the classic noisy-neighbor failure. At 09:00, T-big's 10x export (6 * 10 = 60 connections) plus SMB traffic (18 connections) demands 78 connections from a 60-connection pool. Because the pool and worker queue are FIFO and unbounded, T-big grabs all 60 slots and starves all 200 SMBs (queued=18).

First, cap blast radius inside the shared tier. Set a per-tenant bulkhead cap of 20% (12 connections) and a per-tenant token bucket at the API gateway. Excess T-big requests fail fast with HTTP 429 and Retry-After (or move to an async export queue). SMBs keep 60 - 12 = 48 connections, leaving 30 spare connections above their 18-connection demand.

Next, pick the right SaaS tenancy model:

ModelCompute & DB layoutNoisy-neighbor riskCost for 201 tenants
PoolShared pool + quotas/bulkheadsMedium (contained by caps)Lowest
SiloDedicated DB & queue per tenantNoneHighest (201 clusters)
BridgeDedicated silo for T-big, capped pool for 200 SMBsLow for SMBs, none for T-bigBalanced

Bridge fits this customer mix best. Running 201 separate clusters wastes money on small SMBs, while sharing one database with an enterprise exporter risks repeated incidents. Give T-big a dedicated database and export worker pool funded by its enterprise tier, and keep the 200 SMBs in a pooled tier with fair-share caps.

Close the remaining shared-layer leaks:

  1. Separate workload queues: Route heavy bulk exports to a low-priority background queue with per-tenant fair-share scheduling, never the interactive API queue.
  2. Tenant-prefixed cache keys: Format every Redis key as tenant:{tenant_id}:resource:{id} and enforce per-tenant cache quotas so T-big cannot evict SMB hot keys or leak cached reports.
  3. PostgreSQL Row-Level Security (RLS): Run ALTER TABLE ... ENABLE and FORCE ROW LEVEL SECURITY on each tenant table, and connect as a role without SUPERUSER or BYPASSRLS. Set SET LOCAL app.tenant_id = ... inside each transaction so PostgreSQL blocks cross-tenant access even if a query drops WHERE tenant_id = ?.

Common mistakes

  • Raising the shared pool from 60 to 200 connections without per-tenant caps. T-big still fills the larger pool during heavier exports and crashes PostgreSQL with connection overhead.
  • Building 201 dedicated silos for 200 small SMBs. Idle cluster costs, schema migrations, and operational work scale linearly with every tiny customer.
  • Applying only an API rate limit while sharing one Redis keyspace (report:42) or one export queue. One tenant can still evict cache entries or clog background workers.
  • Connecting as a SUPERUSER or BYPASSRLS role, which always bypasses PostgreSQL RLS even with FORCE ROW LEVEL SECURITY. Running as the table owner also bypasses RLS unless FORCE ROW LEVEL SECURITY is enabled on the table.

Follow-up questions

  • "How do you prevent connection-pool tenant context from leaking between requests in PgBouncer?" With transaction pooling, never use session-level SET app.tenant_id. Always run SET LOCAL app.tenant_id = ... inside an explicit transaction block so PostgreSQL clears the setting automatically on COMMIT or ROLLBACK before the connection returns to the pool.
  • "What if one of the 200 SMBs grows 50x next year and becomes a noisy neighbor too?" Track per-tenant CPU, DB time, and queue depth metrics so you spot growth early. Because the Bridge model uses the same schema and tenant router, you can migrate that growing tenant into its own cell or silo without changing application code.
  • "Why does fair-share queuing beat a single FIFO queue for background exports?" In one FIFO queue, 10,000 export jobs from T-big sit ahead of 5 small SMB jobs. Per-tenant virtual queues (or deficit round-robin) give every active tenant turns, so SMB jobs finish in seconds even while T-big drains a huge backlog.

What a strong answer covers

Quantifies pool starvation (60/60) and shows how a 20% (12-connection) cap preserves 48 slots (30 spare) for SMBs. Compares Silo, Pool, and Bridge cleanly, and pairs per-tenant quotas and separate export queues with tenant-prefixed cache keys and PostgreSQL RLS.

Open in interactive practice deck →

Original OfferVibe question. Azure Architecture: Noisy Neighbor Antipattern · AWS SaaS Lens: Silo, Pool, and Bridge Models · Azure Architecture: Bulkhead Pattern · PostgreSQL: Row Security Policies.
© 2026 OfferVibe · Text CC BY-NC-SA 4.0 · code MITFree to share and adapt with credit, not for commercial use. Code samples are free for any use.