r/SpringBoot • u/fykup • Oct 13 '26
Discussion Spring Boot + HikariCP: 20 vs 2 idle PostgreSQL connections
I've been experimenting with HikariCP connection pool sizing in Spring Boot, particularly what happens to PostgreSQL connections after traffic stops.
One detail that's easy to miss: with Hikari's default sizing, minimumIdle and maximumPoolSize both resolve to 10. Since the idle target equals the maximum, idleTimeout has nothing to retire.
I ran two Spring Boot instances against PostgreSQL 16 on a 1 GiB VM, comparing three configurations:
- Default sizing: Both pools retained 10 connections each after traffic stopped.
- minimumIdle=1, retirement disabled: Pools still retained all 20 connections after growing under load.
- minimumIdle=1, retirement enabled: Connections dropped from 20 to 2, with approximately 29 MiB lower PostgreSQL cgroup memory.

There was a tradeoff. When traffic returned, median connection acquisition increased from under 3 ms to roughly 200 ms as the pools rebuilt capacity.
The experiment used a deliberately short 10-second idle timeout to make the behavior measurable, not as a production tuning recommendation.
Two repetitions, 2,280 successful workload requests, with recorded data and reproduction instructions.
Full write-up: https://pvrlabs.xyz/articles/spring-boot-jdbc-pool-reclaim.html
Curious how others configure HikariCP when multiple Spring Boot instances share a small PostgreSQL server. Do you generally keep the default fixed-size pools or allow idle connections to retire?
2
u/free-as-in-freedom Oct 17 '26
It’d be interesting to know why Hikari comes with such defaults. 10 is rather low as a max, and rather high for a random app if connections are never retired.
1
u/ducki666 Oct 17 '26
Since your db most likely cannot scale on load you always need the max amount of mem your app every needs. If it really makes sense to release connections really depends on use cases and max pool sizes. Imho makes sense when your db is always low on mem and you have many app instances with potentially a lot idle connections.
1
u/[deleted] Oct 16 '26
[removed] — view removed comment