Skip to main content

Command Palette

Search for a command to run...

Fine-Tuning Tomcat 8 JDBC Connection Pool

Published
β€’1 min read
Fine-Tuning Tomcat 8 JDBC Connection Pool
D
I'm Ayyanar Jeyakrishnan ; aka AJ. With over 21 years in IT, I'm a passionate Multi-Cloud Architect specialising in crafting scalable and efficient cloud solutions. I've successfully designed and implemented multi-cloud architectures for diverse organisations, harnessing AWS, Azure, and GCP. My track record includes delivering Machine Learning and Data Platform projects with a focus on high availability, security, and scalability. I'm a proponent of DevOps and MLOps methodologies, accelerating development and deployment. I actively engage with the tech community, sharing knowledge in sessions, conferences, and mentoring programs. Constantly learning and pursuing certifications, I provide cutting-edge solutions to drive success in the evolving cloud and AI/ML landscape.

πŸ”§ 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



44 views