Skip to main content

Command Palette

Search for a command to run...

Fine-Tuning Tomcat 8 JDBC Connection Pool

Updated
β€’1 min read
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"

πŸ“Ž Tomcat 8 Docs - maxWait


βœ… 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



42 views

More from this blog

D

DataOps Labs

77 posts

Stay updated on the latest in AI/ML, Cloud, DevOps, MLOps, Generative AI and cutting-edge techniques with this continuous learning free newsletters.