GCP Cloud Run service returns '504 Gateway Timeout' when connecting to Cloud SQL with connection pooling
Quick question that's been bugging me - I'm working with a '504 Gateway Timeout' behavior when my Cloud Run service tries to connect to Cloud SQL using connection pooling... My Cloud Run service is using Node.js 14 with the `@google-cloud/sqlcommenter` package for tracing. I've configured the connection pool with a maximum of 10 connections, but it seems that during peak traffic, requests are timing out. Hereโs a snippet of the code for the connection setup: ```javascript const sql = require('@google-cloud/sqlcommenter'); const { Pool } = require('pg'); const pool = new Pool({ user: 'my-user', host: '/cloudsql/my-project:us-central1:my-instance', database: 'my-database', password: 'my-password', port: 5432, max: 10, idleTimeoutMillis: 30000, }); const executeQuery = async (query) => { const client = await pool.connect(); try { const res = await client.query(query); return res; } finally { client.release(); } }; ``` Iโve tried increasing the timeout settings in Cloud Run, but it didnโt seem to help. I also looked into the connection pooling settings and verified that the maximum number of connections in Cloud SQL is set high enough to accommodate my needs. Additionally, I ensured that the Cloud SQL connection is authorized properly in the IAM settings. To debug further, I enabled detailed logging, and I see instances where the requests are reaching the Cloud SQL instance but not returning within the expected timeframe. The logs also indicate that some requests are failing before they even hit the database, leading me to believe the scenario might be with the connection pool exhaustion. Is there a recommended practice for handling connection pooling in Cloud Run, or should I consider alternative approaches to manage database connections under load? Any insights would be appreciated! I'm working on a CLI tool that needs to handle this. Thanks in advance! This is for a service running on Ubuntu 20.04. What's the correct way to implement this? I recently upgraded to Javascript LTS.