温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Sysbench基准测试的示例分析

发布时间:2021-11-01 09:34:23 来源:亿速云 阅读:135 作者:小新 栏目:MySQL数据库

这篇文章给大家分享的是有关Sysbench基准测试的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

Sysbench和TPCC-MySQL一样,也是一款基准测试的工具。

TPCC-MySQL
http://blog.itpub.net/29254281/viewspace-1195589/

相对于TPCC-MySQL,Sysbench不仅可以对MySQL,也可以对Oracle,PostgreSQL进行基准测试。

源码下载地址:
https://launchpad.net/sysbench

先下载依赖包
yum install automake autoconf -y

运行./configure && make 命令,可能有以下的报错
../libtool: line 5172: : command not found
修改configure.ac文件
Sysbench基准测试的示例分析

将LIBTOOL注释,并增加AC_PROG_RANLIB
Sysbench基准测试的示例分析

修改之后运行如下命令
./autogen.sh && ./configure && make
完成之后,进入sysbench文件夹,可以看到sysbench命令已经编译完成。

1.进行文件IO测试
准备文件
Sysbench基准测试的示例分析
进行基准测试

  1. [root@mysql1 sysbench]# ./sysbench --test=fileio --file-total-size=2G --file-test-mode=rndrw --file-num=16 --num-threads=16 run

  2. sysbench 0.4.12:  multi-threaded system evaluation benchmark


  3. Running the test with following options:

  4. Number of threads: 16


  5. Extra file open flags: 0

  6. 16 files, 128Mb each

  7. 2Gb total file size

  8. Block size 16Kb

  9. Number of random requests for random IO: 10000

  10. Read/Write ratio for combined random IO test: 1.50

  11. Periodic FSYNC enabled, calling fsync() each 100 requests.

  12. Calling fsync() at the end of test, Enabled.

  13. Using synchronous I/O mode

  14. Doing random r/w test

  15. Threads started!

  16. Done.


  17. Operations performed:  6006 Read, 3996 Write, 1600 Other = 11602 Total

  18. Read 93.844Mb  Written 62.438Mb  Total transferred 156.28Mb  (2.1231Mb/sec)

  19. 135.88 Requests/sec executed


  20. Test execution summary:

  21. total time:                          73.6086s

  22. total number of events:              10002

  23. total time taken by event execution: 602.0152

  24. per-request statistics:

  25. min:                                  0.01ms

  26. avg:                                 60.19ms

  27. max:                               1587.11ms

  28. approx.  95 percentile:             290.98ms


  29. Threads fairness:

  30. events (avg/stddev):           625.1250/42.01

  31. execution time (avg/stddev):   37.6259/2.94

其中主要参数和默认值
  --file-num=N                     创建测试的文件数量 [128]
  --file-block-size=N             块的尺寸,默认是16K 用于测试Oracle一般改为8K[16384]        
  --file-total-size=SIZE         所有测试文件总的大小[2G]
  --file-test-mode=STRING   测试模式 seqwr(顺序写), seqrewr(顺序读写), seqrd(顺序读), rndrd(随机读), rndwr(随机写), rndrw(随机读写)
  --file-io-mode=STRING      文件操作模式 sync(同步),async(异步),fastmmap,slowmmap(两种内存映射模式) [sync]
  --file-rw-ratio=N                测试时的读写比例  [1.5]

  --file-async-backlog=N        number of asynchronous operatons to queue per thread [128]
  --file-extra-flags=STRING     additional flags to use on opening files {sync,dsync,direct} []
  --file-fsync-freq=N           do fsync() after this number of requests (0 - don't use fsync()) [100]
  --file-fsync-all=[on|off]     do fsync() after each write operation [off]
  --file-fsync-end=[on|off]     do fsync() at the end of test [on]
  --file-fsync-mode=STRING      which method to use for synchronization {fsync, fdatasync} [fsync]
  --file-merged-requests=N      merge at most this number of IO requests if possible (0 - don't merge) [0]
 
测试完成之后清理生成的文件
[root@mysql1 sysbench]# ./sysbench --test=fileio --file-num=16 --file-total-size=2G cleanup
sysbench 0.4.12:  multi-threaded system evaluation benchmark
Removing test files...

如果出现如下错误,则需要注意 指定的file-num能够被file-total-size 整除
FATAL: Too large position discovered in request!

2.进行CPU基准测试
[root@mysql1 sysbench]# ./sysbench --test=cpu --num-threads=16 run
sysbench 0.4.12:  multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 16
Doing CPU performance benchmark
Threads started!
Done.
Maximum prime number checked in CPU test: 10000
Test execution summary:
    total time:                          2.5106s
    total number of events:              10000
    total time taken by event execution: 39.3201
    per-request statistics:
         min:                                  0.30ms
         avg:                                  3.93ms
         max:                                 43.80ms
         approx.  95 percentile:              15.07ms

Threads fairness:
    events (avg/stddev):           625.0000/50.60
    execution time (avg/stddev):   2.4575/0.03

3.OLTP基准测试
进行准备
[root@mysql1 sysbench]# ./sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 --mysql-host=127.0.0.1 --mysql-user=xx --mysql-password=xx --mysql-socket=/home/lihuilin/mysql-5.6.14/mysql.sock  --num-threads=15  prepare
sysbench 0.4.12:  multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
Creating table 'sbtest'...
Creating 1000000 records in table 'sbtest'...

然后进行测试
[root@mysql1 sysbench]# ./sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 --mysql-host=127.0.0.1 --mysql-user=xx --mysql-password=xx --mysql-socket=/home/lihuilin/mysql-5.6.14/mysql.sock  --num-threads=15  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: 15

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  (502.61 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 190000 (9549.53 per sec.)
    other operations:                    20000  (1005.21 per sec.)

Test execution summary:
    total time:                          19.8963s
    total number of events:              10000
    total time taken by event execution: 298.1265
    per-request statistics:
         min:                                 11.62ms
         avg:                                 29.81ms
         max:                                185.70ms
         approx.  95 percentile:              42.60ms

Threads fairness:
    events (avg/stddev):           666.6667/5.69
    execution time (avg/stddev):   19.8751/0.01

相对于TPCC-MySQL,sysbench的测试结果非常直观, 一目了然

感谢各位的阅读!关于“Sysbench基准测试的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI