ITPub博客

首页 > 数据库 > PostgreSQL > PostgreSQL DBA(173) - pgAdmin(Network latency)

PostgreSQL DBA(173) - pgAdmin(Network latency)

原创 PostgreSQL 作者:husthxd 时间:2020-05-18 17:20:49 0 删除 编辑

不同的网络环境(延时)对数据库的性能指标有很大的影响,下面用tc工具来模拟增加网络延时来观察数据库的性能指标变化.

安装tc
使用python的封装工具tcconfig,安装命令:

pip3 install tcconfig

性能测试
网络无延时

[pg12@localhost ~]$ pgbench -S -c 10 -h localhost -T 20 test
starting vacuum...end.
transaction type: <builtin: select only>
scaling factor: 1
query mode: simple
number of clients: 10
number of threads: 1
duration: 20 s
number of transactions actually processed: 298322
latency average = 0.671 ms
tps = 14911.921647 (including connections establishing)
tps = 14916.752171 (excluding connections establishing)

TPS接近15K

网络延时延时10ms
设置网络延时为10ms

tcset --device lo --delay=10 --overwrite

再次测试

[pg12@localhost ~]$ pgbench -S -c 10 -h 192.168.26.28 -T 20 test
starting vacuum...end.
transaction type: <builtin: select only>
scaling factor: 1
query mode: simple
number of clients: 10
number of threads: 1
duration: 20 s
number of transactions actually processed: 8459
latency average = 23.655 ms
tps = 422.736098 (including connections establishing)
tps = 424.325926 (excluding connections establishing)

TPS直接降至400多,差不多只有原来的1/40

网络延时50ms
设置网络延时为50ms

tcset --device lo --delay=50 --overwrite

再次测试

[pg12@localhost ~]$ pgbench -S -c 10 -h 192.168.26.28 -T 20 test
starting vacuum...end.
transaction type: <builtin: select only>
scaling factor: 1
query mode: simple
number of clients: 10
number of threads: 1
duration: 20 s
number of transactions actually processed: 1650
latency average = 121.406 ms
tps = 82.368327 (including connections establishing)
tps = 83.671552 (excluding connections establishing)

这一次结果是80多,差不多是最初的1/200

为什么OLTP分布式数据库的TPS的提升是很难的一个事情,其中一个原因是网络延时.

参考资料
PostgreSQL: Network latency does make a BIG difference

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/6906/viewspace-2692825/,如需转载,请注明出处,否则将追究法律责任。

全部评论
ITPUB数据库版块资深版主,对Oracle、PostgreSQL有深入研究。

注册时间:2007-12-28

  • 博文量
    1501
  • 访问量
    3963969