Server-side connection pool (PgBouncer)
If your workload involves many short-lived connections or requires frequently creating and terminating connections, use the server-side connection pool to reuse database connections, reduce instance overhead, and control resource consumption.
Overview
The server-side connection pool in AnalyticDB for PostgreSQL is built on PgBouncer. It sits between your application and the database to manage and reuse connections.
-
Connection reuse: Reuses existing connections to avoid the overhead of frequent connection creation, reduce server load, and improve application responsiveness and concurrency.
-
Resource control: Limits the maximum number of client connections and idle time to prevent excessive resource consumption.
Prerequisites
The connection pool is enabled by default for AnalyticDB for PostgreSQL 7.0 instances with minor engine version 7.3.2.6 or later, or 7.4.2.1 or later.
You can view the minor version on the Basic Information page of an instance in the AnalyticDB for PostgreSQL console. If your instance does not meet the required versions, update the minor version of the instance.
Billing
This feature is free of charge.
Usage notes
-
When the connection pool is enabled, audit logs no longer record the original client source address. Do not use the connection pool if you require client source address auditing.
-
The connection pool and direct connections share the total available connections. Plan the allocation accordingly.
-
The default pooling mode is session, where each client session holds one server-side connection. To switch modes, submit a ticket to contact technical support. Supported modes:
-
session: Returns the connection when the session ends.
-
transaction: Returns the connection when the transaction completes.
-
statement: Returns the connection after each statement executes.
-
Connect through PgBouncer
-
Log on to the AnalyticDB for PostgreSQL console. In the upper-left corner of the console, select the region of your instance.
-
In the left-side navigation pane, click Instances and click the instance ID to go to the instance details page.
-
In the Database Connection Information section, use the Private Endpoint to connect to your instance.