代码改变世界

sysbench基准测试(2)——oltp.lua测试

2016-10-09 20:21  宏愿。  阅读(4738)  评论(2编辑  收藏  举报

 

 

前面知道sysbench基准测试的主要步骤为:prepare(准备数据集)→ run(运行测试)→ cleanup(清除数据集)

 

这一节介绍oltp.lua测试。

oltp基准测试模拟了一个简单的事物处理系统的工作负载。

 

①、准备数据集(使用test数据库,用户名root,密码123456,表数目8,每张表记录10万,测试oltp.lua):

[root@localhost db]# sysbench --test=oltp.lua --mysql-db=test --mysql-user=root --mysql-password=123456 --oltp-tables-count=8 --oltp-table-size=100000 prepare

 

对选项作如下说明:

--test=oltp.lua  //测试用的lua脚本,可以使用绝对路径。该脚本位于sysbench源码包的“sysbench-1.0/sysbench/tests/db/”文件夹下面。当然,你也可以自己写lua脚本。

--mysql-db=test           //测试数据库

--mysql-user=root        //用户名

--myssql-password=123456   //密码

--oltp-tables-count=8      //数据表

--oltp-table-size=100000    //每张表记录为10万

执行结果是:在test数据库中创建8张表,表名分别为“sbtest1...8”,每张表中有记录10万条。

 

②、执行oltp基础测试(线程数10,最大执行时间60s,只读off,打印信息间隔10s):

[root@localhost db]# sysbench --test=oltp.lua --mysql-db=test --mysql-user=root --mysql-password=123456 \
--oltp-tables-count=8 --oltp-table-size=100000 --num-threads=10 --max-time=60 --report-interval=10 --oltp-read-only=off run

 

对选项作如下说明:

--num-threads=10    //线程数为10

--max-time=60      //测试时间为60s

--report-interval=10    //报告打印周期为10s

--oltp-read-only=off    //非只读操作测试

运行结果如下:

sysbench 1.0: multi-threaded system evaluation benchmark

Running the test with following options:  //测试属性,可以通过选项设定
Number of threads: 10
Report intermediate results every 10 second(s)
Initializing random number generator from current time


Initializing worker threads...

Threads started!

//每10秒钟报告一次测试结果,tps、每秒读、每秒写、99%以上的响应时长统计

[ 10s] threads: 10, tps: 81.24, reads: 1149.41, writes: 325.75, response time: 280.29ms (95%), errors: 0.00, reconnects: 0.00
[ 20s] threads: 10, tps: 72.20, reads: 1012.70, writes: 292.00, response time: 318.42ms (95%), errors: 0.00, reconnects: 0.00
[ 30s] threads: 10, tps: 79.40, reads: 1111.60, writes: 317.60, response time: 284.35ms (95%), errors: 0.00, reconnects: 0.00
[ 40s] threads: 10, tps: 74.00, reads: 1034.59, writes: 295.60, response time: 350.64ms (95%), errors: 0.00, reconnects: 0.00
[ 50s] threads: 10, tps: 80.90, reads: 1127.81, writes: 320.90, response time: 309.40ms (95%), errors: 0.10, reconnects: 0.00
[ 60s] threads: 10, tps: 79.90, reads: 1126.20, writes: 322.80, response time: 309.03ms (95%), errors: 0.00, reconnects: 0.00
OLTP test statistics:
queries performed: //性能统计
read: 65632     //读总数,select语句
write: 18749    //写总数,insert、delete、update语句
other: 9375     //其它语句,如commit等
total: 93756           //总的执行语句数
transactions: 4687 (78.06 per sec.)  //总的事物数(每秒处理事物数
read/write requests: 84381 (1405.28 per sec.)  //读写请求次数(每秒的读写次数
other operations: 9375 (156.13 per sec.)    //其它操作的每秒执行数
ignored errors: 1 (0.02 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 60.0456s        //总时间
total number of events: 4687    //事物总数
total time taken by event execution: 600.0783s   //所有事务耗时相加(不考虑并行因素)
response time:    //应答时间
min: 31.96ms    //最小
avg: 128.03ms    //平均
max: 690.49ms    //最大
approx. 95 percentile: 317.65ms  //95%语句执行时间

Threads fairness:  //线程公平性
events (avg/stddev): 468.7000/5.04
execution time (avg/stddev): 60.0078/0.01

最重要的参数指标:

总的事物数,每秒事务数,时间统计信息(最大、最小、平均、95%以上语句响应时间)

 

③、删除测试数据集

[root@localhost db]# sysbench --test=oltp.lua --mysql-db=test --mysql-user=root --mysql-password=123456 --oltp-tables-count=8 --oltp-table-size=100000 cleanup

 

 

后续:

这里的测试使用的是sysbench自带的oltp.lua脚本。也可以写自己的lua脚本来做相关测试。呃,可是lua不会...