We Scaled PgBouncer to 4x Throughput — A Field Report

A widely-shared engineering writeup describes how a team took their PgBouncer deployment from “barely keeping up” to absorbing a 4x traffic spike without provisioning more database nodes. The wins came from configuration, not hardware.

What changed

  • Switched from session to transaction pooling with explicit pool_mode = transaction
  • Tuned default_pool_size and max_client_conn against the actual Postgres max_connections ceiling
  • Added a queue-depth metric and shed load earlier via a small Lua/Envoy layer in front of PgBouncer

What surprised them

  • server_idle_timeout default of 600s was masking connection churn — they dropped it to 30s
  • Prepared statements were being silently re-prepared on every transaction; switching to prepared_statement_cache lifted 30% throughput

Takeaway

  • PgBouncer’s defaults are conservative for OLTP, not for high-churn services. A two-day tuning pass beat a hardware budget request