Sobes.tech
Senior

If PgBouncer holds 10 connections but there are 100 clients, how will they be served?

sobes.tech AI

Answer from AI

PgBouncer is a connection pooler for PostgreSQL that allows efficient management of a large number of client connections with a limited number of actual database connections.

If PgBouncer is configured for 10 real connections to the database but serves 100 clients, it will distribute these client connections across the 10 real connections using queuing and multiplexing.

This means not all 100 clients will have an active connection to the database at the same time. PgBouncer quickly switches connections between clients, ensuring their order and minimizing the overhead of establishing new connections.

This works well for short transactions and queries. However, if clients keep connections open for a long time, the queue may grow, and the waiting time will increase.

Thus, 100 client connections are served by 10 real connections through the pool, which increases scalability and reduces the load on PostgreSQL.