All Products
Search
Document Center

ApsaraDB for OceanBase:Configuration of a database connection pool

Last Updated:Aug 01, 2023

This topic describes the configuration parameters of a connection pool, including the ZDAL, Druid, DBCP, C3P0, and JDBC parameters.

Data source parameters

Parameter type

Description

ZDAL parameter

Druid parameter

DBCP parameter

C3P0 parameter

Number of initial connections

The number of connections established during initialization of the connection pool.

prefill=true, initialized to minConn

initialSize(0)

initialSize(0)

initialPoolSize(3)

Minimum number of connections

The minimum number of available connections retained for the connection pool.

minConn(0)

minIdle(0)

minIdle(0)

minPoolSize(3)

Maximum number of connections

The maximum number of available connections. If the number of connections in the connection pool exceeds this number, an exception is returned, indicating that the connection pool is full.

maxConn(10)

maxActive(8)

maxActive(8)

maxActive(8)

Connection idle timeout period

The period of connection idle time that the connection pool waits for before it disconnects the connection. MySQL disconnects a connection that has been idle for 8 hours by default. A connection becomes a dirty one during the active/standby switchover. Without this mechanism, a request may fail. For ApsaraDB for OceanBase, the default SLB timeout period is 15 minutes. You can set it to 12 minutes.

idleTimeoutMinutes(30min)

minEvictableIdleTimeMillis(30min)

This parameter takes effect only when timeBetweenEvictionRunsMillis(-1) > 0 is set. This parameter specifies the asynchronous check cycle.

maxIdleTime (0 indicates no timeout.)

Timeout period for obtaining a connection from the connection pool

If the value is too large, the application response will be very slow when the connection pool is full.

blockingTimeoutMillis(500ms)

maxWait (-1 indicates no timeout.)

maxWaitMillis (-1 indicates no timeout.)

checkoutTimeout (0 indicates no timeout.)

Timeout period before destroying a connection

If a connection is not returned to the connection pool after this period, the connection is directly destroyed. This mechanism prevents connection leakage but restricts the duration in which a connection can be used by a transaction.

None

removeAbandonedTimeoutMillis(300s)

removeAbandonedTimeout(300s)

None

JDBC parameters

The following JDBC parameters are important and must be configured. You can specify these parameters in the connection properties of the connection pool or the JDBC URL. The following table describes the parameters.

Parameter

Description

Default value

socketTimeout

The network timeout period for a read request. The default value is 0, which means that the default timeout period of the operating system is used.

5000ms

connectTimeout

The timeout period for establishing a connection. The default value is 0, which indicates that the default timeout period of the operating system is used.

500ms

Recommendations on connection pool settings

  • You can retain a minimum of two connections for the console and adjust the configuration based on the business concurrency and transaction time.

  • We recommend that you set the idle connection timeout period to 30 minutes.

    By default, MySQL disconnects a connection that has been idle for 8 hours, which cannot be sensed by the client. This results in dirty connections. The connection pool can check whether a connection is alive through mechanisms such as heartbeats or testOnBorrow. When the connection has been idle for this period, the connection is disconnected.