Managed Connection Pooling overview
This page describes what Managed Connection Pooling is and how to use it to optimizedatabase connection management for your Cloud SQL instances using pooling.
Managed Connection Pooling lets you scale your workloads by optimizing resource useand connection latency for your Cloud SQL instances using pooling.Managed Connection Pooling dynamically assigns server connections toincoming requests when possible. This provides significant performanceimprovements, especially for scaled connections, by absorbing suddenconnection spikes and reusing existing database connections. Instead ofconnecting to a particular database, Managed Connection Pooling connects to acluster of poolers, which provide shorter connection times and scalabilityfor your workloads.
Each pool is associated with a unique database and user. Once a client isauthenticated, the pool attempts to reuse one of the idle serverconnections within the pool to connect the database to the server. If a serverconnection isn't available, then it creates a new server connection in the poolto connect the database. The number of poolers used is based on the number ofvCPU cores of your instance.
While you can use Managed Connection Pooling for any transactional workloads,it provides the most throughput and latency benefit to applicationsthat contain short-lived connections, or applications that result in aconnection surge.
For long-lived connections, the connection performance usingManaged Connection Pooling can be slightly lower than when using a directconnection. In this case, Managed Connection Pooling provides connectionscaling when the number of connections is very high. However, forapplications that typically establish long-lived connections, you mightwant to avoid using connection pooling.
You can use Identity and Access Management to secure connections, depending on theport. For more information on how IAM works inCloud SQL and its restrictions, seeIAM authentication.
For more information about enabling Managed Connection Pooling, seeConfigure Managed Connection Pooling.
Requirements
To use Managed Connection Pooling, your instance must meet the following requirements:
- Your instance must be a Cloud SQL Enterprise Plus edition instance.
- You must be connected to your instance using only a direct connection orthe Cloud SQL Auth Proxy.
- Your instance must be set up forprivate service access,use public IP, or be a new instance withPrivate Service Connect enabled.
- Your instance must use the newCloud SQL network architecture.
- Managed Connection Pooling requires a minimum maintenance version number of
POSTGRES_$version.R20250727.00_14. For more information about performing self-service maintenance, seePerform self-service maintenance.
Ports used by Managed Connection Pooling for Cloud SQL instances
When you enable Managed Connection Pooling, the ports used by Cloud SQL instancesto serve database traffic change. You can use Identity and Access Management to secureconnections, depending on the port.
The ports used by Managed Connection Pooling and their available IAMoptions are as follows:
TCP port 5432: used for direct connections by the Postgres databaseserver. This is the default port number fordirectly connecting using the psql client.
TCP port 6432: used for direct connections by the Managed Connection Poolingserver. To connect using this port, specify
psql -p 6432whendirectly connecting using the psql client.You can use anyIAM authentication optionwhen using this port.
TCP port 3307: used for the Cloud SQL Auth Proxy only connections by aManaged Connection Pooling server. When you use Cloud SQL Auth Proxy to connect toManaged Connection Pooling, this port number is configured with the Cloud SQL Auth Proxy clientand can't be changed.
You can use anyIAM authentication option,orautomatic IAM database authenticationwith this port.
Pooling options
Managed Connection Pooling lets you manage how connections are pooled using thepool_mode parameter. You can use the following pooling options:
transaction(default): pools connections at a transaction level.Connections are returned to the pool after each transaction completes.Cloud SQL recommends usingtransactionpooling mode forshort-lived connections.session: pools connections at a session level. Each session uses adedicated server connection that maintains a session state. This reducespooling efficiency. When a client disconnects, the server returnsto the connection pool.
Advanced configuration options
You cancustomize Managed Connection Poolingby using the following configuration options:
| Configuration name | Description |
|---|---|
max_pool_size | The maximum number of server connections allowed to a database and user pair in each connection pool. The default value is 50 connections. |
min_pool_size | The minimum number of server connections available at any time in each connection pool. If the number of server connections is less than the min_pool_size, then this setting adds more server connections to the pool. This helps manage sudden increases in database load after periods of inacitivty and ensures connections are available and ready to use.The default value is 0 connections. |
max_client_connections | The maximum number of connections allowed for your instance when using Managed Connection Pooling. The default value is 5,000 connections. |
max_prepared_statements | The maximum number of protocol-level named prepared statements supported intransaction pooling mode.Setting this option to 0 disables prepared statement support. For optimal performance, this value should exceed the number of commonly used prepared in your database. A high number of prepared statements in Managed Connection Pooling cmay cause an increase in memory usage. The default value is 0 statements. |
client_connection_idle_timeout | The time that a client-connection remains idle before it times out. This value can range from 0 to 2,147,483 seconds, and the default value is 0 seconds. |
server_connection_idle_timeout | The time that a server connection remains idle before it times out. This value can range from 0 to 2,147,483 seconds, and the default value is 600 seconds. |
query_wait_timeout | The time that a query waits for a server connection in a pool before it times out. Setting this option to 0 disables it, which allows indefinite client queuing. Enabling this option prevents unresponsive servers from holding up connections. This value can range from 0 to 2,147,483 seconds, and the default value is 120 seconds. |
ignore_startup_parameters | The parameters you want ignored, that aren't tracked in the Managed Connection Pooling startup packets by default. |
server_lifetime | The maximum time a server connection is unused before Managed Connection Pooling closes it. If the value is set to 0 seconds, then the connection is immediately closed after use. The default value is 3600 seconds. |
Limitations
When using Managed Connection Pooling withyour Cloud SQL Enterprise Plus edition instances, consider these limitations:
- Enabling Managed Connection Pooling on an existing instance resultsin a database restart.
- When you use the Cloud SQL API to enable, disable, or configureManaged Connection Pooling, the
instance.updateAPI can't contain any otherinstance configuration updates. - Managed Connection Pooling can only be used with Cloud SQL Auth Proxy version 2.15.2 and later.
- If you're using the Cloud SQL Go Language Connector, then we recommenda minimum Go version of
1.24. If you use Go version 1.23 or earlier, thenyou might experience limitations on performance when using Managed Connection Pooling. If you're using Managed Connection Pooling in
transactionpooling mode, thenthe following SQL features aren't supported:SET/RESETLISTENWITH HOLD CURSORPREPARE/DEALLOCATEPRESERVE/DELETE ROWtemp tablesLOAD- Session-level advisory locks
If you're using theasyncpg database interface libraryfor Managed Connection Pooling pooler on port 3307 and 6432, then you must update the
max_prepared_statementsto a value larger than 0 to enable support for prepared statements in Managed Connection Pooling pooler.If you're using Cloud SQL for PostgreSQL version 17, then the
sslnegotiation=directoption isn't supported.Client IP tracking isn't supported with Managed Connection Pooling. If you enablestore client IP addresses inquery insights,then client IP addresses are displayed as
localinstead of the IP addressitself.
Server connections used by Managed Connection Pooling
Themax_connections database configuration limits the maximum number ofserver connections a pooler in Managed Connection Pooling can use.Cloud SQL recommends adjusting this value based on your instance'sworkload requirements and the database instance size. During peak load,the number of connections for authentication can become very high.
If you're using the defaultmax_pool_size of 50 pools on your instance, thenwe recommend reserving at least 15 server connections per CPU forManaged Connection Pooling when you set themax_connections flag for your database.For more information about themax_connections flag, seeMaximum concurrent connections.To modify themax_connections flag for your instance,seeConfigure database flags.
What's next
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-11-24 UTC.