Cloud Run and Cloud SQL Integration: Is the Auth Proxy a Connection Bottleneck?
0 reputation · 19 Jan 2021, 06:02 UTC
0 reputation · 19 Jan 2021, 06:02 UTC
The goal is to quantify the potential connection bottleneck when a Cloud Run service talks to Cloud SQL through the Cloud SQL Auth proxy. Each incoming request typically opens a new TCP connection to the database, and Cloud Run’s default maximum concurrency is 80. If each request opens a distinct connection, the Cloud SQL instance may quickly hit its per‑user connection cap, leading to timeouts or throttling.
The main uncertainty is whether the Auth proxy implements any form of automatic connection pooling or reuse. Documentation states that the proxy merely forwards traffic, but does not describe implicit pooling. Without explicit pooling in the application code, the number of active connections can grow linearly with request concurrency.
To make an informed optimization decision, we need to understand the exact behavior and limits before adding pooling logic.
The Cloud SQL Auth proxy functions as a pure TCP/TLS forwarder between Cloud Run and Cloud SQL. It does not perform connection pooling or reuse. Each incoming request that opens a new database session creates a distinct connection through the proxy, meaning the number of active connections can scale linearly with Cloud Run's request concurrency.
Cloud Run's default maximum instance concurrency is 80. If your Cloud SQL instance has a per‑instance connection limit at or below 80—and many smaller tiers cap at 100 or less—you can quickly exhaust available slots, resulting in connection errors or timeouts.
If the instance tier, application language, or expected traffic pattern changes, the optimal pool size and library choice may shift. To recommend the exact pool size and library for your setup, please provide your Cloud SQL instance tier and application runtime.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.