According to HikariCP's documentation they mentioned to create fixed size pool for better performance.
minimumIdle:
This property controls the minimum number of idle connections that HikariCP tries to maintain in the pool.If the idle connections dip below this value, HikariCP will make a best effort to add additional connections quickly and efficiently. However, for maximum performance and responsiveness to spike demands, we recommend not setting this value and instead allowing HikariCP to act as a fixed size connection pool. Default: same as
maximumPoolSize
My application usually requires 100 connections and only at a few circumstances reaches 200 connections.
If I create a 200 connection fixed size pool, most of the time 100 connections will be idle.
So which of the following is the best:
- Create connection pool with fixed size. i.e. 200
OR
- Create connection pool by setting
minimumIdle
to 100 andmaximumPoolSize
to 200.
Why the second point is not recommended by HikariCP? I think the second one would be the best for my case.
minimumIdle=100
,maximumPoolSize=200
). However, what I would also recommend is that you re-evaluate whether you truly need even a maximum of 100 connections. Most queries are very quick, so even if threads wait for connections, they typically won't wait long (milliseconds). – Sharisharia