Search code examples
postgresqlconnection-poolingthroughputpgbouncer

PgBouncer performance drops when connection count increases


I have a dedicated PostgreSQL server and a pgBouncer server. all connections are established through pgBouncer. I tested the system using Apache JMeter and PHP. The results are weird. The throughput with 500 connections are not bad but when I test using more connections it drops.

This is the test result:

enter image description here

The pgbouncer config:

[databases]

maindb = host=212.212.322.323 port=5432 user=myuser dbname=mydb pool_size=1000 pool_mode=transaction

[pgbouncer]

logfile = /var/log/postgresql/pgbouncer.log
pidfile = /var/run/postgresql/pgbouncer.pid

listen_addr = *
listen_port = 6432

auth_type = trust
auth_file = /etc/pgbouncer/userlist.txt

pool_mode = session
max_client_conn = 1000
default_pool_size = 20

Solution

  • It is known limit of pgbouncer. It uses only one CPU, and doesn't work well under very high number of connections (for smaller number of connects it is fast and effective). There are new projects, that can be used instead pgbouncer for this purpose - Odyssey or pgagroal.