How to use it
- Enter the CPU cores of the database server (physical cores, not hyper-threads) and the number of disks that serve the data.
- Enter how many application instances (pods, processes) share the database.
- Enter the total query rate and the average time a query keeps its connection, including network round trips and time inside a transaction.
Formulas
- Pool total = cores × 2 + effective spindles
- Per instance = ceil(pool total ÷ instances)
- Busy connections (Little’s law) = queries per second × query time in seconds
- Utilisation = busy ÷ pool total
Worked example
A database with 8 cores and 1 disk, used by 2 instances at 400 queries per second, 15 ms each:
- Pool total: 8 × 2 + 1 = 17.
- Per instance: ceil(17 ÷ 2) = 9.
- Busy: 400 × 0.015 = 6 connections; utilisation 6 ÷ 17 = 35.3 %.
Tips
- Above 100 % utilisation queries queue. Make queries faster or reduce how long transactions keep their connection before you add connections.
- Count every client. Background workers, cron jobs and admin tools draw from the same database limit (max_connections in PostgreSQL).
- Keep the pool fixed. Setting the minimum idle connections equal to the maximum avoids latency spikes when the pool has to open new connections under load.