Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hikari CP maxLifetime / idleTimeout

Tags:

hikaricp

Hikari CP Version : 2.7.4

This is actually not an issue but some doubts. a) maxLifetime : retires the connection after 30 mins. Will it also create a new connection automatically at the time of killing it or it waits for a new request and then creates a new connectios? considering pool has more than minIdle.

b) idleTimeout : it will drop after 10 mins of inactivity? but 10mins is too high. is it ok if i mark it as 10s(10 is min as seen from code) as otherwise there will always be connections higher than min-connections?

ALso when does the connetion is mark as idle?

like image 690
Ankit Bansal Avatar asked Jul 23 '18 16:07

Ankit Bansal


People also ask

What is idleTimeout in Hikari?

// idleTimeout is the maximum amount of time a connection can sit in the pool. Connections that. // sit idle for this many milliseconds are retried if minimumIdle is exceeded. config. setIdleTimeout(600000); // 10 minutes.

What is maxLifetime in Hikari?

// maxLifetime is the maximum possible lifetime of a connection in the pool. Connections that. // live longer than this many milliseconds will be closed and reestablished between uses. This. // value should be several minutes shorter than the database's timeout value to avoid unexpected.

What is Hikari CP?

"HikariCP is solid high-performance JDBC connection pool. A connection pool is a cache of database connections maintained so that the connections can be reused when future requests to the database are required.

What is Hikari maximum pool size?

The maximumPoolSize sets the maximum size of connections in HikariCP, in this example the connection limit will be 25. The minimumIdle sets the minimum number of pending connections in the queue to be used. The idleTimeout is the time the connection can be queued.


1 Answers

The Hikari housekeeper runs every 30s, which closes any connections that are not in use and are older than maxLifetime. If there are more than minimumIdle number of connections the housekeeper will close connections that have been idle for longer than idleTimeout.

If while your app is running there are no free connections it will create another connection for you unless its reached maximumPoolSize where you'll need to wait for one to be free.

Creating a new connection has an overhead, by pooling the connections we save that connection time from happening everytime, so by reducing this down to 10s you'll be adding a lot more overhead in comparison to every 10min.

For more info: https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby

like image 92
Alex Avatar answered Oct 13 '22 11:10

Alex