Best practices for Spring Boot connection pool configuration Best practices for Spring Boot connection pool configuration spring spring

Best practices for Spring Boot connection pool configuration


@aliaksei-stadnik 20 req/sec is, in the grand scheme of things, pretty low. So, I wouldn't be overly concerned about pool tuning; more important is to focus on query performance. The lower your query times, the more requests you can handle with a smaller number of connections.

We always recommend running HikariCP as a fixed-size pool for best performance (leaving minimumIdle and idleTimeout unset). The maximumPoolSize is probably the key number you need to tune, and as the referenced link above says, it depends primarily on the number of CPU cores that your database server has.

With an average query time of 2ms, even a single connection could handle ~500 req/sec, and an average query time of 10ms would yield ~100 req/sec per connection. However, at the cost of a single request possibly waiting up to one second to be serviced. Additional connections would, in that case, serve to reduce the queueing time of requests.