OnCallReadyStart learning

pgbouncer: lightweight connection pooler for PostgreSQL (PgBouncer 1.25)

pgbouncer [-d] [-R] [-v] [-u user] <pgbouncer.ini>

What it does

Clients connect to PgBouncer (port 6432) as if it were PostgreSQL; it authenticates them (auth_type, auth_file / auth_query) and hands out server connections from small pools: per client session, per transaction, or per statement (pool_mode). On Ubuntu: /etc/pgbouncer/pgbouncer.ini, /etc/pgbouncer/userlist.txt, pgbouncer.service running as postgres. The admin console is the virtual database "pgbouncer": SHOW POOLS, SHOW CLIENTS, SHOW SERVERS, SHOW STATS, SHOW CONFIG, RELOAD, PAUSE, RESUME, KILL.

Options you will use

-d, --daemon
run in the background.
-R, --reboot
online restart (deprecated: use so_reuseport).
-u, --user=USERNAME
assume identity of USERNAME.
-v, --verbose
increase verbosity.
-q, --quiet
run quietly.
-V, --version
show version, then exit.

Examples

$ sudo -u postgres psql -h /var/run/postgresql -p 6432 -U pgbouncer pgbouncer -c "show pools"

clients waiting? server connections in use?

$ sudo systemctl reload pgbouncer

re-read pgbouncer.ini without dropping clients

Gotchas

On the blog

Try pgbouncer in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.