跳转至

sysbench IO基准测试


2014-09-05 by dongnan

功能

sysbench 是一个模块化的、跨平台、多线程基准测试工具,主要用于评估测试各种不同系统参数 下的数据库负载情况。

测试功能包括:

  • cpu性能
  • 磁盘io性能
  • 调度程序性能
  • 内存分配及传输速度
  • POSIX线程性能
  • 数据库性能(OLTP基准测试支持MySQLPgsqlOracle)

环境

操作系统: CentOS 6.5 amd64
软件版本: sysbench-0.4.12

安装

可以通过EPEL 直接安装 sysbench

yum install sysbench

使用

第1步创建测试文件

这个命令会在当前工作目录下创建测试文件,后续的运行阶段将通过读写这些文件进行测试。

sysbench --test=fileio --file-total-size=50G prepare

sysbench 0.4.12:  multi-threaded system evaluation benchmark
128 files, 409600Kb each, 51200Mb total
Creating files for the test...

第2步就是运行

针对不同的IO类型有不同的测试选项:

  • seqwr 顺序写入
  • seqrewr 顺序重写
  • seqrd 顺序读取
  • rndrd 随机读取
  • rndwr 随机写入
  • rndrw 混合随机读/写

例如,混合随机读/写测试:

sysbench --test=fileio --file-total-size=50G --file-test-mode=rndrw --max-time=300 run

sysbench 0.4.12:  multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Initializing random number generator from timer.

Extra file open flags: 0
128 files, 400Mb each
50Gb total file size
Block size 16Kb
Number of random requests for random IO: 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
Threads started!
Time limit exceeded, exiting...
Done.

Operations performed: 81653 Read, 54435 Write, 174080 Other = 310168 Total
Read 1.2459Gb  Written 850.55Mb Total transferred 2.0765Gb  (7.0879Mb/sec)
 453.63 Requests/sec executed

Test execution summary:
    total time:                         300.0008s
    total number of events:              136088
    total time taken by event execution: 291.4656
    per-request statistics:
         min:                                  0.01ms
         avg:                                 2.14ms
         max:                                519.93ms
         approx.  95 percentile:               6.46ms

Threads fairness:
    events (avg/stddev):           136088.0000/0.00
    execution time (avg/stddev):   291.4656/0.00

输出结果中包含了大量的信息,这些数据对于评估磁盘性能十分有用:

  • 每秒请求数 453.63 Requests/sec
  • 吞吐量 7.0879Mb/sec
  • 时间分布 95 percentile: 6.46ms

测试完成以后,运行清除操作删除第一步生成的测试文件:

sysbench --test=fileio --file-total-size=50G cleanup
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Removing test files...

举个栗子

环境描述

CloudStack 主存储IO测试

磁盘: 300GB SAS 15K * 6块
Raid: Dell Perc6i /256MB Cache/级别 10/条带 1MB/Write Back
CPU: XEON E5405 * 2颗,共8核心
内存: 16GB
网络: BCM 5709(GB) * 4块绑定,模式0
操作系统: CentOS 6.5 amd64

顺序写入

sysbench --test=fileio --file-total-size=50G --file-test-mode=seqwr --init-rng=on --max-time=240 --max-requests=0 run

sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1
Initializing random number generator from timer.

Extra file open flags: 0
128 files, 400Mb each
50Gb total file size
Block size 16Kb
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing sequential write (creation) test
Threads started!
Done.

Operations performed:  0 Read, 3276800 Write, 128 Other = 3276928 Total
Read 0b  Written 50Gb  Total transferred 50Gb  (235.58Mb/sec)
15077.29 Requests/sec executed

Test execution summary:
    total time:                         217.3335s
    total number of events:              3276800
    total time taken by event execution: 199.1954
    per-request statistics:
         min:                                  0.02ms
         avg:                                 0.06ms
         max:                               2034.85ms
         approx.  95 percentile:               0.03ms

