</>CodexBash
All articles
Databases

Connection pooling

Why applications reuse database connections instead of opening one per request: the cost of a connection, how a pool works, HikariCP and other pools, sizing a pool correctly, timeouts and leak detection, PgBouncer for many application instances, serverless pitfalls, and monitoring.

CodexBash, , 6 min read

Opening a database connection is surprisingly expensive: a network round trip or several, a TLS handshake, authentication, and on PostgreSQL a whole new server process. An application that opened a fresh connection for every request would spend much of its time just saying hello to the database. Connection pooling solves this by keeping a set of open connections and lending them out, one request at a time. Every serious web framework uses a pool, and a badly sized one is one of the most common causes of slow or failing production systems. This article explains how pools work and how to configure them well.

Sign in to read the rest

The whole 6 minute article is free with an account, along with every problem, lesson and tutorial. No card.