mysql压力测试工具mysqlslap简介

压力测试是数据库不可或缺一种测试手段,然而在测试过程中模拟各种测试条件是
一件非常棘手的问题,在此推荐一个专用于mysql数据库的压力测试工具mysqlslap,
帮助大家完成mysql的压力测试工作。

mysqlslap的官方使用说明:http://dev.mysql.com/doc/refman/5.1/en/mysqlslap.html

这里根据项目组中实际使用的情况举例说明。

#mysqlslap参数说明:
#-c 模拟客户端的数量;--number-of-queries 所有模拟客户端每一次SQL请求的数量;-i 迭代次数;

例1:
[root@db2 bin]# ./mysqlslap -h db2 -P 3306 -u msandbox -pmsandbox --create-schema=mry_production2 --query='SELECT * FROM contents WHERE (place_id = 20 and invisible IS NOT TRUE AND charge_free IS NULL)' -c 10 -i 30 --number-of-queries 3000
测试结果:

Benchmark
        Average number of seconds to run all queries: 34.350 seconds
        Minimum number of seconds to run all queries: 32.869 seconds
        Maximum number of seconds to run all queries: 36.117 seconds
        Number of clients running queries: 10
        Average number of queries per client: 300

 

例2:

[root@db1 ~]# mysqlslap -h db1 -P 3306 -u root -pcps-pt --create-schema=mry_production --query='SELECT *  FROM contents WHERE (place_id = 20 and invisible IS NOT TRUE AND charge_free IS NULL)'  -c 10 -i 30    --number-of-queries 3000

测试结果:
   Benchmark
        Average number of seconds to run all queries: 13.451 seconds
        Minimum number of seconds to run all queries: 12.871 seconds
        Maximum number of seconds to run all queries: 14.327 seconds
        Number of clients running queries: 10
        Average number of queries per client: 300

这个命令的含义就是对指定的数据库,模拟10个客户端(-c ),每个客户端执行300次( --number-of-queries ),总共执行30个迭代指定的SQL查询(-i )。

你可能感兴趣的:(sql,C++,c,mysql,C#)