Connection pooling in Azure Cosmos DB for PostgreSQL
APPLIES TO: Azure Cosmos DB for PostgreSQL (powered by the Citus database extension to PostgreSQL)
Establishing new connections takes time. That works against most applications, which request many short-lived connections. We recommend using a connection pooler, both to reduce idle transactions and reuse existing connections. To learn more, visit our blog post.
You can run your own connection pooler, or use PgBouncer managed by Azure.
Connection poolers such as PgBouncer allow more clients to connect to the coordinator node at once. Applications connect to the pooler, and the pooler relays commands to the destination database.
When clients connect through PgBouncer, the number of connections that can actively run in the database doesn't change. Instead, PgBouncer queues excess connections and runs them when the database is ready.
Azure Cosmos DB for PostgreSQL is now offering a managed instance of PgBouncer for clusters. It supports up to 2,000 simultaneous client connections. Additionally, if a cluster has high availability (HA) enabled, then so does its managed PgBouncer.
To connect through PgBouncer, follow these steps:
- Go to the Connection strings page for your cluster in the Azure portal.
- Select the checkbox next to PgBouncer connection strings. The listed connection strings change.
- Update client applications to connect with the new string.
Azure Cosmos DB for PostgreSQL allows you to configure the managed PgBouncer parameters as coordinator node parameters.
Discover more about the limits and limitations of Azure Cosmos DB for PostgreSQL.