This topic describes the configuration parameters of a connection pool, including ZDAL parameters, Druid parameters, DBCP parameters, c3p0 parameters, and JDBC parameters.
Data source configuration parameters
| Parameter definition | 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 OceanBase Database deployed in the cloud, 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 configuration parameters
The following JDBC parameters are important and must be configured. These parameters can be specified in the connection properties of the connection pool or in the JDBC URL. The table below provides descriptions of the parameters.
| Parameter | Description |
|---|---|
| socketTimeout | The network socket timeout period, in ms. The value 0 specifies not to set a timeout period. You can also set the system variable max_statement_time to limit the query time. Default value: 0 (standard). |
| connectTimeout | The connection timeout period, in ms. The value 0 specifies not to set a timeout period. Default value: 30000. |
Suggestions 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 duration.
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.