Learnings from debugging PgBouncer

31 October 2019

What is PgBouncer?

PgBouncer is a lightweight connection pooler for PostgreSQL. It multiplexes a low number of underlying database connections and presents a Postgres interface to the client. This should lead to better performance since provisioning lots of connection slots in Postgres leads to a decrease in the memory available for each connection and will lead to worse performance. By using PgBouncer, clients can send lots of queries at a time, and they’ll queue up within PgBouncer, instead of swarming the actual database.

Monitoring PgBouncer

PgBouncer has an admin interface that is available via a virtual database called pgbouncer. This can be access by users that have stats access by connection to the pgbouncer database, i.e.:

\c pgbouncer