DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Connection Pooling
  • A Maven Story
  • Java EE 6 Pet Catalog with GlassFish and MySQL
  • API Performance Tuning

Trending

  • Unlocking Data with Language: Real-World Applications of Text-to-SQL Interfaces
  • Building Custom Tools With Model Context Protocol
  • The Human Side of Logs: What Unstructured Data Is Trying to Tell You
  • Build Your First AI Model in Python: A Beginner's Guide (1 of 3)
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Optimum Database Connection Pool Size

Optimum Database Connection Pool Size

Want to figure out the best size for your connection pool? Here's how the math pans out, courtesy of some simple logic.

By 
Anubhav R Mulchandani user avatar
Anubhav R Mulchandani
·
Nov. 28, 16 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
41.3K Views

Join the DZone community and get the full member experience.

Join For Free

Long ago, I was working on a project where I dealt with a situation — what should be the optimum size of connection pool?

While I was aware that it had to be configured on the application server side (web sphere application server v.5.x, in this case), I did not know the optimum pool size.

So I started having a discussion with my peers to try to understand more about it. I received some input and one of them was good enough, backed by strong reasoning, for me to recommend it to the admin. So what was it?

It’s quite simple and straightforward — look for the maximum size of the web container thread pool.

What Is a Web Container Thread Pool?

This pool consists of a number of threads that an application server will create and use to process the requests concurrently. So, for example, if the thread pool size is 50 (not realistic figure), the maximum number of requests an application may process concurrently will be 50.

So, the connection pool size has to be lower than the maximum size of the web container thread pool. Does it look reasonable and logical?

Let’s Analyze It

Max size of web container thread pool: 50

Max size of connection pool size: 65

Now if there are 50 concurrent requests coming to our application server, only 50 connections will be consumed by those 50 requests. But we are still left with 15 more connections — a sheer waste of resource. So, keeping performance statistics in mind; the connection pool size should be lower than the maximum thread pool size.

It may be 30/35 in our case.

There is another factor/attribute that should be considered, connection timeout. This should be calculated by obtaining the average time a database operation takes in our application, plus a few seconds more (let’s say 5).

I believe this post will be quite enlightening for many, and I  hope to receive your input so that I may update my post accordingly.

I always believe that knowledge is free and should always be free.

Connection pool Database connection Web container application Application server

Opinions expressed by DZone contributors are their own.

Related

  • Connection Pooling
  • A Maven Story
  • Java EE 6 Pet Catalog with GlassFish and MySQL
  • API Performance Tuning

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: