我正在使用5000个连接对pgbouncer进行压力测试。
测试的目的是使用pgbouncer复用连接,即5000个客户端连接到500个数据库连接。
然而,我无法达到活动500个连接的目标。
我的设置非常简单:
(使用pgbench设置客户端) ----> pgbouncer + psql |______多个盒子_______|| ______1个盒子 _______| pgbouncer和postgres在同一台服务器上。 pgbouncer = 1个核(预期) postgres = 15个核(预期)
机器配置: -16个核心 -ulimit -n 10000
Postgres配置: -max_connections = 500 -shared_buffers = 1GB -work_mem = 100kB pgbouncer配置: -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
客户端配置(每个8个核心有8个盒子): -每个客户端盒子都使用pgbench模拟 -对于一个8核的盒子,我设置了16个线程来执行查询: pgbench-hIP-p 6541 -cConnections-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);
正在处理postgres上的活动查询:
然而,我无法达到活动500个连接的目标。
我的设置非常简单:
(使用pgbench设置客户端) ----> pgbouncer + psql |______多个盒子_______|| ______1个盒子 _______| pgbouncer和postgres在同一台服务器上。 pgbouncer = 1个核(预期) postgres = 15个核(预期)
机器配置: -16个核心 -ulimit -n 10000
Postgres配置: -max_connections = 500 -shared_buffers = 1GB -work_mem = 100kB pgbouncer配置: -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
客户端配置(每个8个核心有8个盒子): -每个客户端盒子都使用pgbench模拟 -对于一个8核的盒子,我设置了16个线程来执行查询: pgbench-hIP-p 6541 -cConnections-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);
正在处理postgres上的活动查询:
select count(*) from pg_stat_activity where state like 'active';
count
-------
40
我希望连接池能够提供接近500个活跃的数据库连接。
问题: 目前只有大约40个连接处于活跃状态。
观察结果: 我看到多个postgres进程处于'idle'状态,尽管pgbouncer正在为所有客户端提供服务。这表明pgbouncer无法发挥最佳性能。然而,我不能确定确切的瓶颈在哪里。
可能的瓶颈:
客户端请求: pgbench使每个线程成为一组连接的主节点。如何模拟大量的活动并发连接?
pgbouncer: 我的pgbouncer配置是否存在问题?
postgres: 我的postgres配置是否无法处理大量连接?
pgbouncer
),您的Postgres将永远不会超过最佳连接数。我认为对于永远不会发生的情况进行压力测试是没有意义的。 - Ihor Romanchenko