Java.HikaryCP.What are spring.datasource.hikari.maximum-pool-size and minimum-idle used for?

In HikariCP, the properties spring.datasource.hikari.maximum-pool-size and spring.datasource.hikari.minimum-idle control how many connections the pool maintains and manages. Here’s a detailed breakdown:


🔹 spring.datasource.hikari.maximum-pool-size

Definition:
The maximum number of connections that can exist in the pool (active + idle).

Purpose:
Limits the total number of database connections your app can open at once.

Example:

spring.datasource.hikari.maximum-pool-size=10

➡️ At most 10 connections can be used concurrently.

When it’s reached:

  • If all 10 are in use and a 11th request comes in, it will wait up to connection-timeout milliseconds for a connection to become available.
  • After that, it throws a SQLTransientConnectionException.

🔹 spring.datasource.hikari.minimum-idle

Definition:
The minimum number of idle connections to maintain in the pool.

Purpose:
Ensures a baseline of ready-to-use connections, improving response time under load.

Example:

spring.datasource.hikari.minimum-idle=3

➡️ HikariCP will keep at least 3 idle connections ready, even when load is low.

Important Note:
If minimum-idle > maximum-pool-size, it will be reset to match maximum-pool-size.

✅ TL;DR Comparison

PropertyPurposeAffects
maximum-pool-sizeTotal number of connections (idle + active)Max concurrency
minimum-idleIdle “standby” connections kept in the poolReadiness/performance
This entry was posted in Без рубрики. Bookmark the permalink.

Leave a Reply

Your email address will not be published.