Skip to main content
All Engineering Labs
CalculatorAdvanced

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.

Around 2 min No account required Advanced level
Interactive utility

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.

Inputs

Defined calculation contract

Exact output

Calculation result

9
Max connections per pod
50
Max application pods
500
Database max_connections
480
Total available to pods
20
Reserved for operations
30
Unallocated connections

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.

Purpose and audience

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
How to use it

A complete run, step by step

1

Define database capacity

Enter the absolute maximum connections your database or proxy allows.

2

Set autoscaler bounds

Supply the maximum replica count your HPA will scale the service to.

3

Account for reserved connections

Exclude connections required for migrations, superusers, and sidecars.

4

Review unallocated buffer

Examine the remaining unallocated connections as a safety buffer for sudden spikes.

Input guide

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

text

The absolute maximum connections the database cluster or proxy can accept.

Maximum pods

text

The highest number of application pods that the HPA will scale out to.

Reserved connections

text

Connections reserved for migrations, superusers, or other services.

Results and methodology

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.

Deterministic calculation · medium confidence · v2026.08.1

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

Worked example

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.

Important limitations

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.
Frequently asked questions

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 tool
Engineering signal

Get practical engineering references

A useful digest about twice a week with new error references, tools, integration notes and production lessons. No daily noise.