Threads fairness:
    events (avg/stddev):           3276800.0000/0.00
    execution time (avg/stddev):   199.1954/0.00

主要结果

  • 每秒请求数 15077.29 Requests/sec
  • 吞吐量 235.58Mb/sec
  • 时间分布 95 percentile: 0.03ms

顺序读取

sysbench --test=fileio --file-total-size=50G --file-test-mode=seqrd --init-rng=on --max-time=240 --max-requests=0 run

sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1
Initializing random number generator from timer.


Extra file open flags: 0
128 files, 400Mb each
50Gb total file size
Block size 16Kb
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing sequential read test
Threads started!
Done.

Operations performed:  3276800 Read, 0 Write, 0 Other = 3276800 Total
Read 50Gb  Written 0b  Total transferred 50Gb  (226.74Mb/sec)
14511.31 Requests/sec executed

Test execution summary:
    total time:                          225.8101s
    total number of events:              3276800
    total time taken by event execution: 224.8220
    per-request statistics:
         min:                                  0.01ms
         avg:                                 0.07ms
         max:                                 24.91ms
         approx.  95 percentile:               0.49ms

Threads fairness:
    events (avg/stddev):           3276800.0000/0.00
    execution time (avg/stddev):   224.8220/0.00

主要结果

  • 每秒请求数 14511.31 Requests/sec
  • 吞吐量 226.74Mb/sec
  • 时间分布 95 percentile: 0.49ms

随机写入

sysbench --test=fileio --file-total-size=50G --file-test-mode=rndwr --init-rng=on --max-time=240 --max-requests=0 run

sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1
Initializing random number generator from timer.

Extra file open flags: 0
128 files, 400Mb each
50Gb total file size
Block size 16Kb
Number of random requests for random IO: 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 write test
Threads started!
Time limit exceeded, exiting...
Done.

Operations performed:  0 Read, 246200 Write, 315009 Other = 561209 Total
Read 0b  Written 3.7567Gb  Total transferred 3.7567Gb  (16.026Mb/sec)
 1025.63 Requests/sec executed

Test execution summary:
    total time:                          240.0467s
    total number of events:              246200
    total time taken by event execution: 4.6607
    per-request statistics:
         min:                                  0.01ms
         avg:                                  0.02ms
         max:                                  0.08ms
         approx.  95 percentile:               0.02ms

Threads fairness:
    events (avg/stddev):           246200.0000/0.00
    execution time (avg/stddev):   4.6607/0.00

主要结果

  • 每秒请求数 1025.63 Requests/sec
  • 吞吐量 16.026Mb/sec
  • 时间分布 95 percentile: 0.02ms

随机读取

sysbench --test=fileio --file-total-size=50G --file-test-mode=rndrd --init-rng=on --max-time=240 --max-requests=0 run

sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1
Initializing random number generator from timer.

Extra file open flags: 0
128 files, 400Mb each
50Gb total file size
Block size 16Kb
Number of random requests for random IO: 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 read test
Threads started!
Time limit exceeded, exiting...
Done.

Operations performed: 81832 Read, 0 Write, 0 Other = 81832 Total
Read 1.2487Gb  Written 0b  Total transferred 1.2487Gb  (5.3276Mb/sec)
  340.97 Requests/sec executed

Test execution summary:
    total time:                          240.0002s
    total number of events:              81832
    total time taken by event execution: 239.9596
    per-request statistics:
         min:                                  0.01ms
         avg:                                  2.93ms
         max:                                582.23ms
         approx. 95 percentile:               6.03ms

Threads fairness:
    events (avg/stddev):           81832.0000/0.00
    execution time (avg/stddev):   239.9596/0.00

主要结果

  • 每秒请求数 340.97 Requests/sec
  • 吞吐量 5.3276Mb/sec
  • 时间分布 95 percentile: 6.03ms

参考

回到页面顶部