sysbench testing

sysbench 测试

1 cpu 性能测试

1
sysbench --test=cpu --cpu-max-prime=20000 run

cpu测试主要是进行素数的加法运算,在上面的例子中,
指定了最大的素数为 20000,自己可以根据机器cpu的性能来适当调整数值。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
sysbench 0.4.10:  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: 20000


Test execution summary:
    total time:                          30.5083s
    total number of events:              10000
    total time taken by event execution: 30.5043
    per-request statistics:
         min:                                  2.83ms
         avg:                                  3.05ms
         max:                                  6.46ms
         approx.  95 percentile:               3.48ms

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

2 线程测试

1
sysbench --test=threads --num-threads=64 --thread-yields=100 --thread-locks=2 run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
sysbench 0.4.10:  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:                          0.6215s
    total number of events:              10000
    total time taken by event execution: 39.3849
    per-request statistics:
         min:                                  0.04ms
         avg:                                  3.94ms
         max:                                 85.26ms
         approx.  95 percentile:              30.41ms

Threads fairness:
    events (avg/stddev):           156.2500/10.52
    execution time (avg/stddev):   0.6154/0.00

3 磁盘IO性能测试,随机读写和删除

1
2
3
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw prepare
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw run
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw cleanup

上述参数指定了最大创建16个线程,创建的文件总大小为3G,文件读写模式为随机读。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
sysbench 0.4.10:  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:                          0.6215s
    total number of events:              10000
    total time taken by event execution: 39.3849
    per-request statistics:
         min:                                  0.04ms
         avg:                                  3.94ms
         max:                                 85.26ms
         approx.  95 percentile:              30.41ms

Threads fairness:
    events (avg/stddev):           156.2500/10.52
    execution time (avg/stddev):   0.6154/0.00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
sysbench 0.4.10:  multi-threaded system evaluation benchmark

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

Extra file open flags: 0
128 files, 24Mb each
3Gb 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!
FATAL: Failed to read file! file: 3 pos: 0 errno = 0 (Q?)
FATAL: Failed to read file! file: 3 pos: 6340608 errno = 0 ()
FATAL: Failed to read file! file: 13 pos: 16531456 errno = 0 ()
FATAL: Failed to read file! file: 48 pos: 5537792 errno = 0 ()
FATAL: Failed to read file! file: 96 pos: 8503296 errno = 0 ()
FATAL: Failed to read file! file: 26 pos: 9568256 errno = 0 ()
FATAL: Failed to read file! file: 26 pos: 15794176 errno = 0 ()
FATAL: Failed to read file! file: 127 pos: 18300928 errno = 0 ()
FATAL: Failed to read file! file: 9 pos: 21331968 errno = 0 ()
FATAL: Failed to read file! file: 119 pos: 8421376 errno = 0 ()
FATAL: Failed to read file! file: 62 pos: 17448960 errno = 0 ()
FATAL: Failed to read file! file: 87 pos: 20398080 errno = 0 ()
FATAL: Failed to read file! file: 113 pos: 13156352 errno = 0 ()
FATAL: Failed to read file! file: 20 pos: 10649600 errno = 0 ()
FATAL: Failed to read file! file: 17 pos: 9060352 errno = 0 ()
FATAL: Failed to read file! file: 16 pos: 311296 errno = 0 ()
Done.

Operations performed:  0 Read, 0 Write, 0 Other = 0 Total
Read 0b  Written 0b  Total transferred 0b  (0b/sec)
    0.00 Requests/sec executed

Test execution summary:
    total time:                          0.0029s
    total number of events:              0
    total time taken by event execution: 0.0000
    per-request statistics:
         min:                            18446744073709.55ms
         avg:                                  0.00ms
         max:                                  0.00ms

Threads fairness:
    events (avg/stddev):           0.0000/0.00
    execution time (avg/stddev):   0.0000/0.00
1
2
3
sysbench 0.4.10:  multi-threaded system evaluation benchmark

Removing test files...

4 内存测试

1
sysbench --test=memory --memory-block-size=8k --memory-total-size=4G run

上述参数指定了本次测试整个过程是在内存中传输 4G 的数据量,每个 block 大小为 8K。
1
# 无结果,待更新!

5 mysql 性能测试

5.1 prepare data
1
2
3
sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 \
--mysql-socket=/home/data/mysql/mysql.sock --mysql-user=root --mysql-host=localhost \
--mysql-password=123456 --mysql-db=students --oltp-table-name=test prepare
1
2
3
4
5
sysbench 0.4.10:  multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
Creating table 'test'...
Creating 1000000 records in table 'test'...
5.2 run test
1
2
3
4
sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 \
--mysql-socket=/home/data/mysql/mysql.sock --mysql-user=root --mysql-host=localhost \
--mysql-password=123456 --mysql-db=students --oltp-table-name=test \
--max-requests=1000 --num-threads=100 run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
sysbench 0.4.10:  multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
WARNING: Preparing of "BEGIN" is unsupported, using emulation
(last message repeated 99 times)
Running the test with following options:
Number of threads: 100

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 1000
Threads started!
Done.

OLTP test statistics:
    queries performed:
        read:                            14000
        write:                           5000
        other:                           2000
        total:                           21000
    transactions:                        1000   (276.21 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 19000  (5247.91 per sec.)
    other operations:                    2000   (552.41 per sec.)

Test execution summary:
    total time:                          3.6205s
    total number of events:              1000
    total time taken by event execution: 356.3231
    per-request statistics:
         min:                                 55.01ms
         avg:                                356.32ms
         max:                               1223.34ms
         approx.  95 percentile:             764.73ms

Threads fairness:
    events (avg/stddev):           10.0000/0.76
    execution time (avg/stddev):   3.5632/0.03
5.3 clean data
1
2
sysbench --test=oltp --mysql-host=localhost  --mysql-user=root  --mysql-password=123456 \
--mysql-socket=/home/data/mysql/mysql.sock --mysql-db=students --oltp-table-name=test cleanup

以上测试内容参考 MySQL 中文网.

本文数据为一台1核1G主机的性能测试结果.

欢迎参见Details