Server-side connection pool (PgBouncer)

Updated at:
Copy as MD

If your workload involves a large number of short-lived connections or requires you to frequently create and terminate connections, use the server-side connection pool feature. This feature reuses database connections to significantly reduce the performance impact on your instance, and helps control the server load and resource consumption from creating and terminating connections.

Feature overview

The server-side connection pool feature in AnalyticDB for PostgreSQL is based on the open-source component PgBouncer. It acts as middleware between your application and the database to manage and reuse database connections.

  • Connection reuse: The connection pool prioritizes reusing existing connections. This avoids the performance overhead of frequently creating and terminating connections, significantly reduces the database server load, and improves application responsiveness and concurrency.

  • Resource control: The connection pool allows you to limit parameters such as the maximum number of client connections and maximum idle time. This prevents an excessive number of connections from consuming system resources.

Prerequisites

The server-side connection pool feature is enabled by default for AnalyticDB for PostgreSQL 7.0 instances that have a minor engine version of 7.3.2.6 or later, or 7.4.2.1 or later.

Note

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 server-side connection pool is enabled, audit logs no longer record the original client's source address. If you need to audit client source addresses, do not use the server-side connection pool.

  • The connection pool and direct database connections share the total number of available connections. Plan the connection allocation between them accordingly.

  • By default, the server-side connection pool uses session mode. In this mode, one upstream session occupies one server-side connection. To use other modes, submit a ticket to contact technical support. The supported pooling modes are as follows:

    • session: The connection is returned to the pool when the session ends.

    • transaction: The connection is returned to the pool when the transaction is complete.

    • statement: The connection is returned to the pool after a statement is executed.

Procedure

  1. Log on to the AnalyticDB for PostgreSQL console. In the upper-left corner of the console, select the region where your instance is located.

  2. In the navigation pane on the left, click Instances, and then click the ID of the target instance to go to the instance details page.

  3. In the Database Connection Information section, use the Private Endpoint to connect to your instance.