如何使用 pgbench 获取 P99 延迟结果?
How to get P99 latency result using pgbench?
我正在尝试使用 pgbench 在 PolarDB for postgreSQL 上执行测试。
这是我用来执行测试的命令。
pgbench -M prepared -r -c 16 -j 4 -T 30 -p 10001 -d pgbench -l
这是结果
... ...
client 2 sending P0_10
client 2 receiving
client 2 receiving
client 14 receiving
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 32
query mode: prepared
number of clients: 16
number of threads: 4
duration: 30 s
number of transactions actually processed: 49126
latency average = 9.772 ms
tps = 1637.313156 (including connections establishing)
tps = 1637.438330 (excluding connections establishing)
statement latencies in milliseconds:
1.128 \set aid random(1, 100000 * :scale)
0.068 \set bid random(1, 1 * :scale)
0.040 \set tid random(1, 10 * :scale)
0.041 \set delta random(-5000, 5000)
0.104 BEGIN;
3.815 UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
0.590 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
1.188 UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
1.440 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
0.327 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
0.481 END;
我想知道是否有一种方法可以从结果中计算出 P99,或者我需要向 pgbench 提供一些额外的参数?
-l 导致它写入日志文件。您需要查看这些日志文件以了解延迟。对我来说,看起来像这样:
cat pgbench_log.107915*|wc
36635 219810 1033548
sort pgbench_log.107915* -k3rn|head -n 366|tail -n 1
13 990 65184 0 195589 166574
所以大约 65.184 毫秒是 99% 的延迟。不过,我会质疑这是否真的意味着什么。毕竟,最后一次交易甚至在打开服务器之前不得不等待将近 30 秒,那么为什么它不是 'latency' 30 秒呢?那些根本没有轮到的交易呢?
我正在尝试使用 pgbench 在 PolarDB for postgreSQL 上执行测试。
这是我用来执行测试的命令。
pgbench -M prepared -r -c 16 -j 4 -T 30 -p 10001 -d pgbench -l
这是结果
... ...
client 2 sending P0_10
client 2 receiving
client 2 receiving
client 14 receiving
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 32
query mode: prepared
number of clients: 16
number of threads: 4
duration: 30 s
number of transactions actually processed: 49126
latency average = 9.772 ms
tps = 1637.313156 (including connections establishing)
tps = 1637.438330 (excluding connections establishing)
statement latencies in milliseconds:
1.128 \set aid random(1, 100000 * :scale)
0.068 \set bid random(1, 1 * :scale)
0.040 \set tid random(1, 10 * :scale)
0.041 \set delta random(-5000, 5000)
0.104 BEGIN;
3.815 UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
0.590 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
1.188 UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
1.440 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
0.327 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
0.481 END;
我想知道是否有一种方法可以从结果中计算出 P99,或者我需要向 pgbench 提供一些额外的参数?
-l 导致它写入日志文件。您需要查看这些日志文件以了解延迟。对我来说,看起来像这样:
cat pgbench_log.107915*|wc
36635 219810 1033548
sort pgbench_log.107915* -k3rn|head -n 366|tail -n 1
13 990 65184 0 195589 166574
所以大约 65.184 毫秒是 99% 的延迟。不过,我会质疑这是否真的意味着什么。毕竟,最后一次交易甚至在打开服务器之前不得不等待将近 30 秒,那么为什么它不是 'latency' 30 秒呢?那些根本没有轮到的交易呢?