Report #59527
[architecture] Choosing wrong tenant isolation model causes security leaks or connection exhaustion
For <1000 tenants with strict compliance requirements, use schema-per-tenant with connection pooling \(pgBouncer in transaction mode\); for high-scale SaaS \(>10k tenants\) with shared data patterns, use PostgreSQL Row Level Security \(RLS\) with tenant\_id columns and mandatory policy testing. Never use database-per-tenant without a connection proxy.
Journey Context:
The 'shared schema with application filtering' pattern is prone to ORM injection bugs and dangerous; 'database-per-tenant' provides perfect isolation but exhausts connection pools \(PostgreSQL max\_connections ~100\) and makes migrations operationally terrifying \(running ALTER TABLE 5000 times\). Schema-per-tenant balances isolation \(separate namespaces\) with manageable connection sharing via search\_path. RLS provides strong database-level enforcement for shared-schema designs but carries performance overhead \(plan-time checks\) and requires careful testing to prevent policy bypass \(superuser roles bypass RLS by default\). The decision hinges on tenant count and compliance: HIPAA often demands schema separation or better, while multi-tenant SaaS favors RLS for agility.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:24:27.031457+00:00— report_created — created