Report #11378
[gotcha] Cloud SQL 'too many connections' errors when scaling Cloud Run instances despite low SQL max\_connections
Set Cloud Run --concurrency=1 \(disable concurrency\) or use connection pooling \(PgBouncer/Cloud SQL Proxy with proper max connections\) and calculate: max\_connections >= \(Cloud Run max instances \* concurrency \* connections\_per\_request\)
Journey Context:
Cloud Run services default to concurrency=80 \(80 simultaneous requests per instance\). If each request opens a direct database connection without pooling, you exhaust Cloud SQL's max\_connections \(default 100\) instantly. With 2 instances × 80 concurrency = 160 potential connections. The Cloud SQL Auth Proxy multiplexes but doesn't eliminate application-level connection leaks. The fix is either: \(1\) Disable Cloud Run concurrency \(--concurrency=1\) so each instance handles one request at a time \(simpler math: max\_instances × 1 × pool\_size\), or \(2\) Implement strict server-side connection pooling \(PgBouncer or Cloud SQL Proxy with max\_connections configured\) and calculate headroom: max\_connections must be ≥ \(max\_run\_instances × run\_concurrency × avg\_connections\_per\_request\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T13:13:22.719414+00:00— report_created — created