How to configure postgres + pgbouncer to allow a large number of connections
I am involved in stress testing pgbouncer with 5000 connections. The goal of the test is to multiplex the connection using pgbouncer, i.e. 5000 client connections with a 500dB connection.
However, I am unable to reach the target of the active 500 connection mark.
My setup is pretty simple
(client suite using pgbench) -----> pgbouncer + psql
| ______ several boxes ______ || ______ 1 box _________ |
pgbouncer and postgres are present in the same field.
pgbouncer = 1 core (pending)
postgres = 15 cores (pending)
-
machine configuration :
16 cores
ulimit -n 10000
-
Postgres configuration :
max_connections = 500
shared_buffers = 1GB
work_mem = 100kB
-
Pgbouncer config :
pool_mode = transaction
server_lifetime = 6000
server_idle_timeout = 2000
server_connect_timeout = 30
default_pool_size = 500
pool_size = 500
pkt_buf = 4096
server_login_retry = 2
-
client configuration (8 boxes of 8 cores):
Each client box is simulated as a set for clients using pgbench For a box with 8 boxes, I have set 16 threads to run requests
pgbench -h -p 6541 -c -j 16 -d -f pgbench_Script.sql -T 360 -U postgres test
pgbench_Script.sql
\ setrandom delta 0 100000 insert into t4.emplog values โโ(nextval ('t4.employeeSeq') ,: delta);
Active queries in postgres:
select count(*) from pg_stat_activity where state like 'active';
count
-------
40
My expectation is to have around 500 active database connections through the connection pool. Problem : I only see a few connections ~ 40 active connections
OBSERVATIONS: I see several postgres processes in an "idle" state even though pgbouncer serves all clients. Suggesting that pgbouncer can't do the best it can. However, I cannot point out what the exact bottle neck is.
Potential bottleneck:
client request: pgbench makes each thread the master of the set when connecting. how can I simulate a large set of active concurrent connections?
pgbouncer: is my pgbouncer config wrong?
postgres: is my postgres config unable to handle large connection?
source to share
No one has answered this question yet
Check out similar questions: