prime从库压测WBS

49 阅读3分钟

一、变更内容

变更背景:优化慢查参数,重启PG服务生效

变更环境:PRD

影响范围:xxx

涉及系统登记:低风险

变更类型:S级

变更负责人:xx

变更复核人:xx

变更内容: PG重启

变更验收标准:PG服务正常




二、变更文档

前置工作

  1. PG的架构
  2. 选择从库 172.21.13.91 进行压测

最大连接数 20000

  1. pg_bech 工具安装部署




详细操作WBS

  1. 创建压测账户

  1. 初始化测试库

# 100个客户,初始化的库大小为1.5G
pgbench -i -s 100 -h  172.21.13.101 -p 1921 -d test -U postgres

3. ### 关闭pg_check

# 检查
systemctl status pgcheck.service

# 关闭
systemctl stop pgcheck.service

4. ### 默认读的方式压测

# 从库 172.21.13.91 , 30秒, 10个client
pgbench -c 10 -T 30 -S -h 172.21.13.91 -p 1921 -d test -U postgres
  1. 10个client
# 从库 172.21.13.91 
pgbench -c 10 -T 30 -S -h 172.21.13.91 -p 1921 -d test -U postgres

  1. 100个client
# 备库 172.21.13.91
pgbench -c 100 -T 30 -S -h 172.21.13.91 -p 1921 -d test -U postgres

  1. 500个client
# 备库 172.21.13.91 
pgbench -c 500 -T 30 -S -h 172.21.13.91 -p 1921 -d test -U postgres

  1. 1000个client
# 
pgbench -c 1000 -T 30 -S -h 172.21.13.91 -p 1921 -d test -U postgres

5. 1500个client

# 
pgbench -c 1500 -T 120 -S -h 172.21.13.91 -p 1921 -d test -U postgres

  1. 2000个client
# 
pgbench -c 2000 -T 30 -S -h 172.21.13.91 -p 1921 -d test -U postgres

# 
pgbench -c 2000 -T 120 -S -h 172.21.13.91 -p 1921 -d test -U postgres

  1. 2500个client
# 备库 172.21.13.91 
pgbench -c 2500 -T 30 -S -h 172.21.13.91 -p 1921 -d test -U postgres

8. 5000个client

# 备库 172.21.13.91 (开启大页)
pgbench -c 5000 -T 120 -S -h 172.21.13.91 -p 1921 -d test -U postgres

关闭标准大页

# 备库 172.21.13.91 
pgbench -c 5000 -T 120 -S -h 172.21.13.91 -p 1921 -d test -U postgres

  1. 10000个client
# 备库 172.21.13.91 (开启大页)
pgbench -c 10000 -T 120 -S -h 172.21.13.91 -p 1921 -d test -U postgres

大页关闭

# 备库 172.21.13.91 
pgbench -c 10000 -T 120 -S -h 172.21.13.91 -p 1921 -d test -U postgres

  1. 18000个client
# 备库 172.21.13.91 
pgbench -c 18000-T 120 -S -h 172.21.13.91 -p 1921 -d test -U postgres

5. ### 自定义sql的读压测(可选)

# 自定义读测试脚本
-- read_test.sql
\set aid random(1, 100000)
SELECT abalance FROM accounts WHERE aid = :aid;

# 
# 执行读测试
pgbench -c 10 -T 30 -f read_test.sql -h xxx -p 1921 -d test -U postgres






# 10个client
pgbench -c 10 -T 30 -f read_test.sql -h 172.21.13.91 -p 1921 -d test -U postgres

# 20个
pgbench -c 20 -T 30 -f read_test.sql -h 172.21.13.91 -p 1921 -d test -U postgres

# 100个
pgbench -c 100 -T 30 -f read_test.sql -h 172.21.13.91 -p 1921 -d test -U postgres

# 500个
pgbench -c 500 -T 30 -f read_test.sql -h 172.21.13.91 -p 1921 -d test -U postgres

# 1000个
pgbench -c 1000 -T 30 -f read_test.sql -h 172.21.13.91 -p 1921 -d test -U postgres

# 1500个
pgbench -c 1500 -T 30 -f read_test.sql -h 172.21.13.91 -p 1921 -d test -U postgres

# 2000个
pgbench -c 2000 -T 30 -f read_test.sql -h 172.21.13.91 -p 1921 -d test -U postgres

6. ### 恢复pg_check

# 
systemctl start pgcheck.service

回滚方案

  1. 停止压测

  2. 恢复从库PG




三、变更记录

变更执行记录

双岗复核记录

验证记录

172.21.13.91

项目6.5压测5.17高峰
监控infra-grafana.hwwt2.com/d/Des2V5iSk…infra-grafana.hwwt2.com/d/Des2V5iSk…
CPU
内存使用率
TCP
session
复制延迟
transcations
fetch
return
buffers
lock tables
句柄数