Databases & Transactions interview question · Most asked
What is connection pooling and how do you size a pool?
Summary
A pool keeps a set of open database connections that requests borrow and return, avoiding the cost of opening connections per request and capping concurrent load on the database.
Longer Answer
Size so that pool_size × app instances stays below the database's max connections (minus headroom for admin/migrations). Bigger isn't better: databases perform best with a modest number of active connections (often ~2–4× CPU cores). Use external poolers (PgBouncer, RDS Proxy) when you have many instances or serverless functions. Set timeouts for acquiring connections.
Key Points
- Reuse connections
- Pool × instances < DB max
- Modest pools perform best
- PgBouncer/RDS Proxy at scale
- Acquire timeouts
More most-asked Databases & Transactions questions
- What does ACID mean?
- Explain transaction isolation levels and the anomalies they prevent.
- How do database indexes work and when do they help or hurt?
- What is the N+1 query problem and how do you fix it?
- How do you choose between SQL and NoSQL databases?
- How do you run schema migrations without downtime?
- How do you keep data consistent across services without distributed transactions?