Connection Pool Size Calculator
How many database connections an application actually holds at once — Little’s law from queries per second and their duration — and a pool size with headroom, compared with the database-side rule of thumb.
Little’s law: the average number of connections busy is the query rate times the average time each holds a connection.
How the connection pool size calculator works
Little’s law: the average number of connections busy is the query rate times the average time each holds a connection. 200 queries a second at 25 ms each keep five connections busy; add headroom for bursts and slow queries and you have the pool. On the database side, PostgreSQL’s guidance of about 2 × cores + spindles connections total is the ceiling that many small pools across many app instances must fit under.
Formula: in use = queries per second × seconds per query; pool = in use × (1 + headroom)
Worked examples
| Inputs | Pool size per instance | Note |
|---|---|---|
| 200 qps at 25 ms, 100% headroom, 4 instances | 10 | 10 per instance, 40 total — over the 17 guidance |
| A quiet service: 20 qps at 10 ms | 1 | 1 per instance |
| Slow reports: 5 qps at 2 s | 15 | 15 |
FAQFrequently asked questions
Why are big pools bad?
A database does work with its cores; connections beyond a few per core just queue inside the database, add memory per connection and contend on locks. Benchmarks routinely show throughput falling as pools grow past the core count.
What time do I use for the query?
The whole time the connection is checked out — including transaction time, network round trips and idle-in-transaction — not just the query’s execution time. Measure it from the pool’s metrics.
What if I have many application instances?
Their pools add up on the database. Either make each pool small, or put a connection pooler between them and the database so hundreds of client connections share a few dozen server ones.
Where does 2 × cores + spindles come from?
The PostgreSQL community’s empirical formula for the number of active connections at which throughput peaks: two per core plus one per disk (one for an SSD). It is a starting point, not a law.
Where these figures come from
- IEC 80000-13 — Information science and technology (quantities and units) — the decimal (kB, MB) versus binary (KiB, MiB) prefixes used throughout
- RFC 4632 — Classless Inter-domain Routing (CIDR) — the address-plan arithmetic behind the subnet calculator
- RFC 1918 — Address Allocation for Private Internets — the private ranges the subnet calculator recognises
- NIST SP 800-63B — Digital Identity Guidelines, Authentication — length over composition rules; the basis of the password guidance here
- NIST SP 800-57 Part 1 — Recommendation for Key Management — key-strength comparisons used by the key-space calculator
- NIST — Digital Identity Guidelines (SP 800-63) — US federal authentication standard
Last checked: September 2026. Units follow the SI decimal convention (IEC 80000-13 defines the binary alternatives); network and security figures cite the defining standard.