Why is database connection pooling important, especially at scale?
What they are really testing: Whether you understand that DB connections are expensive and limited, so opening one per request exhausts the database, and that a pool (or a proxy like PgBouncer) is the fix. Acute in serverless.
A real interview question
Why is database connection pooling important, especially at scale?
What most people say
drag me
“Pooling reuses connections so the app is faster.”
It mentions reuse and speed but misses the real driver: database connections are a scarce, expensive resource, and without pooling you exhaust max_connections under load and take the database down. The scale/serverless angle is the point.
The follow-ups they ask next
Why is connection management especially hard in serverless?
Each function instance scales independently and may hold its own connections, so a spike spawns far more connections than the DB allows. You need an external pooler/proxy (PgBouncer, RDS Proxy) to bound total connections.
What happens when you hit max_connections?
New connection attempts are refused (errors) and existing work slows as the DB struggles. Pooling bounds connection count so you stay under the limit even under load.
What the interviewer is listening for
- Knows connections are expensive/limited (per-process in PG)
- Knows one-per-request exhausts max_connections
- Knows external poolers for serverless/scale
What sinks the answer
- Only "reuse for speed"
- Unaware of connection limits
- No notion of poolers/proxies at scale
If you genuinely do not know
Say this instead of freezing. Reasoning out loud from what you do know beats silence every single time, and a good interviewer is listening for exactly that.
“DB connections are [expensive (memory, a process each in Postgres) and capped by max_connections]. [One-per-request under load exhausts the limit and takes the DB down]. A [pool keeps a bounded set of warm connections shared across requests]. At scale/serverless, [instances multiply connections, so use an external pooler (PgBouncer/RDS Proxy) to bound the total reaching the DB].”
Keep going with databases
Foundation
What is a database index, how does it speed up queries, and what does it cost?
Foundation
What are the ACID properties of a database transaction?
Foundation
What is normalization, and what are primary and foreign keys?
Junior
A query is slow in production. How do you diagnose and fix it?
Junior
How do read replicas help scale a database, and what is replication lag?
Mid
Under load, your RDS instance is the bottleneck and the app is slowing down. Walk me through your options, in order.
Knowing the answer is not the same as recalling it under pressure
Sign in to send the questions you fumble to spaced recall, so they come back right before you would forget them, and learn the concepts behind them with hands-on labs.
Start free