mysql 压测结果_mysql压测实战

1、安装压测工具curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh | sudo bash yum -y install sysbench

2、执行压测命令sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=192.168.115.101 --mysql-port=3306 --mysql-user=test_user --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable prepare

命令解释:--db-driver=mysql:这个很简单,就是说他基于mysql的驱动去连接mysql数据库,你要是oracle,或者sqlserver,那 自然就是其他的数据库的驱动了

--time=300:这个就是说连续访问300秒

--threads=10:这个就是说用10个线程模拟并发访问

--report-interval=1:这个就是说每隔1秒输出一下压测情况

--mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=test_user --mysql-password=test_user:这一大串,就 是说连接到哪台机器的哪个端口上的MySQL库,他的用户名和密码是什么

--mysql-db=test_db --tables=20 --table_size=1000000:这一串的意思,就是说在test_db这个库里,构造20个测试 表,每个测试表里构造100万条测试数据,测试表的名字会是类似于sbtest1,sbtest2这个样子的

oltp_read_write:这个就是说,执行oltp数据库的读写测试

--db-ps-mode=disable:这个就是禁止ps模式 最后有一个prepare,意思是参照这个命令的设置去构造出来我们需要的数据库里的数据,他会自动创建20个测试表,每个表 里创建100万条测试数据,所以这个工具是非常的方便的。

测试数据库的综合读写TPS,使用的是oltp_read_write模式(大家看命令中最后不是prepare,是run了,就是运行压测):sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=192.168.115.101 --mysql-port=3306 --mysql-user=test_user --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_write --db-ps-mode=disable run

dae2350f261e823f50f2384bc4ae0a2a.png

对测试输出日志进行解释[ 300s ] thds: 10 tps: 291.54 qps: 5792.65 (r/w/o: 4051.45/1158.13/583.07) lat (ms,95%): 77.19 err/s: 0.00 reconn/s: 0.00

[300s] ,整个压测过程第三百秒

thds:10 , 这个意思就是有10个线程在压测

tps:291.54,  这个意思就是每秒执行了291.54 个事务

qps: 5792.65 ,这个意思就是每秒可以执行5792.65个请

(r/w/o: 4051.45/1158.13/583.07)  ,这个意思就是说,在每秒5792.65个请求中,有4051.45个请求是读请求,1158.13个请 求是写请求,583.07个请求是其他的请求,就是对QPS进行了拆解

lat (ms,95%): 77.19 ,这个意思就是说,95%的请求的延迟都在77.19毫秒以下

err/s: 0.00 reconn/s: 0.00  这两个的意思就是说,每秒有0个请求是失败的,发生了0次网络重连

这个压测结果会根据每个人的机器的性能不同有很大的差距(真机 i5 9300H 1T SSD  16GB RAM,当前压测虚拟机配置 4核4GB RAM 40GB ROM配置),你要是机器性能特别高,那你可以开很多的并发线程去压测,比 如100个线程,此时可能会发现数据库每秒的TPS有上千个,如果你的机器性能很低,可能压测出来你的TPS才二三十个,QPS 才几百个,这都是有可能的。

另外在完成压测之后,最后会显示一个总的压测报告,我把解释写在下面了:

SQL statistics:

queries performed:

read:                            1181852           // 这就是说在300s的压测期间执行了118万多次的读请求

write:                           337672             // 这是说在压测期间执行了33万多次的写请求

other:                           168836            // 这是说在压测期间执行了16万多次的其他请求

total:                           1688360           // 这是说一共执行了168万多次的请求

transactions:                        84418  (281.37 per sec.)          // 这是说一共执行了8.4万多个事务,每秒执行281.37多个事务

queries:                             1688360 (5627.36 per sec.)       // 这是说一共执行了168万多次的请求,每秒执行5600+请求

ignored errors:                      0      (0.00 per sec.)

reconnects:                          0      (0.00 per sec.)

//下面就是说,一共执行了300s的压测,执行了8.4万+的事务

General statistics:

total time:                          300.0253s

total number of events:              84418

Latency (ms):

min:                                    6.90                        // 请求中延迟最小的是6.9ms

avg:                                   35.54                      // 请求中延迟平均是35.54ms

max:                                  287.21                    //请求中延迟最大是287.21ms

95th percentile:                       77.19               //95%的请求延迟都在77.19ms以内

sum:                              2999805.01

Threads fairness:

events (avg/stddev):           8441.8000/46.41

execution time (avg/stddev):   299.9805/0.01

测试数据库的只读性能,使用的是oltp_read_only模式(大家看命令中的oltp_read_write已经变为oltp_read_only了):sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=192.168.115.101 --mysql-port=3306 --mysql-user=test_user --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_read_only --db-ps-mode=disable run

测试数据库的删除性能,使用的是oltp_delete模式:sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=192.168.115.101 --mysql-port=3306 --mysql-user=test_user --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_delete --db-ps-mode=disable run

测试数据库的更新索引字段的性能,使用的是oltp_update_index模式:sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=192.168.115.101 --mysql-port=3306 --mysql-user=test_user --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_update_index --db-ps-mode=disable run

测试数据库的更新非索引字段的性能,使用的是oltp_update_non_index模式sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=192.168.115.101 --mysql-port=3306 --mysql-user=test_user --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_update_non_index --db-ps-mode=disable run

测试数据库的插入性能,使用的是oltp_insert模式sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=192.168.115.101 --mysql-port=3306 --mysql-user=test_user --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_insert --db-ps-mode=disable run

测试数据库的写入性能,使用的是oltp_write_only模式:sysbench --db-driver=mysql --time=300 --threads=10 --report-interval=1 --mysql-host=192.168.115.101 --mysql-port=3306 --mysql-user=test_user --mysql-password=123456 --mysql-db=test_db --tables=20 --table_size=1000000 oltp_write_only --db-ps-mode=disable run

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值