PgBouncer is fundamentally single-threaded, meaning a single process leaves all but one CPU core idle on multi-core servers. On a 16-core machine, connection pooling saturates throughput on one core while the remaining fifteen cores sit completely unused.
The standard workaround is binding multiple PgBouncer processes to the same port using the SO_REUSEPORT socket option. This allows the Linux kernel to distribute incoming connections across the worker fleet. However, scaling out this way creates a subtle and dangerous failure mode: query cancellation stops working reliably.
In Postgres, a query cancellation request arrives over a completely separate connection carrying a cancellation key. When using SO_REUSEPORT, the operating system kernel can route that new cancel connection to an entirely different process than the one holding the client session. That target process has no memory of the running query, causing the cancellation attempt to silently do nothing.
ClickHouse solved this failure mode by implementing an inter-process peering layer across the PgBouncer fleet. When a cancellation packet lands on an arbitrary process, it immediately checks the fleet, locates the process that owns the actual session, and forwards the command directly.
This architecture scales pooling throughput cleanly by four times without breaking client protocol expectations.



