`

性能测试工具sysbench简介

阅读更多

sysbench是一款开源的多线程性能测试工具,可以执行CPU/内存/线程/IO/数据库等方面的性能测试。数据库目前支持MySQL/Oracle/PostgreSQL。本文只是简单演示一下几种测试的用法,后续准备利用sysbench来对MySQL进行一系列的测试。具体的一些参数设置,需要根据不同的测试要求来进行调整。

下载
http://sourceforge.net/projects/sysbench/

编译安装

默认支持MySQL,如果需要测试Oracle/PostgreSQL,则在configure时需要加上–with-oracle或者–with-pgsql参数

./configure --prefix=/u01/sysbench \
--with-mysql-includes=/opt/mysql/include/mysql \
--with-mysql-libs=/opt/mysql/lib/mysql

make && make install

参数

NinGoo:/u01/sysbench/bin>$sysbench
Missing required command argument.
Usage:
  sysbench [general-options]... --test= [test-options]... command

General options:
  --num-threads=N            number of threads to use [1]
  --max-requests=N           limit for total number of requests [10000]
  --max-time=N               limit for total execution time in seconds [0]
  --forced-shutdown=STRING   amount of time to wait after --max-time before forcing shutdown [off]
  --thread-stack-size=SIZE   size of stack per thread [32K]
  --init-rng=[on|off]        initialize random number generator [off]
  --test=STRING              test to run
  --debug=[on|off]           print more debugging info [off]
  --validate=[on|off]        perform validation checks where possible [off]
  --help=[on|off]            print help and exit
  --version=[on|off]         print version and exit

Compiled-in tests:
  fileio - File I/O test
  cpu - CPU performance test
  memory - Memory functions speed test
  threads - Threads subsystem performance test
  mutex - Mutex performance test
  oltp - OLTP test

Commands: prepare run cleanup help version
See 'sysbench --test= help' for a list of options for each test.

 

CPU测试
sysbench采用寻找最大素数的方式来测试CPU的性能

NinGoo:/u01/sysbench/bin>$sysbench --test=cpu --cpu-max-prime=2000 run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1

Doing CPU performance benchmark

Threads started!
Done.

Maximum prime number checked in CPU test: 2000

Test execution summary:
    total time:                          2.3996s
    total number of events:              10000
    total time taken by event execution: 2.3917
    per-request statistics:
         min:                                  0.23ms
         avg:                                  0.24ms
         max:                                 27.44ms
         approx.  95 percentile:               0.24ms

Threads fairness:
    events (avg/stddev):           10000.0000/0.00
    execution time (avg/stddev):   2.3917/0.00

线程测试

NinGoo:/u01/sysbench/bin>$sysbench --test=threads --num-threads=64 --thread-yields=100 \
--thread-locks=2 run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 64

Doing thread subsystem performance test
Thread yields per test: 100 Locks used: 2
Threads started!
Done.

Test execution summary:
    total time:                          4.3925s
    total number of events:              10000
    total time taken by event execution: 280.4418
    per-request statistics:
         min:                                  0.04ms
         avg:                                 28.04ms
         max:                                 72.81ms
         approx.  95 percentile:              52.29ms

Threads fairness:
    events (avg/stddev):           156.2500/1.43
    execution time (avg/stddev):   4.3819/0.01


文件IO性能测试

首先生成需要的测试文件,文件总大小300M,16个并发线程,随机读写模式。执行完后会在当前目录下生成一堆小文件。

NinGoo:/u01/sysbench/bin>$sysbench --test=fileio --num-threads=16  \
--file-total-size=300M --file-test-mode=rndrw prepare
sysbench 0.4.12:  multi-threaded system evaluation benchmark

128 files, 2400Kb each, 300Mb total
Creating files for the test...

执行测试

NinGoo:/u01/sysbench/bin>$sysbench --test=fileio --num-threads=16  \
--file-total-size=300M --file-test-mode=rndrw run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 16

Extra file open flags: 0
128 files, 2.3438Mb each
300Mb total file size
Block size 16Kb
Number of random requests for random IO: 10000
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!
Done.

Operations performed:  5996 Read, 4004 Write, 12800 Other = 22800 Total
Read 93.688Mb  Written 62.562Mb  Total transferred 156.25Mb  (26.713Mb/sec)
 1709.66 Requests/sec executed

Test execution summary:
    total time:                          5.8491s
    total number of events:              10000
    total time taken by event execution: 12.5045
    per-request statistics:
         min:                                  0.01ms
         avg:                                  1.25ms
         max:                                373.28ms
         approx.  95 percentile:               0.03ms

Threads fairness:
    events (avg/stddev):           625.0000/109.60
    execution time (avg/stddev):   0.7815/0.29

清理现场

NinGoo:/u01/sysbench/bin>$sysbench --test=fileio --num-threads=16  \
--file-total-size=300M --file-test-mode=rndrw cleanup
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Removing test files...

Mutex测试

NinGoo:/u01/sysbench/bin>$sysbench --test=mutex --num-threads=16 \
--mutex-num=1024 --mutex-locks=10000 --mutex-loops=5000 run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 16

Doing mutex performance test
Threads started!
Done.

Test execution summary:
    total time:                          1.1561s
    total number of events:              16
    total time taken by event execution: 18.3831
    per-request statistics:
         min:                               1084.60ms
         avg:                               1148.94ms
         max:                               1153.52ms
         approx.  95 percentile:         10000000.00ms

Threads fairness:
    events (avg/stddev):           1.0000/0.00
    execution time (avg/stddev):   1.1489/0.02

内存测试

NinGoo:/u01/sysbench/bin>$sysbench --test=memory --num-threads=16 \
--memory-block-size=8192 --memory-total-size=1G run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 16

Doing memory operations speed test
Memory block size: 8K

Memory transfer size: 1024M

Memory operations type: write
Memory scope type: global
Threads started!
WARNING: Operation time (0.000000) is less than minimal counted value, counting as 1.000000
WARNING: Percentile statistics will be inaccurate
Done.

Operations performed: 131072 (114162.68 ops/sec)

1024.00 MB transferred (891.90 MB/sec)

Test execution summary:
    total time:                          1.1481s
    total number of events:              131072
    total time taken by event execution: 16.0448
    per-request statistics:
         min:                                  0.00ms
         avg:                                  0.12ms
         max:                                  3.60ms
         approx.  95 percentile:               0.01ms

Threads fairness:
    events (avg/stddev):           8192.0000/192.89
    execution time (avg/stddev):   1.0028/0.00

MySQL数据库测试
首先需要创建默认的sbtest数据库,或者使用–mysql-db指定一个已经存在的数据库

生成测试数据,引擎为myisam,表大小为1000000条记录

NinGoo:/u01/sysbench/bin>$sysbench --test=oltp --mysql-table-engine=myisam --oltp-table-size=1000000 \
--mysql-user=root --mysql-socket=/opt/mysql/run/mysql.sock 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@sbtest 11:42:18>desc sbtest.sbtest;
+-------+------------------+------+-----+---------+----------------+
| Field | Type             | Null | Key | Default | Extra          |
+-------+------------------+------+-----+---------+----------------+
| id    | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| k     | int(10) unsigned | NO   | MUL | 0       |                |
| c     | char(120)        | NO   |     |         |                |
| pad   | char(60)         | NO   |     |         |                |
+-------+------------------+------+-----+---------+----------------+

执行测试

NinGoo:/u01/sysbench/bin>$sysbench --test=oltp --mysql-table-engine=myisam --oltp-table-size=1000000 \
--mysql-user=root --mysql-socket=/opt/mysql/run/mysql.sock 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 "LOCK TABLES WRITE" 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  (336.64 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 190000 (6396.11 per sec.)
    other operations:                    20000  (673.27 per sec.)

Test execution summary:
    total time:                          29.7056s
    total number of events:              10000
    total time taken by event execution: 29.6301
    per-request statistics:
         min:                                  2.27ms
         avg:                                  2.96ms
         max:                                 43.88ms
         approx.  95 percentile:               3.36ms

Threads fairness:
    events (avg/stddev):           10000.0000/0.00
    execution time (avg/stddev):   29.6301/0.00

清理现场

NinGoo:/u01/sysbench/bin>$sysbench --test=oltp --mysql-table-engine=myisam --oltp-table-size=1000000 \
--mysql-user=root --mysql-socket=/opt/mysql/run/mysql.sock cleanup
sysbench 0.4.12:  multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
Dropping table 'sbtest'...
Done.
分享到:
评论

相关推荐

    数据库经典压测工具sysbench双版本 sysbench0.5支持oracle sysbench1.1 支持达梦 附详细文档

    总的来说,sysbench作为一个强大的数据库性能测试工具,能够帮助我们深入了解数据库在各种工作负载下的表现。sysbench0.5和sysbench1.1的双版本设计,不仅覆盖了传统的Oracle数据库,还拓展到了中国本土的达梦数据库...

    MySQL 性能测试工具sysbench安装使用

    ### MySQL 性能测试工具sysbench安装与使用详解 #### 一、Sysbench简介 Sysbench是一款开源的、跨平台的、多线程基准测试工具,用于评估不同系统配置下的数据库负载性能。它支持多种测试模式,包括但不限于CPU运算...

    性能测试:sysbench

    mysql性能测试工具:sysbench+资源(autoconf、automake、libtool)

    06-MySQL压力测试工具sysbench1

    1. CPU 性能测试:测试 CPU 的处理能力,包括浮点运算、整数运算、字符串处理等。 2. 磁盘 IO 性能测试:测试磁盘的读写能力,包括随机读写、顺序读写等。 3. 调度程序性能测试:测试操作系统的调度能力,包括进程...

    性能测试工具-sysbench.html

    linux性能测试工具-sysbench使用方法,可以mysql读写性能

    性能测试sysbench.rar

    Sysbench是一款开源的多线程性能测试工具,广泛用于评估Linux系统的CPU、内存、I/O等子系统的性能。本文将详细介绍sysbench-1.0.18的下载、安装过程,以及如何编写和执行测试脚本来进行性能评估。 首先,我们需要...

    sysbench-0.4.12

    《sysbench-0.4.12:性能测试与基准工具详解》 sysbench是一款开源的、跨平台的系统性能测试工具,广泛用于评估Linux系统的CPU、内存、磁盘I/O以及数据库等组件的性能。sysbench-0.4.12是其在2012年发布的一个版本...

    mysql性能测试工具

    mysql 性能测试工具sysbench 0.4.12.10版本

    Android版本的sysbench工具

    sysbench是一个模块化、跨平台、多线程基准测试工具,主要用于测试不同系统参数下的数据库负载情况,本文主要介绍0.4版本的使用...sysbench主要用于以下性能测试: 文件I/O性能 调度 内存分配和传输 POSIX线程 数据库

    数据库性能测试之sysbench工具的安装与用法详解

    sysbench是用于多线程性能测试的开源工具,它具有模块化和跨平台的特性,能够测试CPU、内存、磁盘I/O、线程以及数据库的性能。在数据库测试方面,sysbench支持MySQL、Oracle和PostgreSQL这三种常见的关系型数据库...

    mysql-sysbench测试

    sysbench是一个开源的基准测试工具,可以模拟不同的负载场景来测试数据库的性能。 sysbench下载链接:https://github.com/akopytov/sysbench 安装sysbench: 1. 上传sysbench安装包到Linux环境 2. 解压安装包tar ...

    sysbench压测工具

    `sysbench`是一个强大的系统性能测试工具,无论是对于数据库管理员还是系统管理员,都是评估和优化系统性能的重要助手。通过深入理解和熟练使用`sysbench`,我们可以更有效地找出系统潜在的问题,提升整体性能,确保...

    详解MySQL基准测试和sysbench工具.doc

    数据库的基准测试是对数据库的性能指标进行定量的、可复现的、可对比的测试。基准测试与压力测试 基准测试可以理解为针对系统的一种压力测试。但基准测试不关心业务逻辑,更加简单、直接、易于测试,数据可以由工具...

    sysbench-1.0.20.tar.gz

    sysbench是由Anton Kapela开发的一款开源软件,它提供了多种性能测试场景,包括压力测试数据库服务器、模拟多线程计算任务、磁盘I/O性能测试等。sysbench-1.0.20是sysbench的一个特定版本,适用于x86和ARM架构,这...

    sysbench进行cpu,磁盘IO,内存,OLTP基准测试

    sysbench进行cpu,磁盘IO,内存,OLTP基准测试, 一sysbench-05安装 二用法下面的测试案例需要用到这些说明才能看的懂的 三开始测试 cpu性能测试 线程测试 磁盘IO性能测试 内存测试 OLTP测试

    sysbench-1.0.zip

    sysbench是一款功能强大的系统性能基准测试工具,尤其在MySQL数据库的读写性能测试方面被广泛使用。它不仅可以评估数据库的吞吐量(tps,每秒事务处理量)、查询速率(qps,每秒查询量),还能衡量I/O操作的速度...

    sysbench-master.zip

    总结,sysbench以其全面的功能和灵活的配置,成为IT行业中进行系统性能测试的首选工具之一。无论是在数据库性能评估,还是在系统整体性能的优化过程中,sysbench都发挥着不可忽视的作用。了解并熟练掌握sysbench的...

    Sysbench压测工具搭建和使用实践

    综上所述,Sysbench是MySQL DBA进行系统性能测试的重要工具。通过熟练掌握其安装、配置、使用和结果分析,能够有效地提升数据库性能并确保系统的稳定运行。参考提供的PDF文档,可以更深入地学习Sysbench的高级功能和...

Global site tag (gtag.js) - Google Analytics