✅ 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
minimumIdleconnections — 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
minimumIdleare 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 overminimumIdlewill start closing afteridleTimeoutpasses without activity.
✅ Key point:
minimumIdlesets the baseline of idle connections always kept alive.idleTimeoutcontrols how long extra idle connections (beyondminimumIdle) can sit unused before being closed.