数据库性能测试:sysbench使用方法详解(3)

SQL statistics:
    queries performed:
        read:          35098  # 执行的读操作数量
        write:        10028  # 执行的写操作数量
        other:        5014    # 执行的其它操作数量
        total:        50140
    transactions:      2507  (124.29 per sec.)    # 执行事务的平均速率
    queries:          50140  (2485.82 per sec.)  # 平均每秒能执行多少次查询
    ignored errors:    0      (0.00 per sec.)
    reconnects:        0      (0.00 per sec.)

General statistics:
    total time:                  20.1694s    # 总消耗时间
    total number of events:      2507        # 总请求数量(读、写、其它)

Latency (ms):
        min:                            2.32
        avg:                          32.13
        max:                          575.78
        95th percentile:              118.92    # 采样计算的平均延迟
        sum:                        80554.96

Threads fairness:
    events (avg/stddev):          626.7500/2.49
    execution time (avg/stddev):  20.1387/0.04

5.cpu/io/内存等测试

sysbench内置了几个测试指标。
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

可直接help输出测试方法。例如,fileio测试。
[root@xuexi ~]# sysbench fileio help
sysbench 1.0.15 (using bundled LuaJIT 2.1.0-beta2)

fileio options:
  --file-num=N                  number of files to create [128]
  --file-block-size=N          block size to use in all IO operations [16384]
  --file-total-size=SIZE        total size of files to create [2G]
  --file-test-mode=STRING      test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
  --file-io-mode=STRING        file operations mode {sync,async,mmap} [sync]
  --file-async-backlog=N        number of asynchronous operatons to queue per thread [128]
  --file-extra-flags=[LIST,...] list of additional flags to use to open 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]
  --file-rw-ratio=N            reads/writes ratio for combined test [1.5]

例如,创建5个文件,总共1G,每个文件大概200M。
sysbench fileio --file-num=5 --file-total-size=1G prepare

[root@xuexi ~]# ls -lh test*
-rw------- 1 root root 205M Jul  8 12:15 test_file.0
-rw------- 1 root root 205M Jul  8 12:15 test_file.1
-rw------- 1 root root 205M Jul  8 12:15 test_file.2
-rw------- 1 root root 205M Jul  8 12:15 test_file.3
-rw------- 1 root root 205M Jul  8 12:15 test_file.4

然后,运行测试。
sysbench --events=5000 \
        --threads=16 \
        fileio \
        --file-num=5 \
        --file-total-size=G \
        --file-test-mode=rndrw \
        --file-fsync-freq=0 \
        --file-block-size=16384 \
        run

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/64041b07011b2860a70b156b93a081a6.html