BlueXIII's Blog

热爱技术,持续学习

0%

Sysbench测试

参考文档

安装

1
2
3
4
5
6
7
# 安装
# curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh | sudo bash
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
sudo yum -y install sysbench

# LUA脚本目录
/usr/share/sysbench

MySQL压测

脚本

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
#  准备数据
sysbench \
--mysql-host=10.193.10.252 \
--mysql-port=3306 \
--mysql-db=sysbench \
--mysql-user=dev \
--mysql-password=yourpass \
/usr/share/sysbench/oltp_common.lua \
--tables=10 \
--table_size=100000 \
prepare

# 清理数据
sysbench \
--mysql-host=10.193.10.252 \
--mysql-port=3306 \
--mysql-db=sysbench \
--mysql-user=dev \
--mysql-password=yourpass \
/usr/share/sysbench/oltp_common.lua \
--tables=10 \
cleanup

# 测试
sysbench \
--mysql-host=10.193.10.252 \
--mysql-port=3306 \
--mysql-db=sysbench \
--mysql-user=dev \
--mysql-password=yourpass \
--threads=20 \
--time=60 \
--report-interval=5 \
/usr/share/sysbench/oltp_read_write.lua \
--tables=10 \
--table_size=100000 \
run

测试结果 10.193.10.252 写实例

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
[ 5s ] thds: 4 tps: 426.24 qps: 8533.27 (r/w/o: 5975.01/1704.97/853.29) lat (ms,95%): 10.09 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 4 tps: 458.81 qps: 9181.27 (r/w/o: 6426.59/1837.05/917.63) lat (ms,95%): 9.56 err/s: 0.00 reconn/s: 0.00
[ 15s ] thds: 4 tps: 510.40 qps: 10205.85 (r/w/o: 7144.44/2040.61/1020.81) lat (ms,95%): 8.90 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 4 tps: 480.19 qps: 9604.44 (r/w/o: 6722.49/1921.57/960.38) lat (ms,95%): 8.90 err/s: 0.00 reconn/s: 0.00
SQL statistics:
queries performed:
read: 131362
write: 37532
other: 18766
total: 187660
transactions: 9383 (468.95 per sec.)
queries: 187660 (9378.96 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 20.0069s
total number of events: 9383

Latency (ms):
min: 5.30
avg: 8.53
max: 120.79
95th percentile: 9.22
sum: 79990.85

Threads fairness:
events (avg/stddev): 2345.7500/10.08
execution time (avg/stddev): 19.9977/0.00

测试结果 10.193.10.250 Proxy

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
[ 5s ] thds: 4 tps: 270.87 qps: 5427.64 (r/w/o: 3801.41/1083.69/542.54) lat (ms,95%): 15.83 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 4 tps: 257.42 qps: 5146.09 (r/w/o: 3600.95/1030.30/514.85) lat (ms,95%): 16.12 err/s: 0.00 reconn/s: 0.00
[ 15s ] thds: 4 tps: 261.62 qps: 5233.32 (r/w/o: 3664.43/1045.66/523.23) lat (ms,95%): 16.41 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 4 tps: 271.79 qps: 5435.24 (r/w/o: 3804.49/1087.17/543.58) lat (ms,95%): 15.55 err/s: 0.00 reconn/s: 0.00
SQL statistics:
queries performed:
read: 74382
write: 21252
other: 10626
total: 106260
transactions: 5313 (265.48 per sec.)
queries: 106260 (5309.53 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 20.0115s
total number of events: 5313

Latency (ms):
min: 9.53
avg: 15.06
max: 120.29
95th percentile: 16.12
sum: 80021.11

Threads fairness:
events (avg/stddev): 1328.2500/4.15
execution time (avg/stddev): 20.0053/0.00

TiDB

mysql://10.193.0.8:4000 root/yourpass

脚本

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
# 准备
sysbench \
--mysql-host=10.193.0.8 \
--mysql-port=4000 \
--mysql-db=sysbench \
--mysql-user=root \
--mysql-password=yourpass \
/usr/share/sysbench/oltp_common.lua \
--tables=10 \
--table_size=100000 \
prepare

# 测试
sysbench \
--mysql-host=10.193.0.8 \
--mysql-port=4000 \
--mysql-db=sysbench \
--mysql-user=root \
--mysql-password=yourpass \
--threads=20 \
--time=60 \
--report-interval=5 \
/usr/share/sysbench/oltp_read_write.lua \
--tables=10 \
--table_size=100000 \
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
[ 5s ] thds: 20 tps: 469.21 qps: 9454.95 (r/w/o: 6623.50/1889.03/942.42) lat (ms,95%): 130.13 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 20 tps: 494.81 qps: 9882.80 (r/w/o: 6920.34/1972.84/989.62) lat (ms,95%): 106.75 err/s: 0.00 reconn/s: 0.00
[ 15s ] thds: 20 tps: 441.62 qps: 8837.18 (r/w/o: 6185.26/1768.68/883.24) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 20 tps: 503.80 qps: 10065.62 (r/w/o: 7044.81/2013.60/1007.20) lat (ms,95%): 94.10 err/s: 0.00 reconn/s: 0.00
[ 25s ] thds: 20 tps: 439.01 qps: 8783.70 (r/w/o: 6149.27/1756.02/878.41) lat (ms,95%): 130.13 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 20 tps: 383.00 qps: 7660.47 (r/w/o: 5362.45/1532.01/766.01) lat (ms,95%): 137.35 err/s: 0.00 reconn/s: 0.00
[ 35s ] thds: 20 tps: 439.79 qps: 8793.80 (r/w/o: 6156.66/1757.56/879.58) lat (ms,95%): 130.13 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 20 tps: 467.00 qps: 9337.01 (r/w/o: 6534.81/1868.60/933.60) lat (ms,95%): 118.92 err/s: 0.00 reconn/s: 0.00
[ 45s ] thds: 20 tps: 418.60 qps: 8381.86 (r/w/o: 5868.84/1675.41/837.61) lat (ms,95%): 134.90 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 20 tps: 459.79 qps: 9196.03 (r/w/o: 6435.68/1840.77/919.58) lat (ms,95%): 101.13 err/s: 0.00 reconn/s: 0.00
[ 55s ] thds: 20 tps: 463.01 qps: 9255.66 (r/w/o: 6479.38/1850.25/926.03) lat (ms,95%): 108.68 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: 20 tps: 415.40 qps: 8288.56 (r/w/o: 5799.77/1658.79/830.00) lat (ms,95%): 137.35 err/s: 0.00 reconn/s: 0.00
SQL statistics:
queries performed:
read: 377944
write: 107984
other: 53992
total: 539920
transactions: 26996 (449.31 per sec.)
queries: 539920 (8986.21 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 60.0817s
total number of events: 26996

Latency (ms):
min: 20.72
avg: 44.47
max: 368.03
95th percentile: 130.13
sum: 1200584.83

Threads fairness:
events (avg/stddev): 1349.8000/15.89
execution time (avg/stddev): 60.0292/0.02

CPU

1
sysbench cpu --threads=40 --events=10000 --cpu-max-prime=20000 run

磁盘

脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sysbench fileio help

# 准备
sysbench fileio --file-num=5 --file-total-size=1G prepare

# 测试
sysbench fileio \
--events=5000 \
--threads=16 \
--file-num=5 \
--file-total-size=1G \
--file-test-mode=rndrw \
--file-fsync-freq=0 \
--file-block-size=16384 \
run

结果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
File operations:
reads/s: 33380.09
writes/s: 22271.94
fsyncs/s: 890.43

Throughput:
read, MiB/s: 521.56
written, MiB/s: 348.00

General statistics:
total time: 0.0881s
total number of events: 5000

Latency (ms):
min: 0.00
avg: 0.02
max: 4.30
95th percentile: 0.04
sum: 116.73

Threads fairness:
events (avg/stddev): 312.5000/132.74
execution time (avg/stddev): 0.0073/0.00

Docker

https://hub.docker.com/r/severalnines/sysbench/

脚本

1
2
3
4
5
6
7
8
# 拉镜像
docker pull severalnines/sysbench

# 磁盘准备
docker run -it \
--name=sysbench \
severalnines/sysbench \
bash

结果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
File operations:
reads/s: 6408.42
writes/s: 4272.28
fsyncs/s: 170.89

Throughput:
read, MiB/s: 100.13
written, MiB/s: 66.75

General statistics:
total time: 0.4660s
total number of events: 5000

Latency (ms):
min: 0.00
avg: 0.02
max: 3.48
95th percentile: 0.04
sum: 95.95

Threads fairness:
events (avg/stddev): 312.5000/219.91
execution time (avg/stddev): 0.0060/0.00