Java.HikariCP.What is the use of idleTimeout and how can it affect performance?

Purpose:
The idleTimeout property in HikariCP specifies how long an idle connection can stay in the pool before it’s closed. Essentially, it controls when unused connections are retired to reduce resource usage (e.g., DB connections, memory).

Default:
By default, idleTimeout is set to 600,000 ms (10 minutes).

How it affects performance:

  • If idleTimeout is set too low, HikariCP may aggressively close idle connections. This can lead to frequent closing/reopening of connections, causing higher database and application overhead, especially under bursty traffic.
  • If idleTimeout is set too high, the pool may keep many idle connections open unnecessarily, consuming database resources even when those connections aren’t needed, potentially exhausting DB connection limits.

Good practice:
Tune idleTimeout based on the typical idle period of your application’s workload and your database’s connection limits — ensuring you avoid both excessive connection churn and resource wastage.

This entry was posted in Без рубрики. Bookmark the permalink.

Leave a Reply

Your email address will not be published.