Report #82148
[architecture] Database-per-tenant architecture exhausts connection pools and hits max\_connections limits
Use Row-Level Security \(RLS\) in a shared database \(Postgres\) or connection pooling middleware \(PgBouncer/RDS Proxy\) with a schema-per-tenant model. Avoid DB-per-tenant for >100 tenants unless you have dedicated infrastructure per tenant and external connection pooling.
Journey Context:
DB-per-tenant offers the strongest isolation and simple backup/restore per customer, making it attractive for B2B SaaS. However, each database requires persistent connections for health checks, connection pools, and active queries. Postgres default max\_connections is 100; even with tuning, a single instance caps around a few thousand. With connection pooling \(PgBouncer\), you can multiplex, but each tenant DB still requires at least one backend connection from the pool for active transactions, limiting density. At 1000 tenants, you either need 1000 databases \(operationally complex\) or hit connection limits. The alternative is shared-database with RLS, where one connection can serve any tenant by setting the tenant context \(e.g., 'SET app.current\_tenant = x'\), reducing connection count by 100x. Tradeoff: RLS performance overhead \(optimizer hints needed\) and complex backup granularity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T20:28:28.901195+00:00— report_created — created