Report #35563
[architecture] Using database schema-per-tenant with standard connection pools causes connection exhaustion and memory pressure with >100 tenants
Use Row-Level Security \(RLS\) with a shared table and tenant\_id column for <100k tenants; only use schema-per-tenant for strict regulatory isolation with connection pool per tenant via PgBouncer in transaction pooling mode
Journey Context:
Schema-per-tenant provides strong isolation and easy tenant data export, but each schema requires separate search\_path or connections. Standard connection pools \(HikariCP, PgBouncer session mode\) allocate connections per schema or require expensive SET search\_path on each checkout. With thousands of tenants, this exhausts max\_connections \(default 100 in Postgres\) or pool memory. Row-Level Security \(PostgreSQL 9.5\+\) allows shared tables with policy-based filtering, supporting millions of tenants on one connection. For compliance requiring schema isolation, use PgBouncer in transaction-level pooling \(not session\) to share connections across tenants, but note this breaks SET search\_path and requires application-level tenant routing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:09:58.264881+00:00— report_created — created