Fine-Tuning Tomcat 8 JDBC Connection Pool

π§ 1. Right-Size maxActive
Description: Maximum number of active connections in the pool.
π Issue: Too low = connection starvation. Too high = DB overload.
β Recommendation:
maxActive="100"
π Tomcat 8 Docs - maxActive
β± 2. Set a Sensible maxWait
Description: How long (in ms) to wait for a connection before throwing an exception.
π Issue: Low value = frequent timeouts under load.
β Recommendation:
maxWait="10000"
β
3. Avoid Stale Connections with validationQuery, testOnBorrow, and validationInterval
Description: Checks that a DB connection is valid before returning it to the app.
π Issue: Stale connections lead to failed transactions.
β Recommendation:
testOnBorrow="true"
validationQuery="SELECT 1"
validationInterval="30000"
π Tomcat 8 Docs - validationQuery & testOnBorrow
π€ 4. Manage Idle Connections with minIdle, maxIdle, timeBetweenEvictionRunsMillis, minEvictableIdleTimeMillis
Description: Controls idle connection cleanup to avoid leaks and unnecessary DB usage.
β Recommendation:
minIdle="10"
maxIdle="30"
timeBetweenEvictionRunsMillis="30000"
minEvictableIdleTimeMillis="60000"
π Tomcat 8 Docs - Idle Connection Settings






