PlanetScale

Scaling Postgres connections with PgBouncer

Mar 13, 2026Ben Dicken
Scaling Postgres connections with PgBouncer
SummaryAI, from the source post

This post details how to tune PgBouncer for optimal connection pooling with PostgreSQL. It explains the benefits of PgBouncer over direct connections, introduces PlanetScale's three PgBouncer deployment options (local, dedicated primary, dedicated replica), and elaborates on the three pooling modes (session, statement, transaction), recommending transaction pooling. The core contribution is a deep dive into PgBouncer's configuration parameters (`max_client_conn`, `default_pool_size`, `max_db_connections`, `max_user_connections`) and their interaction with PostgreSQL's `max_connections`, providing concrete tuning examples for different server sizes and tenancy models.

More from the Database Connection Management trail