sysbench工具测试query cache对性能的影响
2016-08-27 06:57
323 查看
一.sysbench安装和使用说明
1.下载sysbench工具
wget sysbench-0.5.tar.gz
cd /data/software
tar -zxvf sysbench-0.5.tar.gz
2.安装相关包
yum install -y bzr
yum install -y libtool
3.编译安装
cd /data/software/sysbench-0.5/
chmod a+x *
./autogen.sh
./configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib
make
make install
sysbench --help
数据测试参数说明:
测试工具:sysbench 0.5
测试流程:通过对innodb引擎和myisam引擎的压力测试,得出两种引擎的性能表现
测试模型:采用OLTP模型。大致命令如下:
常用命令参数:
/usr/local/bin/sysbench
--mysql-host=127.0.0.1 #数据库host
--mysql-port=3306 #数据库端口
--mysql-user=admin #数据库用户名
--mysql-password=admin #数据库密码
--mysql-db=test #数据库名
--oltp-tables-count=10 #模拟的表的个数,规格越高该值越大
--oltp-table-size=1000000 #模拟的每张表的行数,规格越高该值越大
--num-threads=100 #模拟的并发数量,规格越高该值越大
--max-requests=10000 #最大请求次数
--max-time=20 #最大测试时间(与--max-requests只要有一个超过,则退出)
--report-interval=1 #每1秒打印一次当前的QPS等值
---mysql-socket=/tmp/mysql3306.sock
[prepare | run | cleanup] #prepare准备数据,run执行测试,cleanup清理数据
--oltp-dist-type=uniform :指定随机取样类型,可选值有 uniform(均匀分布), Gaussian(高斯分布), special(空间分布)
--oltp_table_count=1:指定测试过程中表的个数,0.5新增,0.4整个测试过程只有一个表。
--oltp-table-size=:指定表的大小,如果指定1000,那么它会往表里初始化1000条数据
--rand-init=on:是否随机初始化数据,如果不随机化那么初始好的数据每行内容除了主键不同外其他完全相同。
--num-threads=:测试过程中并发线程数,看测试要求来定并发压力
--test=tests/db/oltp.lua 表示调用 tests/db/oltp.lua 脚本进行 oltp 模式测试
--oltp_tables_count=10 表示会生成 10 个测试表
--oltp-table-size=100000 表示每个测试表填充数据量为 100000
--rand-init=on 表示每个测试表都是用随机数据来填充的
--rand-type=uniform 表示随机类型为固定模式,其他几个可选随机模式:uniform(固定),gaussian(高斯),special(特定的),pareto(帕累托)
--oltp-read-only=off 表示不要进行只读测试,也就是会采用读写混合模式测试
--num-threads=128 表示发起 128个并发连接
--report-interval=10 表示每10秒输出一次测试进度报告
--max-time=120 表示最大执行时长为 120秒
--max-requests=0 表示总请求数为 0,因为上面已经定义了总执行时长,所以总请求数可以设定为 0;也可以只设定总请求数,不设定最大执行时长
--percentile=99 表示设定采样比例,默认是 95%,即丢弃1%的长请求,在剩余的99%里取最大值
二.环境信息
硬件配置:
虚拟机vmware
cpu : 8个 Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz
内存:64G
mysql参数配置:
innodb_buffer_pool_size =11G
key_buffer_size = 64M
max_binlog_size = 128M
binlog_cache_size = 1M
sync_binlog=0
innodb_flush_log_at_trx_commit=2
innodb_log_file_size = 256M
innodb_log_buffer_size = 16M
MySQL版本:mysql 5.6.24
三.关闭QC
query_cache_size=0
query_cache_type=off
1.准备数据:
读写:
sysbench --test=/data/software/sysbench-0.5/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --oltp-table-size=1000000 --max-requests=0 \
--num-threads=100 --oltp_tables_count=10 --rand-init=on --oltp-read-only=off --report-interval=10 --rand-type=uniform --percentile=99 \
--mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=admin --mysql-password=admin \
--mysql-db=test --oltp-range-size=40 --oltp-point-selects=10 --oltp-simple-ranges=1 --oltp-sum-ranges=1 --oltp-order-ranges=1 --oltp-distinct-ranges=1 \
--oltp-index-updates=1 --oltp-non-index-updates=1 --mysql-socket=/tmp/mysql3306.sock prepare
2.测试:
sysbench --test=/data/software/sysbench-0.5/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --oltp-table-size=1000000 --max-time=600 --max-requests=0 \
--num-threads=100 --oltp_tables_count=10 --rand-init=on --oltp-read-only=off --report-interval=10 --rand-type=uniform --percentile=99 \
--mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=admin --mysql-password=admin \
--mysql-db=test --oltp-range-size=40 --oltp-point-selects=10 --oltp-simple-ranges=1 --oltp-sum-ranges=1 --oltp-order-ranges=1 --oltp-distinct-ranges=1 \
--oltp-index-updates=1 --oltp-non-index-updates=1 --mysql-socket=/tmp/mysql3306.sock run
OLTP test statistics:
queries performed:
read: 23751980
write: 6786280
other: 3393140
total: 33931400
transactions: 1696570 (2827.56 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 30538260 (50896.15 per sec.)
other operations: 3393140 (5655.13 per sec.)
Test execution summary:
total time: 600.0112s
total number of events: 1696570
total time taken by event execution: 59999.0893s
per-request statistics:
min: 2.13ms
avg: 35.36ms
max: 322.02ms
approx. 99 percentile: 111.12ms
Threads fairness:
events (avg/stddev): 16965.7000/151.74
execution time (avg/stddev): 599.9909/0.01
3.数据清理
sysbench --test=/data/software/sysbench-0.5/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --oltp-table-size=1000000 --max-time=600 --max-requests=0 \
--num-threads=100 --oltp_tables_count=10 --rand-init=on --oltp-read-only=off --report-interval=10 --rand-type=uniform --percentile=99 \
--mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=admin --mysql-password=admin \
--mysql-db=test --oltp-range-size=40 --oltp-point-selects=10 --oltp-simple-ranges=1 --oltp-sum-ranges=1 --oltp-order-ranges=1 --oltp-distinct-ranges=1 \
--oltp-index-updates=1 --oltp-non-index-updates=1 --mysql-socket=/tmp/mysql3306.sock cleanup
四.打开QC:
query_cache_type=1
query_cache_size = 1g
1.准备数据:
读写:
sysbench --test=/data/software/sysbench-0.5/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --oltp-table-size=1000000 --max-requests=0 \
--num-threads=100 --oltp_tables_count=10 --rand-init=on --oltp-read-only=off --report-interval=10 --rand-type=uniform --percentile=99 \
--mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=admin --mysql-password=admin \
--mysql-db=test --oltp-range-size=40 --oltp-point-selects=10 --oltp-simple-ranges=1 --oltp-sum-ranges=1 --oltp-order-ranges=1 --oltp-distinct-ranges=1 \
--oltp-index-updates=1 --oltp-non-index-updates=1 --mysql-socket=/tmp/mysql3306.sock prepare
2.测试:
sysbench --test=/data/software/sysbench-0.5/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --oltp-table-size=1000000 --max-time=600 --max-requests=0 \
--num-threads=100 --oltp_tables_count=10 --rand-init=on --oltp-read-only=off --report-interval=10 --rand-type=uniform --percentile=99 \
--mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=admin --mysql-password=admin \
--mysql-db=test --oltp-range-size=40 --oltp-point-selects=10 --oltp-simple-ranges=1 --oltp-sum-ranges=1 --oltp-order-ranges=1 --oltp-distinct-ranges=1 \
--oltp-index-updates=1 --oltp-non-index-updates=1 --mysql-socket=/tmp/mysql3306.sock run
OLTP test statistics:
queries performed:
read: 18442102
write: 5269172
other: 2634586
total: 26345860
transactions: 1317293 (2195.39 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 23711274 (39517.10 per sec.)
other operations: 2634586 (4390.79 per sec.)
Test execution summary:
total time: 600.0257s
total number of events: 1317293
total time taken by event execution: 60001.0816s
per-request statistics:
min: 2.58ms
avg: 45.55ms
max: 393.53ms
approx. 99 percentile: 117.09ms
Threads fairness:
events (avg/stddev): 13172.9300/78.44
execution time (avg/stddev): 600.0108/0.01
3.数据清理
sysbench --test=/data/software/sysbench-0.5/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --oltp-table-size=1000000 --max-time=600 --max-requests=0 \
--num-threads=100 --oltp_tables_count=10 --rand-init=on --oltp-read-only=off --report-interval=10 --rand-type=uniform --percentile=99 \
--mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=admin --mysql-password=admin \
--mysql-db=test --oltp-range-size=40 --oltp-point-selects=10 --oltp-simple-ranges=1 --oltp-sum-ranges=1 --oltp-order-ranges=1 --oltp-distinct-ranges=1 \
--oltp-index-updates=1 --oltp-non-index-updates=1 --mysql-socket=/tmp/mysql3306.sock cleanup
五.总结
select (2827.56-2195.39)/2827.56*100;
+-------------------------------+
| (2827.56-2195.39)/2827.56*100 |
+-------------------------------+
| 22.357439 |
+-------------------------------+
1 row in set (0.00 sec)
(product)root@localhost [(none)]>
关闭QC,每秒事务数2827.56,打开时是2195.39。关闭QC,性能提升22.36%。
1.下载sysbench工具
wget sysbench-0.5.tar.gz
cd /data/software
tar -zxvf sysbench-0.5.tar.gz
2.安装相关包
yum install -y bzr
yum install -y libtool
3.编译安装
cd /data/software/sysbench-0.5/
chmod a+x *
./autogen.sh
./configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib
make
make install
sysbench --help
数据测试参数说明:
测试工具:sysbench 0.5
测试流程:通过对innodb引擎和myisam引擎的压力测试,得出两种引擎的性能表现
测试模型:采用OLTP模型。大致命令如下:
常用命令参数:
/usr/local/bin/sysbench
--mysql-host=127.0.0.1 #数据库host
--mysql-port=3306 #数据库端口
--mysql-user=admin #数据库用户名
--mysql-password=admin #数据库密码
--mysql-db=test #数据库名
--oltp-tables-count=10 #模拟的表的个数,规格越高该值越大
--oltp-table-size=1000000 #模拟的每张表的行数,规格越高该值越大
--num-threads=100 #模拟的并发数量,规格越高该值越大
--max-requests=10000 #最大请求次数
--max-time=20 #最大测试时间(与--max-requests只要有一个超过,则退出)
--report-interval=1 #每1秒打印一次当前的QPS等值
---mysql-socket=/tmp/mysql3306.sock
[prepare | run | cleanup] #prepare准备数据,run执行测试,cleanup清理数据
--oltp-dist-type=uniform :指定随机取样类型,可选值有 uniform(均匀分布), Gaussian(高斯分布), special(空间分布)
--oltp_table_count=1:指定测试过程中表的个数,0.5新增,0.4整个测试过程只有一个表。
--oltp-table-size=:指定表的大小,如果指定1000,那么它会往表里初始化1000条数据
--rand-init=on:是否随机初始化数据,如果不随机化那么初始好的数据每行内容除了主键不同外其他完全相同。
--num-threads=:测试过程中并发线程数,看测试要求来定并发压力
--test=tests/db/oltp.lua 表示调用 tests/db/oltp.lua 脚本进行 oltp 模式测试
--oltp_tables_count=10 表示会生成 10 个测试表
--oltp-table-size=100000 表示每个测试表填充数据量为 100000
--rand-init=on 表示每个测试表都是用随机数据来填充的
--rand-type=uniform 表示随机类型为固定模式,其他几个可选随机模式:uniform(固定),gaussian(高斯),special(特定的),pareto(帕累托)
--oltp-read-only=off 表示不要进行只读测试,也就是会采用读写混合模式测试
--num-threads=128 表示发起 128个并发连接
--report-interval=10 表示每10秒输出一次测试进度报告
--max-time=120 表示最大执行时长为 120秒
--max-requests=0 表示总请求数为 0,因为上面已经定义了总执行时长,所以总请求数可以设定为 0;也可以只设定总请求数,不设定最大执行时长
--percentile=99 表示设定采样比例,默认是 95%,即丢弃1%的长请求,在剩余的99%里取最大值
二.环境信息
硬件配置:
虚拟机vmware
cpu : 8个 Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz
内存:64G
mysql参数配置:
innodb_buffer_pool_size =11G
key_buffer_size = 64M
max_binlog_size = 128M
binlog_cache_size = 1M
sync_binlog=0
innodb_flush_log_at_trx_commit=2
innodb_log_file_size = 256M
innodb_log_buffer_size = 16M
MySQL版本:mysql 5.6.24
三.关闭QC
query_cache_size=0
query_cache_type=off
1.准备数据:
读写:
sysbench --test=/data/software/sysbench-0.5/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --oltp-table-size=1000000 --max-requests=0 \
--num-threads=100 --oltp_tables_count=10 --rand-init=on --oltp-read-only=off --report-interval=10 --rand-type=uniform --percentile=99 \
--mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=admin --mysql-password=admin \
--mysql-db=test --oltp-range-size=40 --oltp-point-selects=10 --oltp-simple-ranges=1 --oltp-sum-ranges=1 --oltp-order-ranges=1 --oltp-distinct-ranges=1 \
--oltp-index-updates=1 --oltp-non-index-updates=1 --mysql-socket=/tmp/mysql3306.sock prepare
2.测试:
sysbench --test=/data/software/sysbench-0.5/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --oltp-table-size=1000000 --max-time=600 --max-requests=0 \
--num-threads=100 --oltp_tables_count=10 --rand-init=on --oltp-read-only=off --report-interval=10 --rand-type=uniform --percentile=99 \
--mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=admin --mysql-password=admin \
--mysql-db=test --oltp-range-size=40 --oltp-point-selects=10 --oltp-simple-ranges=1 --oltp-sum-ranges=1 --oltp-order-ranges=1 --oltp-distinct-ranges=1 \
--oltp-index-updates=1 --oltp-non-index-updates=1 --mysql-socket=/tmp/mysql3306.sock run
OLTP test statistics:
queries performed:
read: 23751980
write: 6786280
other: 3393140
total: 33931400
transactions: 1696570 (2827.56 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 30538260 (50896.15 per sec.)
other operations: 3393140 (5655.13 per sec.)
Test execution summary:
total time: 600.0112s
total number of events: 1696570
total time taken by event execution: 59999.0893s
per-request statistics:
min: 2.13ms
avg: 35.36ms
max: 322.02ms
approx. 99 percentile: 111.12ms
Threads fairness:
events (avg/stddev): 16965.7000/151.74
execution time (avg/stddev): 599.9909/0.01
3.数据清理
sysbench --test=/data/software/sysbench-0.5/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --oltp-table-size=1000000 --max-time=600 --max-requests=0 \
--num-threads=100 --oltp_tables_count=10 --rand-init=on --oltp-read-only=off --report-interval=10 --rand-type=uniform --percentile=99 \
--mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=admin --mysql-password=admin \
--mysql-db=test --oltp-range-size=40 --oltp-point-selects=10 --oltp-simple-ranges=1 --oltp-sum-ranges=1 --oltp-order-ranges=1 --oltp-distinct-ranges=1 \
--oltp-index-updates=1 --oltp-non-index-updates=1 --mysql-socket=/tmp/mysql3306.sock cleanup
四.打开QC:
query_cache_type=1
query_cache_size = 1g
1.准备数据:
读写:
sysbench --test=/data/software/sysbench-0.5/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --oltp-table-size=1000000 --max-requests=0 \
--num-threads=100 --oltp_tables_count=10 --rand-init=on --oltp-read-only=off --report-interval=10 --rand-type=uniform --percentile=99 \
--mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=admin --mysql-password=admin \
--mysql-db=test --oltp-range-size=40 --oltp-point-selects=10 --oltp-simple-ranges=1 --oltp-sum-ranges=1 --oltp-order-ranges=1 --oltp-distinct-ranges=1 \
--oltp-index-updates=1 --oltp-non-index-updates=1 --mysql-socket=/tmp/mysql3306.sock prepare
2.测试:
sysbench --test=/data/software/sysbench-0.5/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --oltp-table-size=1000000 --max-time=600 --max-requests=0 \
--num-threads=100 --oltp_tables_count=10 --rand-init=on --oltp-read-only=off --report-interval=10 --rand-type=uniform --percentile=99 \
--mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=admin --mysql-password=admin \
--mysql-db=test --oltp-range-size=40 --oltp-point-selects=10 --oltp-simple-ranges=1 --oltp-sum-ranges=1 --oltp-order-ranges=1 --oltp-distinct-ranges=1 \
--oltp-index-updates=1 --oltp-non-index-updates=1 --mysql-socket=/tmp/mysql3306.sock run
OLTP test statistics:
queries performed:
read: 18442102
write: 5269172
other: 2634586
total: 26345860
transactions: 1317293 (2195.39 per sec.)
deadlocks: 0 (0.00 per sec.)
read/write requests: 23711274 (39517.10 per sec.)
other operations: 2634586 (4390.79 per sec.)
Test execution summary:
total time: 600.0257s
total number of events: 1317293
total time taken by event execution: 60001.0816s
per-request statistics:
min: 2.58ms
avg: 45.55ms
max: 393.53ms
approx. 99 percentile: 117.09ms
Threads fairness:
events (avg/stddev): 13172.9300/78.44
execution time (avg/stddev): 600.0108/0.01
3.数据清理
sysbench --test=/data/software/sysbench-0.5/sysbench/tests/db/oltp.lua --mysql-table-engine=innodb --oltp-table-size=1000000 --max-time=600 --max-requests=0 \
--num-threads=100 --oltp_tables_count=10 --rand-init=on --oltp-read-only=off --report-interval=10 --rand-type=uniform --percentile=99 \
--mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=admin --mysql-password=admin \
--mysql-db=test --oltp-range-size=40 --oltp-point-selects=10 --oltp-simple-ranges=1 --oltp-sum-ranges=1 --oltp-order-ranges=1 --oltp-distinct-ranges=1 \
--oltp-index-updates=1 --oltp-non-index-updates=1 --mysql-socket=/tmp/mysql3306.sock cleanup
五.总结
select (2827.56-2195.39)/2827.56*100;
+-------------------------------+
| (2827.56-2195.39)/2827.56*100 |
+-------------------------------+
| 22.357439 |
+-------------------------------+
1 row in set (0.00 sec)
(product)root@localhost [(none)]>
关闭QC,每秒事务数2827.56,打开时是2195.39。关闭QC,性能提升22.36%。
相关文章推荐
- 获得进程可执行文件的路径: GetModuleFileNameEx, GetProcessImageFileName, QueryFullProcessImageName
- NtQuerySystemInformation的使用(提供50余种信息)
- 一个修改过简化版的InputQuery(简单实用,用到了Canvas)
- 学习记录:交叉编译环境配置(buildroot and gdb&gdbserver)
- miniui设置边框的方法
- UIView和CALayer的区别
- Integer.MAX_VALUE和Integer.MIN_VALUE的运算及原理
- easyui设置全局分页
- IOS---UIScrollView(无限循环滚动)
- UVA 5986 - Wizarding Duel 超级脑洞题
- Android与设计模式之Builder
- Luence简单实现2
- Luence简单实现1
- LeetCode | Distinct Subsequences
- break、continue、return的用法
- Arduino+sim900发送短信例程代码
- 带你深入理解STL之Stack和Queue
- 带你深入理解STL之Stack和Queue
- LeetCode387—First Unique Character in a String
- UIBezierPath介绍