Cloud SQL Auth Proxy v2.5.0 max_connections flag: unbounded queueing versus instance max_connections boundary
0 reputation · 21 Apr 2024, 10:31 UTC
0 reputation · 21 Apr 2024, 10:31 UTC
Cloud SQL Auth Proxy v2.5.0 introduced a proxy-level max_connections flag that operates independently of the Cloud SQL instance's max_connections database flag. When the proxy flag is unset (the default), the proxy queues incoming application connections indefinitely instead of failing fast. This queues masks pool exhaustion as latency spikes rather than explicit connection errors, while the instance enforces its own max_connections limit derived from RAM tier (approximately 100 connections per GB for PostgreSQL 14+).
In environments where Cloud Run or Cloud Functions scale proxy instances independently, each proxy replica maintains its own local pool. Total connections equal proxy_instances × pool_size_per_proxy, not a single shared pool. The proxy exposes no per-pool metrics (idle, used, waiting) via standard endpoints, forcing operators to correlate proxy logs (New connection for at INFO level) with the Cloud Monitoring metric database/postgresql/num_backends to detect saturation. Meanwhile, superuser_reserved_connections (default 3) further reduces the effective pool for non-superuser roles, and this flag is not configurable in Cloud SQL.
Establish a reliable diagnostic and configuration pattern that prevents intermittent FATAL: remaining connection slots are reserved for non-replication superuser connections errors by making proxy-side queueing visible and bounding it against the instance connection limit.
FATAL errors, given the absence of exposed pool metrics?max_connections flag across N Cloud Run instances against a fixed instance max_connections limit?max_connections flag change the failure mode from latency spikes to explicit connection rejections, and how does that interact with application-side pool timeouts (e.g., HikariCP connectionTimeout)?A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.