惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
腾讯CDC
博客园 - 司徒正美
A
About on SuperTechFans
H
Help Net Security
J
Java Code Geeks
C
Check Point Blog
B
Blog RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
MongoDB | Blog
MongoDB | Blog
U
Unit 42
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
MyScale Blog
MyScale Blog
V
Visual Studio Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
I
InfoQ
H
Hackread – Cybersecurity News, Data Breaches, AI and More
F
Fortinet All Blogs
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
博客园 - 【当耐特】
雷峰网
雷峰网

博客园 - MSSQL123

timescaledb 扩展 PostgreSQL 18+ 版本下源码编译安装 ubuntu24下 ext4和xfs类型磁盘以及PostgreSQL实例性能对比测试 PostgreSQL 18 新特性 skip scan,一个鸡肋的功能 PostgreSQL 17 流复制中开启逻辑复制槽同步,以及逻辑槽的故障转移 记一次PostgreSQL交叉表crosstab行转列导致的OOM TiDB 扩容与缩容 PostgreSQL 高可用集群 patroni 自动故障转移测试 Ubuntu 20 环境下 patroni 自动化安装,一分钟快速搭建 patroni 集群 Ubuntu 20 环境下 pg_auto_failover 自动化安装,一分钟快速搭建pg_auto_failover集群 PostgreSQL的消息队列扩展pgmq 磁盘IO延迟和队列深度的关系 TiDB 最小拓扑架构集群安装 PostgreSQL 逻辑复制中的同步和异步模式以及其表现 prometheus 的 altermanager Silences静默告警,优雅地抑制告警 “世界上百分之99的博士和他们的论文都是垃圾”,原本以为这个观点偏激 pg_auto_failover 在多种场景下自动故障转移的验证 pg_auto_failover 自动故障转移参数 博文阅读密码验证 - 博客园 pg_auto_failover 高可用中,PostgreSQL实例配置文件的加载步骤 pg_auto_failover集群monitor节点的高可用 prometheus监控Linux Server node_exporter代理安装和配置 prometheus监控windows window_exporter代理安装和配置 Prometheus 和 Grafana 监控 PostgreSQL 记一次MySQL binlog日志导致磁盘空间占满的问题 SQLServer 2019 标准版在虚拟机上无法充分利用CPU的问题诊断 Windows Failover Cluster集群中的EventId 1196错误日志 pg_auto_failover 环境变量导致的show命令错误 SqlServer 事务复制(transaction replication)的复制位点信息 SqlServer 事务复制的两个参数immediate_sync,allow_anonymous MySQL,SqlServer,PostgreSQL中,如何实现锁定一张表
pgbouncer连接池设置与压力测试的最大连接数测试
MSSQL123 · 2026-04-03 · via 博客园 - MSSQL123

pgbouncer中间件,通过设置so_reuseport=1,配置两个pgbouncer的systemctl服务,启动两个pgbouncer的进程。
如下两个进程的配置文件分别是pgbouncer.ini和pgbouncer2.ini,default_pool_size=30,意味着最多支持60个客户端连接,超过这个连接数之后就开始排队(即便是数据库的最大连接数远超60),验证一下这个设置。

image

可以看到当线程数超过64的时候,出现了NOTICE:  No server connection available in postgres backend, client being queued异常。
但是这里的No server connection available并不是达到了数据库的最大连接数的设置的值,也不是报错,而是受前端的pgbouncer连接池中设置的最大值限制,没有连接可用,然后排队等待可用连接。

root@ubuntu12:/usr/local/pgbouncer/bin# pgbench -r -T60 demo_db -U demo_user  -p 8888 -c8 -j8
Password:
pgbench (16.4)
starting vacuum...end.
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 10
query mode: simple
number of clients: 8
number of threads: 8
maximum number of tries: 1
duration: 60 s
number of transactions actually processed: 76925
number of failed transactions: 0 (0.000%)
latency average = 6.239 ms
initial connection time = 11.821 ms
tps = 1282.170948 (without initial connection time)
statement latencies in milliseconds and failures:
         0.001           0  \set aid random(1, 100000 * :scale)
         0.000           0  \set bid random(1, 1 * :scale)
         0.000           0  \set tid random(1, 10 * :scale)
         0.000           0  \set delta random(-5000, 5000)
         0.534           0  BEGIN;
         0.709           0  UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
         0.737           0  SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
         0.846           0  UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
         1.261           0  UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
         0.624           0  INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
         1.527           0  END;
root@ubuntu12:/usr/local/pgbouncer/bin#
root@ubuntu12:/usr/local/pgbouncer/bin#
root@ubuntu12:/usr/local/pgbouncer/bin# pgbench -r -T60 demo_db -U demo_user  -p 8888 -c32 -j32
Password:
pgbench (16.4)
starting vacuum...end.
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 10
query mode: simple
number of clients: 32
number of threads: 32
maximum number of tries: 1
duration: 60 s
number of transactions actually processed: 93419
number of failed transactions: 0 (0.000%)
latency average = 20.549 ms
initial connection time = 28.982 ms
tps = 1557.281163 (without initial connection time)
statement latencies in milliseconds and failures:
         0.001           0  \set aid random(1, 100000 * :scale)
         0.000           0  \set bid random(1, 1 * :scale)
         0.000           0  \set tid random(1, 10 * :scale)
         0.000           0  \set delta random(-5000, 5000)
         2.492           0  BEGIN;
         1.250           0  UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
         1.657           0  SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
         3.656           0  UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
         7.347           0  UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
         1.015           0  INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
         3.126           0  END;
root@ubuntu12:/usr/local/pgbouncer/bin#
root@ubuntu12:/usr/local/pgbouncer/bin#
root@ubuntu12:/usr/local/pgbouncer/bin# pgbench -r -T60 demo_db -U demo_user  -p 8888 -c64 -j64
Password:
pgbench (16.4)
starting vacuum...end.
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
NOTICE:  No server connection available in postgres backend, client being queued
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 10
query mode: simple
number of clients: 64
number of threads: 64
maximum number of tries: 1
duration: 60 s
number of transactions actually processed: 93579
number of failed transactions: 0 (0.000%)
latency average = 41.024 ms
initial connection time = 67.205 ms
tps = 1560.068618 (without initial connection time)
statement latencies in milliseconds and failures:
         0.001           0  \set aid random(1, 100000 * :scale)
         0.000           0  \set bid random(1, 1 * :scale)
         0.000           0  \set tid random(1, 10 * :scale)
         0.000           0  \set delta random(-5000, 5000)
        23.016           0  BEGIN;
         1.245           0  UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
         1.818           0  SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
         3.676           0  UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
         7.185           0  UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
         1.111           0  INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
         2.951           0  END;
root@ubuntu12:/usr/local/pgbouncer/bin#