使用sysbench测试MySQL5.7.14的oltp性能

本文详细介绍使用Sysbench工具对CPU、内存、IO、互斥锁、线程及MySQL OLTP性能进行测试的过程与结果,包括测试参数设置、结果分析及图表展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目的:使用sysbench测试MySQL的oltp性能,将结果用gnuplot绘制成性能图。

环境:redhat7,mysql5.7.14,sysbench0.5 (均在vmvare中安装)

配置:

物理cpu个数:4
核心数量:1
线程数量:4

mysql配置:默认

1.使用sysbench测量cpu

参数:

sysbench --test=cpu \
--num-threads=`grep "processor" /proc/cpuinfo | wc -l` \
--cpu-max-prime=20000 run

 

结果:

[root@localhost mysql]# ./cpu_test.sh 
sysbench 0.5: multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 4
Random number generator seed is 0 and will be ignored


Prime numbers limit: 20000

Initializing worker threads...

Threads started!


General statistics:
total time: 7.2456s
total number of events: 10000
total time taken by event execution: 28.9647s
response time:
min: 2.54ms
avg: 2.90ms
max: 13.15ms
approx. 95 percentile: 3.90ms

Threads fairness:
events (avg/stddev): 2500.0000/1.22
execution time (avg/stddev): 7.2412/0.00

 

2.使用sysbench测量内存

参数:

sysbench --test=memory --memory-block-size=8K --memory-total-size=2G  --num-threads=16 run

结果:

[root@localhost mysql]# ./memory_test.sh 
sysbench 0.5: multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 16
Random number generator seed is 0 and will be ignored


Initializing worker threads...

Threads started!

Operations performed: 262144 (2015598.14 ops/sec)

2048.00 MB transferred (15746.86 MB/sec)


General statistics:
total time: 0.1301s
total number of events: 262144
total time taken by event execution: 0.3529s
response time:
min: 0.00ms
avg: 0.00ms
max: 1.01ms
approx. 95 percentile: 0.00ms

Threads fairness:
events (avg/stddev): 16384.0000/2206.91
execution time (avg/stddev): 0.0221/0.00

 

3.使用sysbench测量IO

参数:

#prepare 10G data

sysbench --test=fileio --file-total-size=10G prepare
#test
sysbench --test=fileio --file-total-size=10G --file-test-mode=rndrw\
--init-rng=on --max-time=300 --max-requests=0 run
#clean temp data
sysbench --test=fileio --file-total-size=10G cleanup

结果:

====初始化测试文件

Creating file test_file.1
Creating file test_file.2
...

Creating file test_file.126
Creating file test_file.127
10737418240 bytes written in 40.59 seconds (252.30 MB/sec).
sysbench 0.5: multi-threaded system evaluation benchmark

====开始测试

Running the test with following options:
Number of threads: 1
Random number generator seed is 0 and will be ignored


Extra file open flags: 0
128 files, 80Mb each
10Gb total file size
Block size 16Kb
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Initializing worker threads...

Threads started!

Operations performed: 907422 reads, 604948 writes, 1935744 Other = 3448114 Total
Read 13.846Gb Written 9.2308Gb Total transferred 23.077Gb (78.74Mb/sec)
5039.38 Requests/sec executed

General statistics:
total time: 300.1101s
total number of events: 1512370
total time taken by event execution: 238.0086s
response time:
min: 0.00ms
avg: 0.16ms
max: 163.65ms
approx. 95 percentile: 0.18ms

Threads fairness:
events (avg/stddev): 1512370.0000/0.00
execution time (avg/stddev): 238.0086/0.00

sysbench 0.5: multi-threaded system evaluation benchmark

 

4.使用sysbench测量互斥锁

参数:

sysbench --test=mutex --num-threads=16 --mutex-num=2048 \
--mutex-locks=1000000 --mutex-loops=5000 run

结果:

[root@localhost mysql]# ./mutex_test.sh 
sysbench 0.5: multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 16
Random number generator seed is 0 and will be ignored


Initializing worker threads...

Threads started!


General statistics:
total time: 2.3676s
total number of events: 16
total time taken by event execution: 36.2816s
response time:
min: 2042.78ms
avg: 2267.60ms
max: 2367.17ms
approx. 95 percentile: 2366.65ms

Threads fairness:
events (avg/stddev): 1.0000/0.00
execution time (avg/stddev): 2.2676/0.10

 

5.使用sysbench测量线程

参数:

sysbench --test=threads --num-threads=64 run

结果:

[root@localhost mysql]# ./thread_test.sh 
sysbench 0.5: multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 64
Random number generator seed is 0 and will be ignored


Initializing worker threads...

Threads started!


General statistics:
total time: 2.5541s
total number of events: 10000
total time taken by event execution: 163.0034s
response time:
min: 0.15ms
avg: 16.30ms
max: 246.45ms
approx. 95 percentile: 55.25ms

Threads fairness:
events (avg/stddev): 156.2500/12.16
execution time (avg/stddev): 2.5469/0.00

6.使用sysbench测量mysql oltp

参数:

records=100000
thds=10
type=innodb
host=localhost
port=3306
sysbench --test=/home/ljp/sysbench-0.5/sysbench/tests/db/oltp.lua \
--oltp_tables_count=10 --oltp-table-size=$records --rand-init=on \
--num-threads=$thds --oltp-read-only=off --report-interval=1 \
--rand-type=special --rand-spec-pct=5 --mysql-table-engine=$type \
--max-time=60 --mysql-host=$host --mysql-port=$port --mysql-user=root \
--mysql-password=root --mysql-db=test --max-requests=1000000 $1

 

结果:

[ 1s] threads: 10, tps: 31.01, reads: 398.08, writes: 121.03, response time: 1247.93ms (95%), errors: 0.00, reconnects: 0.00
[ 2s] threads: 10, tps: 71.00, reads: 1024.04, writes: 287.01, response time: 535.40ms (95%), errors: 0.00, reconnects: 0.00

...
[ 59s] threads: 10, tps: 113.04, reads: 1538.59, writes: 423.16, response time: 594.54ms (95%), errors: 0.00, reconnects: 0.00
[ 60s] threads: 10, tps: 7.00, reads: 142.92, writes: 63.97, response time: 1053.44ms (95%), errors: 0.00, reconnects: 0.00
OLTP test statistics:
queries performed:
read: 64554
write: 18444
other: 9222
total: 92220
transactions: 4611 (76.67 per sec.)
read/write requests: 82998 (1380.10 per sec.)
other operations: 9222 (153.34 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 60.1390s
total number of events: 4611
total time taken by event execution: 601.1634s
response time:
min: 2.12ms
avg: 130.38ms
max: 2378.80ms
approx. 95 percentile: 656.66ms

Threads fairness:
events (avg/stddev): 461.1000/24.47
execution time (avg/stddev): 60.1163/0.03

图像:

进行60秒查询,tps

image2016-8-31%2016%3A35%3A27.png?version=1&modificationDate=1472633224000&api=v2

进行60秒查询,读写次数

image2016-8-31%2016%3A35%3A42.png?version=1&modificationDate=1472633224000&api=v2

进行60秒查询,响应时间(ms)

image2016-8-31%2016%3A36%3A1.png?version=1&modificationDate=1472633224000&api=v2

 

转载于:https://my.oschina.net/jumpLee/blog/740589

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值