CodexBloom - Programming Q&A Platform

Issues with managing connection pool size in Spring Boot when using HikariCP

πŸ‘€ Views: 0 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-06
spring-boot hikaricp postgresql Java

I'm working on a project and hit a roadblock. I'm updating my dependencies and I'm encountering unexpected performance issues in my Spring Boot application, specifically when connecting to my PostgreSQL database using HikariCP. I've configured HikariCP with a maximum pool size of 10, but during peak load, I'm experiencing slow query performance and occasional `SQLTimeoutException`. Here’s how I configured the connection pool in my `application.properties`: ```properties spring.datasource.url=jdbc:postgresql://localhost:5432/mydb spring.datasource.username=myuser spring.datasource.password=mypassword spring.datasource.hikari.maximum-pool-size=10 spring.datasource.hikari.minimum-idle=5 spring.datasource.hikari.idle-timeout=30000 spring.datasource.hikari.connection-timeout=20000 ``` During load testing, I noticed that even with 10 active connections, the application seems to hang sometimes. When I check the database, it appears that connections are being held open longer than expected, which leads to a backlog. I've tried adjusting the `minimum-idle` and `idle-timeout` settings but saw no significant improvement. I also looked at the query performance via `EXPLAIN ANALYZE` in PostgreSQL, and everything seems fine at the database side. The queries are not particularly complex, so I'm wondering if this is related to how HikariCP manages the connections or if there are other tuning parameters I might be overlooking. Has anyone faced similar issues, and what configurations or practices would you recommend for optimizing HikariCP with Spring Boot? Any insights would be appreciated! This is for a microservice running on Ubuntu 20.04. What are your experiences with this? I'm working with Java in a Docker container on Windows 10. Has anyone else encountered this?