码迷,mamicode.com
首页 > 数据库 > 详细

mysql 压力测试工具

时间:2014-12-10 14:24:02      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:msql mysqlslap   压力测试   


mysql  压力测试工具


自从mysql5.1 之后就自带有一个压力测试的工具 mysqlslap

mysqlslap可以自动生成测试脚本 ,也可以使用第三方提供的测试脚本。


mysqlslap可以测试的指标

(1).系统的最大并发度

(2).不同存储引擎之间的性能比较

(3).系统同一变量设置为不同值时的性能比较

(4).不同版本之间的性能比较


mysqlslap 的具体使用方法可以直接查看帮助   mysqlslap --help 


常用的参数有:

--concurrency代表并发数量,多个可以用逗号隔开,当然你也可以用自己的分隔符隔开,这个时候要用到--delimiter开关。

--engines代表要测试的引擎,可以有多个,用分隔符隔开。

--iterations代表要运行这些测试多少次。

--auto-generate-sql 代表用系统自己生成的SQL脚本来测试。

--auto-generate-sql-load-type 代表要测试的是读还是写还是两者混合的(read,write,update,mixed)

--number-of-queries 代表总共要运行多少次查询。每个客户运行的查询数量可以用查询总数/并发数来计算。比如倒数第二个结果2=200/100。

--debug-info 代表要额外输出CPU以及内存的相关信息。

--number-int-cols 代表示例表中的INTEGER类型的属性有几个。

--number-char-cols 意思同上。

--create-schema 代表自己定义的模式(在MySQL中也就是库)。

--query 代表自己的SQL脚本。

--only-print 如果只想打印看看SQL语句是什么,可以用这个选项。


使用mysqlslap自带脚本压力测试:

[root@linuxvm01 ~]# mysqlslap --defaults-file=/usr/my.cnf --concurrency=100,200 --iterations=1 --number-int-cols=4 --number-char-cols=35 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=mixed --engine=innodb,myisam --number-of-queries=10000 --debug-info -uroot -p

Enter password: 

Benchmark

        Running for engine innodb

        Average number of seconds to run all queries: 17.092 seconds

        Minimum number of seconds to run all queries: 17.092 seconds

        Maximum number of seconds to run all queries: 17.092 seconds

        Number of clients running queries: 100

        Average number of queries per client: 100


Benchmark

        Running for engine innodb

        Average number of seconds to run all queries: 17.373 seconds

        Minimum number of seconds to run all queries: 17.373 seconds

        Maximum number of seconds to run all queries: 17.373 seconds

        Number of clients running queries: 200

        Average number of queries per client: 50


Benchmark

        Running for engine myisam

        Average number of seconds to run all queries: 11.350 seconds

        Minimum number of seconds to run all queries: 11.350 seconds

        Maximum number of seconds to run all queries: 11.350 seconds

        Number of clients running queries: 100

        Average number of queries per client: 100


Benchmark

        Running for engine myisam

        Average number of seconds to run all queries: 13.761 seconds

        Minimum number of seconds to run all queries: 13.761 seconds

        Maximum number of seconds to run all queries: 13.761 seconds

        Number of clients running queries: 200

        Average number of queries per client: 50


User time 0.54, System time 0.57

Maximum resident set size 10316, Integral resident set size 0

Non-physical pagefaults 6279, Physical pagefaults 9, Swaps 0

Blocks in 1776 out 0, Messages in 0 out 0, Signals 0

Voluntary context switches 74086, Involuntary context switches 42



输出解释:

Benchmark

        Running for engine myisam

        Average number of seconds to run all queries: 13.761 seconds

        Minimum number of seconds to run all queries: 13.761 seconds

        Maximum number of seconds to run all queries: 13.761 seconds

        Number of clients running queries: 200

        Average number of queries per client: 50

10000个请求,200个线程并发执行,每个线程平均完成50个请求。


使用第三方脚本测试

[root@linuxvm01 ~]# mysqlslap --defaults-file=/usr/my.cnf --create-schema=‘test‘ --concurrency=50,100 --iterations=1 --query=‘select * from  test.temp01 limit 100 ‘ --number-of-queries=5000 --debug-info -uroot -p 

Enter password: 

Benchmark

        Average number of seconds to run all queries: 6.133 seconds

        Minimum number of seconds to run all queries: 6.133 seconds

        Maximum number of seconds to run all queries: 6.133 seconds

        Number of clients running queries: 50

        Average number of queries per client: 100


Benchmark

        Average number of seconds to run all queries: 6.238 seconds

        Minimum number of seconds to run all queries: 6.238 seconds

        Maximum number of seconds to run all queries: 6.238 seconds

        Number of clients running queries: 100

        Average number of queries per client: 50



User time 1.53, System time 1.46

Maximum resident set size 37512, Integral resident set size 0

Non-physical pagefaults 141862, Physical pagefaults 0, Swaps 0

Blocks in 0 out 0, Messages in 0 out 0, Signals 0

Voluntary context switches 504977, Involuntary context switches 43




本文出自 “SQLServer MySQL” 博客,请务必保留此出处http://dwchaoyue.blog.51cto.com/2826417/1588255

mysql 压力测试工具

标签:msql mysqlslap   压力测试   

原文地址:http://dwchaoyue.blog.51cto.com/2826417/1588255

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!