John Smith
John Smith

Reputation: 193

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?

Upvotes: 6

Views: 4861

Answers (1)

catwalk
catwalk

Reputation: 6476

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)

Upvotes: 4

Related Questions