Updated on 2023-11-27 GMT+08:00

Configuring Connection Pools

Scenarios

A session-level connection pool is suitable for short connections. A session-level connection pool helps reduce the database load caused by frequent establishment of short connections.

Connection Pool is disabled by default. You can enable a session-level connection pool.

How a Session-Level Connection Pool Works

When your client disconnects from your database, RDS checks whether the connection is idle. If it is, RDS places the connection in the connection pool and retains the connection for a short period of time.

When your client re-initiates a connection, any available connection in the connection pool is used, reducing the overhead of establishing a new connection to the database. If no connections are available in the connection pool, a new connection will be established.

Constraints

  • Only RDS for MySQL 8.0 and 5.7 support the connection pool function.
  • This function is incompatible with Application Lossless and Transparent (ALT). If ALT is enabled, the connection pool becomes invalid.
  • When any of the following operations is performed, the connection is locked until the connection ends. That is, the connection will not be placed in the connection pool for other users to use.
    • Running the PREPARE statement
    • Creating a temporary table
    • Modifying user variables
    • Inserting or querying big data (for example, more than 16 MB)
    • Running the LOCK TABLE statement
    • Executing a multi-statement query (concatenated SQL statements with semicolons, for example, SELECT 1;SELECT 2)
    • Calling a stored procedure

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Click in the upper left corner of the page and choose Databases > Relational Database Service.
  4. On the Instances page, click the primary instance name. The Basic Information page is displayed.
  5. In the navigation pane on the left, choose Database Proxy.
  6. On the displayed page, click Configure next to Connection Pool.
  7. Set Connection Pool to Session level and click OK.

    Figure 1 Configuring connection pool