Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HikariCP: maxLifetime and idleTimeout with fixed-size pool

Tags:

hikaricp

I would like to know how maxLifetime and idleTimeout settings behave in a fixed-size Hikari pool.

Under which circumstances are connections being retired from a fixed-size pool? And since the pool is fixed-size, is a new connection immediately created after a retirement?

Furthermore, what happens if the database itself (MySQL in my case) closes a connection after the database wait timeout is reached (in case the maxLifetime is not less than the DB timeout)?

Will the connection be retired from the fixed-size pool and another one will be immediately created?

Thanks!

like image 250
mike Avatar asked Jan 04 '16 15:01

mike


1 Answers

HikariCP is retiring connections when connection reaches its maxLifetime or connection remains idle in pool for idleTimeout.

HikariCP housekeeper runs every 30s by default. to maintain 'minimumIdle' connections, it may add new connections or retire idle connections (not borrowed by client for idleTimeout millis).

you must set maxLifetime few mins less than (mysql)wait_timeout to avoid broken connection / exceptions.

HikariCP may add new connections in housekeeper or when client attempts to borrow connection. so it may not add connections immediately after retiring them.

like image 76
Nitin Avatar answered Sep 30 '22 19:09

Nitin