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

← All Databases & Transactions questions