mysql 读写速度测试工具 sysbench

为了测试mysql的读写速度(tps、qps、iops),可以使用sysbench测试,从阿里云RDS的官方文档可以发现,阿里云的RDS也是采用该工具测试。

下载安装参考:

https://www.cnblogs.com/Nora-F/p/11508248.html

具体使用方法:

安装路径/usr/local/Cellar/sysbench/1.0.16/share/sysbench下已经有软件自带的脚本,从名字中可以看出每个脚本的大致作用。例如oltp_read_only.lua表示测试只读的速度,oltp_read_write.lua表示测试同时读写的速度。

1.准备数据

sysbench /usr/local/Cellar/sysbench/1.0.16/share/sysbench/oltp_read_only.lua --mysql-host=xxx --mysql-port=3306 --mysql-user=root --mysql-password=xxx --oltp-test-mode=complex --oltp-tables-count=10 --oltp-table-size=100000 --threads=10 --time=120 --report-interval=10 prepare 

参数说明:

--mysql-host mysql数据库host
--mysql-port mysql端口号
--mysql-user mysql用户名
--mysql-password mysql密码
--oltp-tables-count 测试表的数量
--oltp-table-size   测试表的大小
--threads           线程数
--time              执行时间
--report-interval   报告产生时间间隔

使用了10个表,每个表有10万条数据,客户端的并发线程数为10,执行时间为120秒,每10秒生成一次报告。

2.执行测试

只读测试

sysbench --mysql-host=xxx --db-driver=mysql --mysql-user=root --mysql-password=xxx --mysql-db=streaming --range_size=100 --table_size=10000 --tables=2 --threads=10 --events=0 --time=120 --rand-type=uniform /usr/local/Cellar/sysbench/1.0.16/share/sysbench/oltp_read_only.lua run

读写测试 

sysbench --mysql-host=xxx --db-driver=mysql --mysql-user=root --mysql-password=xxx --mysql-db=streaming --range_size=100 --table_size=10000 --tables=2 --threads=10 --events=0 --time=120 --rand-type=uniform /usr/local/Cellar/sysbench/1.0.16/share/sysbench/oltp_read_write.lua run

3.查看测试结果

QL statistics:
    queries performed:
        read:                            106036			--读总数
        write:                           30296			-- 写总数
        other:                           15148			-- 其他操作总数(SELECT、INSERT、UPDATE、DELETE之外的操作,例如COMMIT等)  
        total:                           151480			-- 全部总数
    transactions:                        7574   (62.58 per sec.)			-- 总事务数(每秒事务数)
    queries:                             151480 (1251.63 per sec.)			-- 总查询数		
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          121.0239s			--总耗时
    total number of events:              7574				--共发生多少事务数			

Latency (ms):
         min:                                  124.32
         avg:                                  508.65
         max:                                 3238.68
         95th percentile:                     1213.57
         sum:                              3852516.08

Threads fairness:
    events (avg/stddev):           236.6875/27.09
    execution time (avg/stddev):   120.3911/0.21

4、清理数据

测试过程中会在实际数据库创建测试表和数据,测试完毕后可手动清理测试数据。也可以使用sysbench自带的工具清理。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值