Hi @rgrzesk
“timeout exceeded when trying to connect” comes from pg-pool’s acquisition timeout, so the pool never handed out a client within DB_POSTGRESDB_CONNECTION_TIMEOUT, rather than the Cloud SQL socket being unreachable. DB_POSTGRESDB_POOL_SIZE defaults to 2, and on a single Cloud Run instance the startup queries plus incoming traffic queue behind those two connections, which is why the root endpoint stayed 200 while the DB-backed calls went 500. Raise both on the revision:
Then cap Cloud Run container concurrency to roughly what the pool can serve (10 to 20), so a spike can’t outrun it again. Cloud Run allows 100 connections per instance to Cloud SQL, so 10 stays well inside that.
Thanks! I will tune the CloudRun this way.
However, what worries me - it just happened all of a sudden and the instance is up from 6 months, so far working without any issues.
A pg-pool acquisition timeout tells you that no client became available before the deadline. It does not prove the pool was too small. Because this happened once after six stable months, raising the pool may only move pressure to Cloud SQL.
Line up the affected revision with the Cloud SQL connection graph and the Cloud Run startup log for that timestamp. If both existing connections were busy while requests queued, a larger pool or lower container concurrency is reasonable. If new connections were timing out, the pool size is not the root cause.
Change one limit at a time and keep the previous value recorded. Otherwise the next incident will not tell you which change helped.