Database Connection Pool Calculator
Size a pool from cores, concurrency and think time — with the math shown step by step.
Workload inputs
oltpRecommendation
healthyConnections per instance
18
18 connections per instance · 54 across 3 instances · healthy
- HikariCP: pool = (cores × 2) + effective spindles = (8 × 2) + 2 = 18
- multiplier applied: 18 × 1 = 18
- fleet check: 54 ≤ 90 usable of 100 max_connections (10% reserved) → healthy
| Cores | 1× | 1.2× | 1.5× | 2× |
|---|---|---|---|---|
| 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 |
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
cores 8, spindles 2, multiplier 118 connections per instance8 × 2 + 2 = 18, the classic HikariCP answer.
200 rps at 50 ms
rps 200, latency 50 ms, safety 1.212 connectionsL = 200 × 0.05 = 10, then 10 × 1.2 = 12.
Fleet over budget
10 instances × 18, max_connections 100over-budget, ceiling 9 per instance180 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
Choose a formula
Use the HikariCP rule for a starting point, Little's law when traffic is known, or fleet check to reconcile instances.
Fill in workload values
Cores, spindles, requests per second, latency, safety factor, instances and max_connections all update the result live.
Read the derivation
Each displayed step shows the substitution so the number is auditable.
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
| Mode | Inputs |
|---|---|
| HikariCP | cores, spindles, multiplier |
| Little's law | rps, latency, safety |
| Fleet | all 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
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.gitattributes Generator
Build .gitattributes rules for line endings, Git LFS, GitHub linguist marks and merge drivers — with a one-line explanation for every rule.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
A/B Test Sample Size Calculator
Compute required sample size per variant and test duration from baseline conversion rate, minimum detectable effect, alpha and power.
ABA Routing Number Validator
Validate 9-digit US ABA routing numbers with 3-7-1 Mod-10 breakdown.