Database Engineering · Finding data fast
Connection pooling
Opening a database connection costs several network round trips and a server process. A pool opens a few connections once and lends them out, so requests skip the setup and the database is not swamped.
- Time14 min
- LevelDeveloper
- Experiments1 live
- Check6 questions






TCP the app and the database exchange SYN, SYN-ACK and ACK: one round trip.
TLS they agree on encryption keys: about two more round trips.
Login the password is checked with SCRAM: about two more round trips.
Backend process PostgreSQL starts a process just for this connection.
Query the 2 ms of work you actually wanted, plus one round trip.
Close the process exits; the next request starts from scratch.
Request handlers hundreds of requests in flight across your app instances.
PostgreSQL backends one process per real connection, capped by max_connections.