✅ Does the pool always keep minimumIdle
connections, and are connections above minimumIdle
closed after idleTimeout
?
Answer:
Yes — that’s exactly how it works:
🔹 HikariCP’s idle connection management works like this:
- The pool tries to maintain at least
minimumIdle
connections — even if they sit idle for longer thanidleTimeout
, they’re not closed as long as the total number of idle connections ≤minimumIdle
. - Any idle connections above
minimumIdle
are considered “excess idle connections.” If they stay unused longer thanidleTimeout
, they will be closed by the pool.
🔹 What this means practically:
- If your pool has
minimumIdle=5
, the pool will keep at least 5 idle connections alive indefinitely (or until demand increases). - If demand causes the pool to grow beyond
minimumIdle
(e.g., up tomaximumPoolSize=20
), and then traffic drops off, the extra connections overminimumIdle
will start closing afteridleTimeout
passes without activity.
✅ Key point:
minimumIdle
sets the baseline of idle connections always kept alive.idleTimeout
controls how long extra idle connections (beyondminimumIdle
) can sit unused before being closed.