Overview
PgBouncer sits between clients and PostgreSQL, multiplexing many client connections onto fewer backend connections. Every database created through DBHost gets a PgBouncer pool entry automatically.Configuration files
| File | Purpose |
|---|---|
/etc/pgbouncer/pgbouncer.ini | Main config: database entries, pool settings |
/etc/pgbouncer/userlist.txt | User credentials (plaintext, format: "user" "pass") |
How the agent manages PgBouncer
The agent performs four operations on PgBouncer:-
Add database — Appends a line to
[databases]inpgbouncer.ini: -
Remove database — Removes the line from
pgbouncer.ini -
Add/update user — Appends or replaces entry in
userlist.txt: -
Reload — Sends
SIGHUPto the PgBouncer process (found viapgrep). This reloads config without dropping existing connections.
Pool settings
Default pool configuration inpgbouncer.ini:
| Setting | Value | Why |
|---|---|---|
pool_mode | transaction | Best for multi-tenant (releases backend conn after each transaction) |
auth_type | scram-sha-256 | Matches PostgreSQL’s default auth method |
max_client_conn | 200 | Total client connections across all databases |
default_pool_size | 20 | Backend connections per database |
max_prepared_statements | 100 | Needed for ORMs like Drizzle that use prepared statements |