Database Connection Pool Sizer
A mathematically precise utility for calculating the maximum safe connection pool size per pod. It prevents connection exhaustion and database brownouts during aggressive horizontal scaling.
Run DB Pool Sizer
Inputs stay in this browser and results are not saved.
Accuracy contract: The floor division is exact for the supplied capacity and reserve, but real safety depends on accounting for every connection consumer and deployment overlap.
Defined calculation contract
Calculation result
Recommendation
Use 9 connections per pod as an arithmetic upper bound under the supplied assumptions. At 50 pods this allocates 450 application connections and leaves 50 connections outside those pools.
Include every database consumer in the reserve: administrators, replication or monitoring, migrations, other services, pool maintenance connections, and temporary overlap during deployments. Validate the result with database and pool metrics before production use.
Versioned sources
Who this Lab is for
Designed for
- Backend and platform engineers
- Database administrators
- SRE teams reviewing autoscaling rules
Use it when
- Configuring Prisma, HikariCP, or PgBouncer pool limits
- Setting up a new horizontally scaling service
- Investigating connection exhaustion incidents
A complete run, step by step
Define database capacity
Enter the absolute maximum connections your database or proxy allows.
Set autoscaler bounds
Supply the maximum replica count your HPA will scale the service to.
Account for reserved connections
Exclude connections required for migrations, superusers, and sidecars.
Review unallocated buffer
Examine the remaining unallocated connections as a safety buffer for sudden spikes.
What you will need
Prepare the following information before starting. Use measured evidence where possible; defaults are examples and should not be treated as recommendations.
Database max_connections
The absolute maximum connections the database cluster or proxy can accept.
Maximum pods
The highest number of application pods that the HPA will scale out to.
Reserved connections
Connections reserved for migrations, superusers, or other services.
What the result tells you
Your report includes
- Maximum safe connections per pod
- Optimal database configuration bounds
- Risk analysis for autoscaling limits
How it is determined
The calculator subtracts reserved connections from the database limit, then divides the remainder by the maximum pod count. The result is floored to ensure that even at maximum scale, the database connection limit is never breached.
The floor division is exact for the supplied capacity and reserve, but real safety depends on accounting for every connection consumer and deployment overlap.
Model assumptions
- • The entered reserve includes administrative, monitoring, migration, replication, maintenance and non-application connections.
- • Maximum pods includes temporary overlap during rollouts and autoscaling.
- • Every pod uses the same configured maximum pool size.
Authoritative references
50-pod scaling event
Situation
A database accepts 500 connections. 20 are reserved for operations. The HPA scales out to 50 pods.
Result
Each pod must be strictly limited to a pool size of 9. Any value higher than 9 will cause connection errors at maximum scale.
Use the result with engineering judgement
- It assumes all pods are actively using their full pool.
- It does not account for PgBouncer transaction-level pooling dynamics, only hard connection counts.
Questions before you begin
Shouldn't I just use a proxy?
A proxy like PgBouncer helps, but you still need to limit the application pool so it doesn't exhaust the proxy's limit.
Why use floor instead of round?
Rounding up creates a scenario where scaling to max pods exceeds the absolute database connection limit, causing dropped transactions.
How do I handle multiple services using the same database?
You must allocate the database's max connections among the services first, then run this calculator individually for each service using its allotted fraction as the max connection limit.
Ready to run DB Pool Sizer?
Open the interactive utility without an account. Inputs and results are not saved.
Open toolGet practical engineering references
A useful digest about twice a week with new error references, tools, integration notes and production lessons. No daily noise.