CertGrid CertGrid
Hands-on Lab·PostgreSQL

PostgreSQL Connection Limits and PgBouncer

Fill every slot and read the error PostgreSQL actually gives - it is not the one everybody quotes. Then 60 clients through PgBouncer become 5 server backends.

Monitoring and Operations Guide 42 of 47 Intermediate

Written against the versions above. `reserved_connections` is separate from `superuser_reserved_connections` and was added in PostgreSQL 16, for members of `pg_use_reserved_connections`. PgBouncer here is 1.25.1.

Every command on this page ran on db-a01.
Server NameIP AddressOSRolesCPURAMHDD
db-a01192.168.0.81Ubuntu 26.04 LTSPrimary / Source / Replica Set Member 12 Core4 GB50 GB

Before you start

  1. Count the budget

  2. Lower it, and watch the reload not work

  3. Fill every slot

  4. Limit a role rather than the server

  5. Install PgBouncer and point it at the cluster

  6. Configure transaction pooling

  7. Sixty clients, five backends

  8. Put the cluster back

Official sources