Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate the size for a database connection pool?

Say I'm expecting about 100 requests a second, each request should take anywhere between 1 - 3 seconds (In a perfect world).

Would I create a pool of 300 connections? Or something slightly higher to compensate for potential spikes?

like image 260
John Smith Avatar asked Nov 25 '09 22:11

John Smith


People also ask

What is DB connection pool size?

A connection pool maintains a specific number of open database connections to an application in the main memory. The default size of the database connection pool is eight, but you can change this number while deploying or updating an application in the SAP BTP cockpit.

What is the max pool size in connection pool?

A connection pool is created for each unique connection string. When a pool is created, multiple connection objects are created and added to the pool so that the minimum pool size requirement is satisfied. Connections are added to the pool as needed, up to the maximum pool size specified (100 is the default).

What is SQL pool size?

By default, SQL Server allows a maximum of 32767 concurrent connections which is the maximum number of users that can simultaneously log in to the SQL server instance.


1 Answers

That depends on the distribution of arriving events. Queuing theory can give you a formula (for a given distribution) how many connections you need so that the probability of failure (no free connection in your case) will be no more than certain percentage.

You may want to look at these notes (page 17) which give you some formulas, such as probability that you have n requests being served at the same time or you have a non-empty queue (the state that you want to avoid)

like image 200
catwalk Avatar answered Oct 14 '22 02:10

catwalk