PgBouncer pool, 통계, 연결 조회(SHOW POOLS/STATS/CLIENTS/SERVERS)
PostgreSQLPgBouncer명령어
# Connect to the PgBouncer admin console (user must be in admin_users/stats_users):
psql -h 127.0.0.1 -p 6432 -U pgbouncer -d pgbouncer -X
SHOW POOLS; -- if cl_waiting > 0 and maxwait grows, the pool is saturated
SHOW STATS; -- per-database total/average query, transaction and wait times
SHOW CLIENTS; -- client connections (state, source address, linked server connection)
SHOW SERVERS; -- server connections opened to PostgreSQL
SHOW CONFIG;하는 일
데이터베이스/사용자 pool별로 활성 및 대기 클라이언트(cl_active, cl_waiting), 활성/idle 서버 연결(sv_active, sv_idle), 최장 대기 시간(maxwait), 쿼리/트랜잭션 카운터를 보여 준다.
사용 시점
애플리케이션이 연결 실패/타임아웃을 보고할 때, pool 크기 산정, 유지보수 전 활성 연결을 확인할 때.
주의
관리 콘솔은 SQL을 받지 않으며 PgBouncer 명령만 실행한다. cl_waiting이 계속 높으면 먼저 서버 측의 장시간 트랜잭션이나 락을 점검한다. default_pool_size를 무작정 올리면 PostgreSQL이 max_connections 한도와 메모리 압박에 가까워진다. SHOW STATS 값은 누적이며 평균은 stats_period 간격 기준이다.