Cloud SQL Auth Proxy and Cloud Run Application Connection Pools: Which Limit Governs Exhaustion Behavior?
0 reputation · 19 Jun 2020, 21:13 UTC
0 reputation · 19 Jun 2020, 21:13 UTC
A Cloud Run service uses an application-level connection pool (for example, HikariCP with maxPoolSize=20) while the Cloud SQL Auth Proxy sidecar runs with --max_connections=10. Both components enforce a connection ceiling, but the documented interaction between the two limits is not explicit about which one effectively governs backend connection creation under load.
The Auth Proxy acts as a pass-through forwarder; prior to v1.30.0 it had no --max_connections flag at all. When the flag is set lower than the application pool, excess client connections are queued or rejected, yet the proxy’s own metrics are not directly exposed in Cloud Monitoring. Unix-socket mode can multiplex streams, potentially masking exhaustion until the socket’s internal queue fills. The Cloud SQL instance itself also enforces a tier-dependent maximum, which may be lower than either configured limit.
--max_connections differ, which limit determines the point at which new backend connections are refused?34775 reputation · 20 Jun 2020, 03:21 UTC
When the application‑side pool size and the Cloud SQL Auth Proxy --max_connections differ, the first component to reach its ceiling determines when new backend connections are refused. In practice, the lowest of the three limits—the proxy’s --max_connections, the application pool’s maxPoolSize, and the Cloud SQL instance’s tier‑specific max_connections—becomes the bottleneck. If the proxy’s limit is lower than the pool, the proxy will queue or reject connections before they hit the database. If the proxy’s limit is higher, the application pool governs until the instance’s own limit is reached.
--max_connections flag in v1.30.0; earlier versions had no proxy‑side cap.max_connections ceiling that supersedes both proxy and pool limits.In many deployments, developers notice increased latency or connection‑wait times before any database error, indicating the proxy is the active limiter. Conversely, if the pool size is the smallest value, the application will experience “connection pool exhausted” errors from the driver before the proxy ever logs a rejection.
gcloud sql instances describe INSTANCE_NAME --format="value(settings.ipConfiguration.ipv4Enabled)" to confirm the instance’s max_connections value.--debug or --log-level=debug to surface metrics such as proxy_connections_active and proxy_connections_waiting in the container logs.activeConnections and idleConnections). Log these values or export them to Cloud Monitoring.wrk or ab to open more concurrent connections than the proxy limit and observe where the first failures occur.--socket-path=/cloudsql/PROJECT:REGION:INSTANCE) and note any delay in failure symptoms; the numeric threshold should remain unchanged.Could you confirm the Cloud SQL instance’s tier and its configured max_connections value? If that value is lower than either the proxy or the pool, the instance itself becomes the governing limit.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.