MySQL性能测试工具之mysqlslap使用详解
mysqlslap是mysql自带的基准测试工具,优点:查询数据,语法简单,灵活容易使用.该工具可以模拟多个客户端同时并发的向服务器发出查询更新,给出了性能测试数据而且提供了多种引擎的性能比较.msqlslap为mysql性能优化前后提供了直观的验证依据,建议系统运维和DBA人员应该掌握一些常见的压力测试工具,才能准确的掌握线上数据库支撑的用户流量上限及其抗压性等问题。
常用的选项
--concurrency 并发数量,多个可以用逗号隔开
--engines 要测试的引擎,可以有多个,用分隔符隔开,如--engines=myisam,innodb
--iterations 要运行这些测试多少次
--auto-generate-sql 用系统自己生成的SQL脚本来测试
--auto-generate-sql-load-type 要测试的是读还是写还是两者混合的(read,write,update,mixed)
--number-of-queries 总共要运行多少次查询。每个客户运行的查询数量可以用查询总数/并发数来计算
--debug-info 额外输出CPU以及内存的相关信息
--number-int-cols 创建测试表的int型字段数量
--number-char-cols 创建测试表的chat型字段数量
--create-schema 测试的database
--query 自己的SQL 脚本执行测试
--only-print 如果只想打印看看SQL语句是什么,可以用这个选项
实例1
说明:测试100个并发线程,测试次数1次,自动生成SQL测试脚本,读、写、更新混合测试,自增长字段,测试引擎为innodb,共运行5000次查询
#mysqlslap -h127.0.0.1 -uroot -p123456789 --concurrency=100 --iterations=1 --auto-generate-sql --auto-generate-sql-load-type=mixed --auto-generate-sql-add-autoincrement --engine=innodb --number-of-queries=5000
Benchmark
Running for engine innodb
Average number of seconds to run all queries: 0.351 seconds 100个客户端(并发)同时运行这些SQL语句平均要花0.351秒
Minimum number of seconds to run all queries: 0.351 seconds
Maximum number of seconds to run all queries: 0.351 seconds
Number of clients running queries: 100 总共100个客户端(并发)运行这些sql查询
Average number of queries per client:50 每个客户端(并发)平均运行50次查询(对应--concurrency=100,--number-of-queries=5000;5000/100=50)
实例2
#mysqlslap -h127.0.0.1 -uroot -p123456789 --concurrency=100,500,1000 --iterations=1 --auto-generate-sql --auto-generate-sql-load-type=mixed --auto-generate-sql-add-autoincrement --engine=innodb --number-of-queries=5000 --debug-info
Benchmark
Running for engine innodb
Average number of seconds to run all queries: 0.328 seconds
Minimum number of seconds to run all queries: 0.328 seconds
Maximum number of seconds to run all queries: 0.328 seconds
Number of clients running queries: 100
Average number of queries per client: 50
Benchmark
Running for engine innodb
Average number of seconds to run all queries: 0.358 seconds
Minimum number of seconds to run all queries: 0.358 seconds
Maximum number of seconds to run all queries: 0.358 seconds
Number of clients running queries: 500
Average number of queries per client: 10
Benchmark
Running for engine innodb
Average number of seconds to run all queries: 0.482 seconds
Minimum number of seconds to run all queries: 0.482 seconds
Maximum number of seconds to run all queries: 0.482 seconds
Number of clients running queries: 1000
Average number of queries per client: 5
User time 0.21, System time 0.78
Maximum resident set size 21520, Integral resident set size 0
Non-physical pagefaults 12332, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 36771, Involuntary context switches 1396
实例3(自定义sql语句)
#mysqlslap -h127.0.0.1 -uroot -p123456789 --concurrency=100 --iterations=1 --create-schema=rudao --query='select * from serverlist;' --engine=innodb --number-of-queries=5000 --debug-info
Benchmark
Running for engine innodb
Average number of seconds to run all queries: 0.144 seconds
Minimum number of seconds to run all queries: 0.144 seconds
Maximum number of seconds to run all queries: 0.144 seconds
Number of clients running queries: 100
Average number of queries per client: 50
User time 0.05, System time 0.09
Maximum resident set size 6132, Integral resident set size 0
Non-physical pagefaults 2078, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 6051, Involuntary context switches 90
实例4(指定sql脚本)
#mysqlslap -h127.0.0.1 -uroot -p123456789 --concurrency=100 --iterations=1 --create-schema=rudao --query=/tmp/query.sql --engine=innodb --number-of-queries=5000 --debug-info
Warning: Using a password on the command line interface can be insecure.
Benchmark
Running for engine innodb
Average number of seconds to run all queries: 0.157 seconds
Minimum number of seconds to run all queries: 0.157 seconds
Maximum number of seconds to run all queries: 0.157 seconds
Number of clients running queries: 100
Average number of queries per client: 50
User time 0.07, System time 0.08
Maximum resident set size 6152, Integral resident set size 0
Non-physical pagefaults 2107, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 6076, Involuntary context switches 89
MySQL性能测试工具之mysqlslap使用详解的更多相关文章
- MySQL性能测试工具之mysqlslap
MySQL性能测试工具之mysqlslap [日期:2014-10-05] 来源:Linux社区 作者:tongcheng [字体:大 中 小] --转自Linux社区:http://www.l ...
- MySQL数据库使用mysqldump导出数据详解
mysqldump是mysql用于转存储数据库的实用程序.它主要产生一个SQL脚本,其中包含从头重新创建数据库所必需的命令CREATE TABLE INSERT等.接下来通过本文给大家介绍MySQL数 ...
- 【转】MySQL用户管理及SQL语句详解
[转]MySQL用户管理及SQL语句详解 1.1 MySQL用户管理 1.1.1 用户的定义 用户名+主机域 mysql> select user,host,password from mysq ...
- MySQL数据库的各种存储引擎详解
原文来自:MySQL数据库的各种存储引擎详解 MySQL有多种存储引擎,每种存储引擎有各自的优缺点,大家可以择优选择使用: MyISAM.InnoDB.MERGE.MEMORY(HEAP).BDB ...
- (转)总结之:CentOS 6.5 MySQL数据库的基础以及深入详解
总结之:CentOS 6.5 MySQL数据库的基础以及深入详解 原文:http://tanxw.blog.51cto.com/4309543/1395539 前言 早期MySQL AB公司在2009 ...
- MYSQL之数据库初识、安装详解、sql语句基本操作
目录 MYSQL之数据库初识及安装详解 1.什么是数据库? 1.什么是数据?(data) 2.什么是数据库?(databases,简称DB) 2.为什要用数据库? 3.什么是数据库管理系统?(Data ...
- MySQL的用户密码过期功能详解
MySQL的用户密码过期功能详解 作者:chszs,未经博主允许不得转载.经许可的转载需注明作者和博客主页:http://blog.csdn.net/chszs 先说明两个术语. Payment Ca ...
- MySql绿色版配置及使用详解
原文:MySql绿色版配置及使用详解 最近在做项目开发时用到了MySql数据库,在看了一些有关MySql的文章后,很快就上手使用了.在使用的过程中还是出现了一些问题,因为使用的是绿色免安装版的MySq ...
- mysql数据库分区功能及实例详解
分区听起来怎么感觉是硬盘呀,对没错除了硬盘可以分区数据库现在也支持分区了,分区可以解决大数据量的处理问题,下面一起来看一个mysql数据库分区功能及实例详解 一,什么是数据库分区 前段时间写过一篇 ...
随机推荐
- Bluetooth LE(低功耗蓝牙) - 第二部分
回顾 在前面的文章中我们介绍了Bluetooth LE的背景也说明了我们在本系列文章中将要开发什么,但是还没有实际的代码.我们将在这篇文章中纠正这一点,我们将通过定义 Service/Activity ...
- 此集合已经采用方案 http 的地址。此集合中每个方案中最多只能包含一个地址。
错误信息:此集合已经采用方案 http 的地址.此集合中每个方案中最多只能包含一个地址.如果服务承载于 IIS 中,则可以通过将“system.serviceModel/serviceHostingE ...
- 凯撒密码 CH Round #57 - Story of the OI Class
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2357%20-%20Story%20of%20the%20OI%20Class/凯撒密码 题解:刚开始想map, ...
- javascipt取整数四舍五入
1.丢弃小数部分,保留整数部分 parseInt(5/2) 2.向上取整,有小数就整数部分加1 Math.ceil(5/2) 3,四舍五入. Math.round(5/2) 4,向下取整 Math.f ...
- Python IDLE 清屏工具
转载自:http://www.cnblogs.com/maybego/p/3234055.html 1.下载clearwindow.py(右击-目标另存为,直接点击会打开脚本内容). 2.拷贝c ...
- How to disable Eclipse splash
Run eclipse with the -nosplash option.
- HTTP协议介绍(SERVLET)
本文是servlet的入门篇,主要简单介绍下http协议 1.什么是HTTP _ 1.http协议:_1. 复杂解释: http(超文本传输协议)是一个基于请求与响应模式的.无状态的.应用层的协议 ...
- smarty、thinkphp中的html加载其他的html文件的方式
1.smarty 在模板文件中,使用定界符 {include file="header.html"} 不可以省略.html 2.thinkphp的html文件中 <incl ...
- IAAS云计算产品畅想-云主机产品内涵
这里所涉及的主要还是狭义的云主机产品. 主要还是谈云主机产品中公有云产品与私有云产品相比赋予更多的含义: 产品广义理解:公有云主机的最大特点就是基础资源按需支付 从这一句话中可以体现出来两个含义: 产 ...
- const char*, char const* and char *const 分类: C/C++ OpenCV 2014-11-08 18:10 114人阅读 评论(0) 收藏
const char*, char const*, char*const的区别问题几乎是C++面试中每次都会有的题目. 事实上这个概念谁都有只是三种声明方式非常相似很容易记混. Bjarne在他的 ...