PG长短连接-性能测试

PG短连接对系统性能有很大影响。

# test.sql

select 1;
[postgres@master ~]$ pgbench -M extended -n -r -f ./test.sql -c 16 -j 4 -C -T 30
transaction type: ./test.sql
scaling factor: 1
query mode: extended
number of clients: 16
number of threads: 4
duration: 30 s
number of transactions actually processed: 27868
latency average = 17.227 ms
tps = 928.756333 (including connections establishing)
tps = 1235.692776 (excluding connections establishing)
statement latencies in milliseconds:
         8.539  select 1;

如果系统没有sar,需要通过yum -y install sysstat安装

#sar -w 1

08:21:31 AM    proc/s   cswch/s
08:21:33 AM    844.00   5311.00
08:21:34 AM    787.00   4932.00
08:21:35 AM    846.00   5322.00
08:21:36 AM    864.00   5515.00
08:21:37 AM    856.44   5379.21
08:21:38 AM    790.00   4960.00
08:21:39 AM    819.00   5217.00
08:21:40 AM    863.00   5531.00
08:21:41 AM    843.00   5415.00
08:21:42 AM    819.00   5139.00
08:21:43 AM    285.00   1916.00

[postgres@master ~]$ pgbench -M extended -n -r -f ./test.sql -c 16 -j 4 -T 30
transaction type: ./test.sql
scaling factor: 1
query mode: extended
number of clients: 16
number of threads: 4
duration: 30 s
number of transactions actually processed: 1348764
latency average = 0.356 ms
tps = 44954.875131 (including connections establishing)
tps = 44967.030121 (excluding connections establishing)
statement latencies in milliseconds:
         0.344  select 1;

#sar -w 1
08:21:44 AM      0.00     92.00
08:21:45 AM      0.00     99.00
08:21:46 AM      0.00    104.00
08:21:47 AM      0.00    138.00
08:21:49 AM      0.00  89788.12
08:21:50 AM      0.00  84233.00
08:21:51 AM      0.00  62440.00
08:21:52 AM      0.00  65457.00
08:21:53 AM      0.00  66130.00
08:21:54 AM      0.00  61289.00
08:21:55 AM      0.00  64196.00
08:21:56 AM      0.00  62915.00
08:21:57 AM      0.00  61806.00
08:21:58 AM      0.00  63227.00
08:21:59 AM      0.00  64437.00

上一篇:PG守护进程(Postmaster)——后台一等公民进程


下一篇:Postgres 数据库常用一些sql语句