mysql benchmark基准测试
时间:2022-04-22
本文章向大家介绍mysql benchmark基准测试,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
git项目地址:
https://github.com/akopytov/sysbench
利用sysbench很容易对mysql做性能基准测试(当然这个工具很强大,除了测试主流数据库性能,还能测试其它方面,详情自己看官网项目文档)
mac上的用法:
一、安装
brew install sysbench
二、先在mysql上创建一个专门的测试数据库,比如test
三、利用sysbench先生成测试数据
sysbench --test=oltp --oltp-table-size=5000000 --oltp-table-name=t_test
--mysql-table-engine=innodb
--mysql-host=localhost
--mysql-db=test
--mysql-user=root
--mysql-password=***
prepare
上面这一堆的意思,是在本机localhost的test数据库的t_test中创建500万条测试数据,表的数据库引擎为innodb.
tips:如果想知道还有哪些参数可用,可输入命令
sysbench --test=oltp help
centos上如果用yum install sysbench安装的话,运行时可能会出现
FATAL: no database driver specified FATAL: failed to initialize database driver!
可以加上参数 --db-driver=mysql ,原因是yum方式安装时,同时安装了mysql与其它数据库的驱动,不指定驱动类型的话,sysbench不知道你是要测试是mysql,还是oracle之类的其它数据库
四、运行测试
sysbench --test=oltp --oltp-table-size=5000000 --oltp-table-name=t_test
--mysql-table-engine=innodb
--mysql-host=localhost
--mysql-db=test
--mysql-user=root
--mysql-password=***
run
最后一个prepare改成run就行了,测试完后,会输出类似以下结果:
sysbench 0.4.12: multi-threaded system evaluation benchmark
No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 1
Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations, 1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 10000
Threads started!
Done.
OLTP test statistics:
queries performed:
read: 140000
write: 50000
other: 20000
total: 210000
transactions: 10000 (514.48 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 190000 (9775.14 per sec.)
other operations: 20000 (1028.96 per sec.)
Test execution summary:
total time: 19.4371s
total number of events: 10000
total time taken by event execution: 19.3581
per-request statistics:
min: 1.65ms
avg: 1.94ms
max: 13.48ms
approx. 95 percentile: 2.34ms
Threads fairness:
events (avg/stddev): 10000.0000/0.00
execution time (avg/stddev): 19.3581/0.00
一般我们比较关心:
transactions: 10000 (514.48 per sec.)
read/write requests: 190000 (9775.14 per sec.)
这代表每秒能处理的事务数,以及每秒的读写次数。
五、清理测试数据
sysbench --test=oltp --oltp-table-size=5000000 --oltp-table-name=t_test
--mysql-table-engine=innodb
--mysql-host=localhost
--mysql-db=test
--mysql-user=root
--mysql-password=***
cleanup
最后一个换成cleanup即可。
春晚实在太无聊了,还不如写二行代码有意思,祝各位园友猴年大吉,身体健康,心想事成!
- React技巧8(不再手动绑定this,跟.bind(this)说88)
- 美美的商务范儿——ggplot2蝴蝶图
- 机器学习(三)使用Python和R语言从头开始理解和编写神经网络介绍目录神经网络背后的直观知识多层感知器及其基础知识什么是激活函数?前向传播,反向传播和训练次数(epochs)多层感知器全批量梯度下降
- React第三方组件2(状态管理之Refast的使用⑤LogicRender使用)
- 左右用R右手Python9——字符串合并与拆分
- hdu 1003 Max Sum(最大子窜和)
- React第三方组件2(状态管理之Refast的使用④中间件middleware使用)
- 高维分面应用——ggplot2分面气泡图饼图
- poj 1579 Function Run Fun
- React第三方组件2(状态管理之Refast的使用③扩展ctx)
- 财经小知识——CRS风暴与全球离岸金融中心
- The Triangle
- React第三方组件2(状态管理之Refast的使用②异步修改state)
- UVa Automatic Editing
- MySQL 教程
- MySQL 安装
- MySQL 管理与配置
- MySQL PHP 语法
- MySQL 连接
- MySQL 创建数据库
- MySQL 删除数据库
- MySQL 选择数据库
- MySQL 数据类型
- MySQL 创建数据表
- MySQL 删除数据表
- MySQL 插入数据
- MySQL 查询数据
- MySQL where 子句
- MySQL UPDATE 查询
- MySQL DELETE 语句
- MySQL LIKE 子句
- mysql order by
- Mysql Join的使用
- MySQL NULL 值处理
- MySQL 正则表达式
- MySQL 事务
- MySQL ALTER命令
- MySQL 索引
- MySQL 临时表
- MySQL 复制表
- 查看MySQL 元数据
- MySQL 序列 AUTO_INCREMENT
- MySQL 处理重复数据
- MySQL 及 SQL 注入
- MySQL 导出数据
- MySQL 导入数据
- MYSQL 函数大全
- MySQL Group By 实例讲解
- MySQL Max()函数实例讲解
- mysql count函数实例
- MYSQL UNION和UNION ALL实例
- MySQL IN 用法
- MySQL between and 实例讲解
- 如何基于Python代码实现高精度免费OCR工具
- python怎么调用自己的函数
- Python datetime模块使用方法小结
- PHP hebrev()函数用法讲解
- PHP hex2bin()函数用法讲解
- PHP+jQuery实现即点即改功能示例
- PHP html_entity_decode()函数讲解
- PHP下载大文件失败并限制下载速度的实例代码
- thinkphp5框架实现的自定义扩展类操作示例
- python导入库的具体方法
- PHP+jQuery实现双击修改table表格功能示例
- 基于ThinkPHP5框架使用QueryList爬取并存入mysql数据库操作示例
- Laravel推荐使用的十个辅助函数
- PHP htmlentities()函数用法讲解
- thinkphp5框架API token身份验证功能示例