HikariCP important parameter configuration

Outline

HikariCP is the default database connection pool Spring Framework 5.0, thanks to his performance. However, if configured incorrectly, the database connection pool may also affect system performance due to.

Important parameters

  • maximum-pool-size
  • minimum-idle
  • pool-name
  • auto-commit
  • idle-timeout
  • max-lifetime
  • connection-timeout

Initialization process and create a logical connection

When HikariCP initialization time, adds the connections to the pool until it reaches the number of minimum-idle, in which case to maintain this state. When a new connection request pool, HikariCP returns a proxy connection. When the connection are in use at this time if there is a new connection request pool, HikariCP will continue until the new connection maximun-pool-size.

maximum-pool-size

Pool maximum number of connections (including idle and connected in use). The default value is the maximum number of connections 10, application of this general estimate, a late obtain a maximum average value based on the monitoring. You know, the biggest connection is not possible, a connection consumes bandwidth and storage systems. However, when no free connection and the connection pool has reached its maximum value, the new connection request pool (HikariPool # getConnection) it will be blocked until connectionTimeout(ms), after a timeout throws SQLException.

minimum-idle

The minimum number of idle connection pool. The default value is 10, the pool is less than the maximum number of connections, and generally in accordance with an average value in the connection database system in most cases. Hikari will as far as possible, as quickly as possible to maintain the number of idle connections on this number. If in order to obtain optimum performance and responsiveness of peak demand, we might as well let him be consistent and the maximum number of connections, making the database connection pool HikariCP become a fixed size.

pool-name

The name of the connection pool. Usually appear in the log and JMX console. Default value: auto-genenrated. Recommended to take an appropriate name for easy monitoring.

auto-commit

Submit it automatically returns to the connection pool. The default value is true. Generally it is necessary to automatically submit things on a connection's. If false, then you need to manually submit the application layer things.

idle-timeout

free time. Only take effect until the minimum-idle is less than the maximum-poop-size time. The default value of 10 minutes. Adjusted according to the actual situation of the application, the application for peak reached some intermittent flow, generally need to consider more than the set time interval, prevent the creation of a database connection speeds slow down the application.

max-lifetime

Connection maximum lifetime connections in the pool. When the connection is idle consistent, the database may take the initiative to disconnect. In order to prevent a large number of idle connections at the same time because the idle timeout policy database party disconnects (avalanche will be appreciated that the connection) will generally be "idle time" seconds less than the value of the database, so that these disconnected after, HikariCP can quickly create a new connection.

connection-timeout

Connection timeout. The default value is 30s, the minimum time-out time may be received as 250ms. However, the connection pool can also customize request timeout (com.zaxxer.hikari.pool.HikariPool # getConnection (long)).

Guess you like

Origin www.cnblogs.com/fireround/p/11701369.html