Database Connection Pool Size Calculator
Enter your database server's CPU cores, storage type and max_connections, then your application's instance count, threads, average query latency and target throughput. The calculator applies the HikariCP / PostgreSQL wiki formula (cores × 2 + effective spindles) for the per-database optimum, Little's Law (throughput × latency) for per-instance demand, and checks the total against max_connections and a rough per-backend memory estimate. Every intermediate number and the bound that won are shown, so nothing is a black box. You get a ready config snippet for HikariCP, pgxpool, node-postgres, SQLAlchemy, Django or PgBouncer, plus the PostgreSQL-side SQL to verify and monitor. Everything runs entirely in your browser — nothing is sent to a server.
Do more than database connection pool size calculator — meet Chat2DB
Chat2DB is an AI-powered SQL client for Windows, macOS and Linux. Write SQL in natural language, format and optimize queries automatically, and manage MySQL, PostgreSQL, Oracle and 20+ other databases in one workspace.
How to use
- Fill in the database server section (cores, storage type, RAM, max_connections, reserved connections, work_mem) and the application section (instances, threads, latency, throughput, whether PgBouncer is in front).
- Read the Recommendation block: it shows the per-database optimum, the Little's Law demand, the per-instance pool and which bound limited it, plus warnings if total demand exceeds max_connections.
- Pick your pool library to get a copy-ready config snippet, then run the PostgreSQL-side queries to confirm the live connection count and spot idle-in-transaction sessions.
Frequently asked questions
What is the formula for database connection pool size?
The most cited rule, from the PostgreSQL wiki and the HikariCP 'About Pool Sizing' page, is pool_size = CPU cores × 2 + effective_spindle_count, where the spindle count is roughly 1 on SSD/NVMe. This is the optimum for the whole database, not per application instance: divide it across instances, and cap each instance by its thread count and by Little's Law (throughput per second × average latency in seconds). A 8-core SSD server therefore wants about 17 concurrent connections total, even if you have 40 app pods.
Why does a smaller connection pool often perform better than a larger one?
A database core can only execute one query at a time; extra connections just wait on CPU, locks and I/O while consuming memory (each PostgreSQL backend is a process using roughly 5–10 MB plus work_mem per sort or hash node). With too many connections the server spends its time context switching and contending for buffers, so latency rises and throughput drops. A small pool with a client-side queue delivers the same work with lower tail latency and predictable memory.
How do I check whether my pool size is correct in production?
Query pg_stat_activity grouped by application_name and state: if you see many 'idle' connections you are over-provisioned, if clients wait on connectionTimeout while the server is mostly idle the pool is too small, and any 'idle in transaction' rows point to a code bug. Also compare pool wait time from your driver's metrics against query latency. Chat2DB lets you watch pg_stat_activity and pool metrics live with AI-assisted SQL and charts: download it at https://chat2db.ai/download or use the web version at https://app.chat2db.ai.
