How many PostgreSQL connections does my API need?
Worked Answer
Multiply requests per second by connection hold time in seconds (Little's Law). At 200 requests/s and 50 ms (0.05 s) holding one connection, average demand is 200 × 0.05 = 10 active connections—but a 4× burst pushes demand to 40 connections, which is why you size pools for peak bursts and use a transaction pooler.
Estimate average active PostgreSQL connections from request rate and connection hold time, then test how a traffic burst changes your pool and max_connections requirements.
Prerequisites
Packages
pgpgbouncerInteractive PostgreSQL Concurrency Calculator
Every request holds one database connection for the stated duration.
Average Active
10
200 × 0.050s
Burst Peak (4×)
40
40% of max_connections
Pool Recommendation
Fits within max_connections, but keep a pooler for slow-query spikes.
Baseline worked example: 200 × 0.05 seconds = 10 active connections on average. During a 4× traffic spike, concurrent demand jumps to 40 connections.
Why the average alone cannot size your pool
Average demand assumes uniform arrival. Real API traffic arrives in bursts (webhooks, cron jobs, AI agent fan-outs) and slow queries double hold time. If 200 req/s spikes 4× while a lock doubles hold time from 50 ms to 100 ms, demand hits 80 connections—quickly saturating a default PostgreSQL instance unless you place PgBouncer or Hyperdrive in front.
Traffic stays constant at 200 req/s, but each request holds its connection twice as long (100 ms instead of 50 ms). What happens to average connection demand?
Production Evidence & Architecture Guides
1.5M Events/Sec Distributed Streaming & Execution Engine (Rust + Go)
Read Case Study Architecture ArticleHire a Golang Developer for High-Concurrency Backends: What to Check Before You Sign
Read Article Architecture ArticleWhy Production AI Backends Use Go for Concurrency and Rust for Sandboxing
Read ArticleOfficial Sources
Want this architecture built for your team?
Fixed-scope engineering sprints for databases, AI agents, and production retrieval.