pgbouncer

https://pgbouncer.github.io/
https://pgbouncer.github.io/usage.html

https://www.pgbouncer.org/config.html

PgBouncer の設定 | Heroku Dev Center 2023

PostgreSQL + Rails へ PgBouncer を導入してDBメモリ使用量を大幅に改善した話 - Hello Tech 2023

FreeBSD

FreeBSD 10.1にpgbouncerをインストールする
https://symfoware.blog.fc2.com/blog-entry-1738.html

Possible solutions:

Reconnect after a certain number of requests
Add more memory
Connection pooling to put a ceiling on the number of postgres connections using pgpool-II or PgBouncer

https://stackoverflow.com/questions/20514569/idle-postgres-processes-taking-up-lots-of-memory

pgbouncer log rotate

http://raghavt.blogspot.com/2016/08/how-to-rotate-pgbouncer-logs-in.html

FreeBSD newsyslog

/usr/local/etc/newsyslog.conf.d/pgbouncer 
/var/log/pgbouncer/pgbouncer.log	pgbouncer:pgbouncer	644	7	*	@T00	J	/var/run/pgbouncer/pgbouncer.pid
ステータス確認

PgBouncer command-line usage

psql -p 6432 -U pgbouncer pgbouncer -c "SHOW DATABASES;"

max_client_conn pgbouncerが受け付けるコネクション数
pool_size pgbouncerとpostgresの間のコネクション数

pool_size コネクションを使い切った状態で、コネクション取得できず
query_wait_timeout 秒経過すると Pooler Error: query_wait_timeout

https://dba.stackexchange.com/questions/261709/pgbouncer-logging-details-for-query-wait-timeout-error

pgpool-II と PgBouncer 比較