Search code examples
postgresqlgoogle-cloud-platformgoogle-cloud-sql

How to increase the connection limit for the Google Cloud SQL Postgres database?


The number of connections for Google Cloud SQL PostgreSQL databases is relatively low. Depending on the plan this is somewhere between 25 and 500, while the limit for MySQL in Google Cloud SQL is between 250 and 4000, reaching 4000 very quickly.

We currently have a number of trial instances for different customers running on Kubernetes and backed by the same Google Cloud SQL Postgres server. Each instance uses a separate set of database, roles and connections (one per service). We've already reached the limit of connections for our plan (50) and we're not even close to getting to the memory or cpu limits. Connection pooling seems not to be an option, because the connections are with different users. I'm wondering now why the limit is so low and if there's a way to increase the limit without having to upgrade to a more expensive plan.


Solution

  • It looks like google just released this as a beta feature. When creating or editing a database instance, you can add a flag called max_connections, where you can enter a new limit between 14 and 262143 connections.

    gcp cloud sql connection limit flag