DevTools Logo

Database Connection Pool Calculator

Database Connection Pool Calculator

Size a pool from cores, concurrency and think time — with the math shown step by step.

Runs in your browser
Try an example

Workload inputs

oltp

Recommendation

healthy

Connections per instance

18

18 connections per instance · 54 across 3 instances · healthy

  1. HikariCP: pool = (cores × 2) + effective spindles = (8 × 2) + 2 = 18
  2. multiplier applied: 18 × 1 = 18
  3. fleet check: 54 ≤ 90 usable of 100 max_connections (10% reserved) → healthy
Pool size sensitivity by core count and safety factor
Cores1×1.2×1.5×2×
268912
410121520
818222736
1634415168
32668099132

Config snippet

dataSource.maximumPoolSize=18
dataSource.minimumIdle=9
dataSource.connectionTimeout=30000
| Cores | x1 | x1.2 | x1.5 | x2 |
|---|---|---|---|
| 2 | 6 | 8 | 9 | 12 |
| 4 | 10 | 12 | 15 | 20 |
| 8 | 18 | 22 | 27 | 36 |
| 16 | 34 | 41 | 51 | 68 |
| 32 | 66 | 80 | 99 | 132 |

Examples

8-core OLTP

Input
cores 8, spindles 2, multiplier 1
Output
18 connections per instance

8 × 2 + 2 = 18, the classic HikariCP answer.

200 rps at 50 ms

Input
rps 200, latency 50 ms, safety 1.2
Output
12 connections

L = 200 × 0.05 = 10, then 10 × 1.2 = 12.

Fleet over budget

Input
10 instances × 18, max_connections 100
Output
over-budget, ceiling 9 per instance

180 demand exceeds 90 usable connections after the reserve.

About this tool

The Database Connection Pool Calculator turns three common sizing questions into defensible numbers. The HikariCP rule of thumb starts at (cores × 2) + effective spindles. Little's law derives concurrency from request rate and average latency as L = λ × W. Fleet reconciliation multiplies a per-instance pool by your instance count and compares it with the database's max_connections.

Every result includes its derivation with the actual numbers substituted, so you can explain the recommendation in a design review instead of quoting a blog post. A sensitivity grid shows how the answer moves across 2 to 32 cores and safety factors from 1× to 2×, and snippets are emitted for HikariCP properties, Prisma connection limits and pgx MaxConns.

Pool sizing is a starting point, not a law. The tool warns when reporting workloads need a queue, when serverless fan-out calls for a transaction pooler, and when your fleet is over the database connection budget with a ten percent reserve left for administrative sessions.

What this tool does not do

  • Formulas produce starting points; load testing is still required.
  • Queueing theory beyond Little's law is not modeled.
  • Database-side limits other than max_connections are not considered.
  • Serverless concurrency forecasts must be supplied by you.

How to use this tool

  1. Choose a formula

    Use the HikariCP rule for a starting point, Little's law when traffic is known, or fleet check to reconcile instances.

  2. Fill in workload values

    Cores, spindles, requests per second, latency, safety factor, instances and max_connections all update the result live.

  3. Read the derivation

    Each displayed step shows the substitution so the number is auditable.

  4. Copy a snippet

    Pick HikariCP, Prisma or pgx output and paste the recommended pool size into your configuration.

Use cases

HikariCP tuning

Get a defensible maximumPoolSize for a Spring service.

Fleet capacity planning

Check that every instance's pool fits inside the database budget.

Interview prep

See the HikariCP and Little's law derivations with numbers plugged in.

Three sizing methods

ModeInputs
HikariCPcores, spindles, multiplier
Little's lawrps, latency, safety
Fleetall inputs + instances

Ten percent of max_connections is reserved before the budget verdict.

Common mistakes

Mistake:Setting a very large pool to fix slow queries.

Fix:Investigate latency first; extra connections add contention.

Mistake:Forgetting multiple app instances.

Fix:Multiply the per-instance pool by instance count and compare with max_connections.

Mistake:Treating SSDs as many spindles.

Fix:Effective spindle count is a tuning parameter, often 1-2 for SSD storage.

Mistake:Ignoring serverless fan-out.

Fix:Use a small per-instance pool and a transaction proxy such as PgBouncer.

Frequently asked questions

What is the HikariCP pool size formula?

The widely cited starting point is (cores × 2) + effective spindles. It assumes a mix of CPU and I/O work: more cores allow more parallel queries, while spinning disks benefit from a small number of concurrent operations. Treat it as a starting point and measure wait times afterwards.

Why not make the pool much bigger?

Extra connections increase context switching, memory use and database contention. Past a certain point throughput falls while latency rises. A smaller pool with a queue in front of it usually performs better than an oversized pool.

How does Little's law apply?

L = λ × W: concurrency equals arrival rate multiplied by average time in the system. At 200 requests per second with 50 ms queries, you need about 10 concurrent queries; a safety factor gives the pool size.

Do multiple app instances share the pool budget?

They share the database's connection limit but not the pool itself. Multiply the per-instance pool by instance count, leave headroom for administrative sessions, and reduce the per-instance size if the total exceeds the budget.

What about serverless databases?

Every scaled instance or function can open its own connections, so keep each pool tiny (often 1-5) and put a transaction pooler such as PgBouncer in front of the database.

Does the tool load-test my database?

No. It computes and explains starting values, then emits configuration snippets. Real load testing is still the authoritative check for your workload.

References & standards