JAVA、PHP、前端、APP、网站开发 - 开发技术学习

开发技术学习 » 数据库 » mysql性能测试sysbench配置使用

mysql性能测试sysbench配置使用

此文被围观2185日期: 2017-06-21 分类 : 数据库  标签:  ·····

网上找的一张图:

倡议:MySQL压力测试建议基准值(2015试行版)


这里我们要说的是sysbench,sysbench安装方法:


https://github.com/akopytov/sysbench#debianubuntu


注意最后一行,一项测试开始前需要用prepare来准备好表和数据,run执行真正的压测,cleanup用来清除数据和表。

1、prepare

shell> sysbench --test=/usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --oltp_tables_count=20 --oltp-table-size=1000000 --mysql-host=10.19.0.2 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test --db-driver=mysql --threads=2500 --time=120 --max-requests=0 --oltp-test-mode=complex prepare


2、run

shell> sysbench --test=/usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --oltp_tables_count=20 --oltp-table-size=1000000 --mysql-host=10.19.0.2 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test --db-driver=mysql --threads=2500 --time=120 --max-requests=0 --oltp-test-mode=complex prepare run >> /var/log/sysbench_oltpx_2017.log


3、cleanup

shell> sysbench --test=/usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --oltp_tables_count=20 --oltp-table-size=100000 --mysql-host=10.19.0.2 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test --db-driver=mysql --threads=2500 --time=120 --max-requests=0 --oltp-test-mode=complex cleanup


参数说明:

--test=tests/db/oltp.lua 表示调用 tests/db/oltp.lua 脚本进行 oltp 模式测试

--oltp_tables_count=10 表示会生成 10 个测试表

--oltp-table-size=100000 表示每个测试表填充数据量为 100000 

--rand-init=on 表示每个测试表都是用随机数据来填充的


--threads=8 表示发起 8个并发连接

--oltp-read-only=off 表示不要进行只读测试,也就是会采用读写混合模式测试

--report-interval=10 表示每10秒输出一次测试进度报告

--rand-type=uniform 表示随机类型为固定模式,其他几个可选随机模式:uniform(固定),gaussian(高斯),special(特定的),pareto(帕累托)

--time=120 表示最大执行时长为 120秒

--max-requests=0 表示总请求数为 0,因为上面已经定义了总执行时长,所以总请求数可以设定为 0;也可以只设定总请求数,不设定最大执行时长

--percentile=99 表示设定采样比例,默认是 95%,即丢弃1%的长请求,在剩余的99%里取最大值

即:模拟 对10个表并发OLTP测试,每个表1000万行记录,持续压测时间为 1小时。

真实测试场景中,建议持续压测时长不小于30分钟,否则测试数据可能不具参考意义。


第二步的结果说明:


sysbench 1.0.7 (using bundled LuaJIT 2.1.0-beta2)


Running the test with following options:

Number of threads: 20

Initializing random number generator from current time



Initializing worker threads...


Threads started!


SQL statistics:

    queries performed:

        read:                            361046 //总select数量

        write:                           103143 //总update insert delete数量

        other:                           51573 //commit unlock tables 以及其它数量

        total:                           515762 //总数

    transactions:                        25784  (214.70 per sec.) //通常需要关注的数TPS

    queries:                             515762 (4294.76 per sec.) //

    ignored errors:                      5      (0.04 per sec.) //

    reconnects:                          0      (0.00 per sec.) //


General statistics:

    total time:                          120.0886s //指定压测时间

    total number of events:              25784 //总的事件数一般与transactions相同


Latency (ms):

         min:                                  2.97

         avg:                                 93.11 //95%的平均响应时间

         max:                               2027.86

         95th percentile:                    183.21 //95%语句执行时间

         sum:                            2400849.05


Threads fairness: //线程公平性

    events (avg/stddev):           1289.2000/7.74

    execution time (avg/stddev):   120.0425/0.02


我们一般关注的用于绘图的指标主要有:


response time avg: 平均响应时间。(后面的95%的大小可以通过--percentile=98的方式去更改)

transactions: 精确的说是这一项后面的TPS 。但如果使用了-oltp-skip-trx=on,这项事务数恒为0,需要用total number of events 去除以总时间,得到tps(其实还可以分为读tps和写tps)

read/write requests: 用它除以总时间,得到吞吐量QPS

当然还有一些系统层面的cpu,io,mem相关指标


站点声明:部分内容源自互联网,为传播信息之用,如有侵权,请联系我们删除。

© Copyright 2011-2024 www.kfju.com. All Rights Reserved.
超级字帖 版权所有。蜀ICP备12031064号