GoogleCloudPlatform / GoogleCloudPlatform/cloud-sql-proxy
Add total connections metric
- Dominant language
- Go
- Stars
- 1.4k
- Forks
- 352
- Avg merge
- 14h 54m
- Merged PRs (30d)
- 5
Description
### Feature Description
Hi,
Following on from the very old issue (https://github.com/GoogleCloudPlatform/cloud-sql-proxy/issues/1871) - connection churn is still a real problem when using cloudsql-proxy & IAM.
I'm hesitant to introduce pgbouncer globally as a mitigation, because it'll be confusing for our devs who are configuring their app pools, and observing their postgres servers (they'll not be in control of the proxy).
This then leads me instead towards a softer approach where i'm able to highlight to people when they have a high amount of connection churn. So for example we want to encourage people to create connection pools with a min+max the same, and keep alive on the connections, in order to mitigate latency.
The current metrics don't enable us to do that, we only have `cloudsqlconn_open_connections` which is the open connections at a point in time. We had an issue today where every 10 minutes 80% of the idle connections were being reconnected (at once) due to an idleTimeout configured, this was subsequently service impacting. This didn't appear in this metric because the same didn't happen at the exact time they were recreated.
I propose adding `cloudsqlconn_total_connections` as an ever incrementing counter, this will enable us to trivially track how many connections people make over a period (thus allowing us to detect sub optimal connection pooling configurations - eg where their min connections are too low, or their idle ttl too high).
### Sample code
_No response_
### Alternatives Considered
_No response_
### Additional Details
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.