基于 AWS EC2 的简单基准测试

关于去年云计算课程的一次实践整理。

Practice with the fundamental cloud mechanisms and resources.

配置并运行 AWS EC2 实例

虚拟私有云:Virtual Private Cloud (VPC)

配置 VPC

Create a nondefault VPC:

  • VPC dashboard - Launch VPC Wizard
  • Select VPC with a Single Public Subnet
  • using default configuration settings

Name: lab-VPC

配置安全组(Security Group)

Create a nondefault Security Group

Name: admin-SG-useast1

VPC:lab-VPC

Inbound:

  • Type: HTTP ; Source: Anywhere(0.0.0.0/0)
  • Type: HTTPS ; Source: Anywhere(0.0.0.0/0)
  • Type: SSH ; Source: My public IP address

创建 VM1

  • Launch Instance
  • Amazon Machine Image (AMI): Amazon Linux 2 AMI (HVM), SSD Volume Type
  • Instance Type: t2.micro(default)
  • Configure instance details
    • Network: lab-VPC
    • enable public IP
  • Review Instance Launch - Edit security groups
    • Configure Security Group - Select an existing security group
    • Select admin-SG-useast1
    • Review and Launch
  • Launch
  • Choose an existing key pair
  • Launch instances

VM Name: lab-EC2-VM1

Volume Name: lab-VM1-Vol

Access VM

1
ssh -i admin-key-pair-useast1.pem ec2-user@ec2-<ip>.compute-1.amazonaws.com

生成负载

为虚拟机生成工作负载,以便进行监控。

Sysbench

源代码:https://github.com/akopytov/sysbench

安装

1
2
3
4
5
6
7
8
9
10
11
12
$ sudo yum -y install git
$ sudo yum -y install make automake libtool pkgconfig libaio-devel
$ sudo yum -y install mariadb-devel openssl-devel
$ sudo git clone https://github.com/akopytov/sysbench.git /opt/sysbench
$ cd /opt/sysbench
$ sudo ./autogen.sh
$ sudo ./configure
$ sudo make -j
$ sudo make install

$ sysbench --version
sysbench 1.1.0-1327e79

CPU 测试

1
sysbench cpu --cpu-max-prime=200000 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
sysbench 1.1.0-1327e79 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Prime numbers limit: 200000

Initializing worker threads...

Threads started!

CPU speed:
events per second: 12.09

Throughput:
events/s (eps): 12.0894
time elapsed: 10.0088s
total number of events: 121

Latency (ms):
min: 80.63
avg: 82.71
max: 83.99
95th percentile: 82.96
sum: 10007.70

Threads fairness:
events (avg/stddev): 121.0000/0.00
execution time (avg/stddev): 10.0077/0.00

CPU 压力测试

--stress :设置线程数量

1
2
3
for each in 1 2 4 8 16 32 64; do
sysbench cpu --cpu-max-prime=200000 --threads=$each run;
done

结果:

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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
sysbench 1.1.0-1327e79 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time


Prime numbers limit: 200000

Initializing worker threads...

Threads started!

CPU speed:
events per second: 12.05

Throughput:
events/s (eps): 12.0534
time elapsed: 10.0387s
total number of events: 121

Latency (ms):
min: 82.28
avg: 82.96
max: 84.08
95th percentile: 82.96
sum: 10037.57

Threads fairness:
events (avg/stddev): 121.0000/0.00
execution time (avg/stddev): 10.0376/0.00

sysbench 1.1.0-1327e79 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 2
Initializing random number generator from current time


Prime numbers limit: 200000

Initializing worker threads...

Threads started!

CPU speed:
events per second: 12.02

Throughput:
events/s (eps): 12.0205
time elapsed: 10.1494s
total number of events: 122

Latency (ms):
min: 159.76
avg: 166.35
max: 172.32
95th percentile: 167.44
sum: 20295.12

Threads fairness:
events (avg/stddev): 61.0000/0.00
execution time (avg/stddev): 10.1476/0.00

sysbench 1.1.0-1327e79 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 4
Initializing random number generator from current time


Prime numbers limit: 200000

Initializing worker threads...

Threads started!

CPU speed:
events per second: 12.03

Throughput:
events/s (eps): 12.0260
time elapsed: 10.3110s
total number of events: 124

Latency (ms):
min: 315.89
avg: 332.30
max: 345.95
95th percentile: 337.94
sum: 41204.69

Threads fairness:
events (avg/stddev): 31.0000/0.00
execution time (avg/stddev): 10.3012/0.00

sysbench 1.1.0-1327e79 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 8
Initializing random number generator from current time


Prime numbers limit: 200000

Initializing worker threads...

Threads started!

CPU speed:
events per second: 12.04

Throughput:
events/s (eps): 12.0352
time elapsed: 10.5523s
total number of events: 127

Latency (ms):
min: 571.79
avg: 659.02
max: 703.07
95th percentile: 669.89
sum: 83695.76

Threads fairness:
events (avg/stddev): 15.8750/0.33
execution time (avg/stddev): 10.4620/0.18

sysbench 1.1.0-1327e79 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 16
Initializing random number generator from current time


Prime numbers limit: 200000

Initializing worker threads...

Threads started!

CPU speed:
events per second: 12.06

Throughput:
events/s (eps): 12.0617
time elapsed: 10.6121s
total number of events: 128

Latency (ms):
min: 1270.58
avg: 1321.72
max: 1373.07
95th percentile: 1352.03
sum: 169179.67

Threads fairness:
events (avg/stddev): 8.0000/0.00
execution time (avg/stddev): 10.5737/0.02

sysbench 1.1.0-1327e79 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 32
Initializing random number generator from current time


Prime numbers limit: 200000

Initializing worker threads...

Threads started!

CPU speed:
events per second: 12.02

Throughput:
events/s (eps): 12.0227
time elapsed: 10.6465s
total number of events: 128

Latency (ms):
min: 2539.24
avg: 2641.29
max: 2801.14
95th percentile: 2728.81
sum: 338085.50

Threads fairness:
events (avg/stddev): 4.0000/0.00
execution time (avg/stddev): 10.5652/0.04

sysbench 1.1.0-1327e79 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 64
Initializing random number generator from current time


Prime numbers limit: 200000

Initializing worker threads...

Threads started!

CPU speed:
events per second: 12.04

Throughput:
events/s (eps): 12.0391
time elapsed: 10.6320s
total number of events: 128

Latency (ms):
min: 4911.61
avg: 5227.60
max: 5466.45
95th percentile: 5409.26
sum: 669133.28

Threads fairness:
events (avg/stddev): 2.0000/0.00
execution time (avg/stddev): 10.4552/0.07
  • Prime numbers limit: 200000 : The maximum number of primes produced by each thread is 20,000
  • CPU speed
    • events per second : All threads completed xx events per second
  • Latency (ms)
    • 95th percentile : 95% of events completed in xx seconds
    • sum : Thread overlay time
  • Threads fairness
    • events (avg/stddev) : Each thread completes xx events with a standard deviation of xx
    • execution time (avg/stddev) : Each thread takes an average of xx seconds with a standard deviation of xx

File I/O 测试

  1. 创建文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    $ df -hl
    文件系统 容量 已用 可用 已用% 挂载点
    devtmpfs 475M 0 475M 0% /dev
    tmpfs 492M 0 492M 0% /dev/shm
    tmpfs 492M 404K 492M 1% /run
    tmpfs 492M 0 492M 0% /sys/fs/cgroup
    /dev/xvda1 8.0G 1.7G 6.3G 22% /
    tmpfs 99M 0 99M 0% /run/user/1000

    $ sysbench fileio --file-total-size=6G --file-num=3 prepare
  2. 读写文件

    1
    2
    3
    4
    5
    6
    7
    --file-test-mode:
    1. seqwr: sequential write
    2. seqrewr: sequential read and write
    3. seqrd: sequential read
    4. rndrd: random read
    5. rndwr: random write
    6. *rndrw: random read and write

    使用随机读写测试。

    1
    2
    3
    for each in 1 4 8 16 32; do
    sysbench fileio --file-total-size=6G --file-test-mode=rndrw --time=240 --events=0 --file-block-size=4k --file-num=3 --threads=$each run;
    done

    结果:

    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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    sysbench 1.1.0-1327e79 (using bundled LuaJIT 2.1.0-beta3)

    Running the test with following options:
    Number of threads: 1
    Initializing random number generator from current time


    Extra file open flags: (none)
    3 files, 2GiB each
    6GiB total file size
    Block size 4KiB
    Number of IO requests: 0
    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
    Initializing worker threads...

    Threads started!


    Throughput:
    read: IOPS=1487.00 5.81 MiB/s (6.09 MB/s)
    write: IOPS=991.33 3.87 MiB/s (4.06 MB/s)
    fsync: IOPS=74.36

    Latency (ms):
    min: 0.00
    avg: 0.39
    max: 80.62
    95th percentile: 1.23
    sum: 238268.36

    sysbench 1.1.0-1327e79 (using bundled LuaJIT 2.1.0-beta3)

    Running the test with following options:
    Number of threads: 4
    Initializing random number generator from current time


    Extra file open flags: (none)
    3 files, 2GiB each
    6GiB total file size
    Block size 4KiB
    Number of IO requests: 0
    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
    Initializing worker threads...

    Threads started!


    Throughput:
    read: IOPS=1972.21 7.70 MiB/s (8.08 MB/s)
    write: IOPS=1314.81 5.14 MiB/s (5.39 MB/s)
    fsync: IOPS=98.66

    Latency (ms):
    min: 0.00
    avg: 1.18
    max: 145.04
    95th percentile: 3.82
    sum: 957824.13

    sysbench 1.1.0-1327e79 (using bundled LuaJIT 2.1.0-beta3)

    Running the test with following options:
    Number of threads: 8
    Initializing random number generator from current time


    Extra file open flags: (none)
    3 files, 2GiB each
    6GiB total file size
    Block size 4KiB
    Number of IO requests: 0
    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
    Initializing worker threads...

    Threads started!


    Throughput:
    read: IOPS=1962.84 7.67 MiB/s (8.04 MB/s)
    write: IOPS=1308.55 5.11 MiB/s (5.36 MB/s)
    fsync: IOPS=98.23

    Latency (ms):
    min: 0.00
    avg: 2.37
    max: 94.97
    95th percentile: 13.46
    sum: 1917867.62

    sysbench 1.1.0-1327e79 (using bundled LuaJIT 2.1.0-beta3)

    Running the test with following options:
    Number of threads: 16
    Initializing random number generator from current time


    Extra file open flags: (none)
    3 files, 2GiB each
    6GiB total file size
    Block size 4KiB
    Number of IO requests: 0
    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
    Initializing worker threads...

    Threads started!


    Throughput:
    read: IOPS=1964.55 7.67 MiB/s (8.05 MB/s)
    write: IOPS=1309.70 5.12 MiB/s (5.36 MB/s)
    fsync: IOPS=98.42

    Latency (ms):
    min: 0.00
    avg: 4.74
    max: 98.33
    95th percentile: 17.63
    sum: 3837882.19

    sysbench 1.1.0-1327e79 (using bundled LuaJIT 2.1.0-beta3)

    Running the test with following options:
    Number of threads: 32
    Initializing random number generator from current time


    Extra file open flags: (none)
    3 files, 2GiB each
    6GiB total file size
    Block size 4KiB
    Number of IO requests: 0
    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
    Initializing worker threads...

    Threads started!


    Throughput:
    read: IOPS=1962.48 7.67 MiB/s (8.04 MB/s)
    write: IOPS=1308.31 5.11 MiB/s (5.36 MB/s)
    fsync: IOPS=98.52

    Latency (ms):
    min: 0.00
    avg: 9.50
    max: 91.18
    95th percentile: 25.28
    sum: 7678005.08
    • IOPS : input/output operations per second
    • The SSD read speed is 7.7 MiB/s and write speed is 5 MiB/s .
  3. 清理文件

    1
    sysbench fileio --file-total-size=6G --file-num=3 cleanup

Apache Bench

Create VM2 by using the same configuration of VM1, use the same VPC and security group of VM1.

VM Name: lab-EC2-VM2

Volume Name: lab-VM2-Vol


Install apache2-utils :

1
2
3
4
5
6
$ sudo yum -y install httpd-tools

$ ab -V
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

在 VM1 上安装 Apache Web Server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ sudo yum update httpd
$ sudo yum -y install httpd

$ sudo systemctl start httpd
$ sudo systemctl enable httpd

$ sudo systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since 六 2019-12-07 18:47:49 UTC; 1min 37s ago
Docs: man:httpd.service(8)
Main PID: 21218 (httpd)
Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec: 0 B/sec"
CGroup: /system.slice/httpd.service
├─21218 /usr/sbin/httpd -DFOREGROUND
├─21219 /usr/sbin/httpd -DFOREGROUND
├─21220 /usr/sbin/httpd -DFOREGROUND
├─21221 /usr/sbin/httpd -DFOREGROUND
├─21222 /usr/sbin/httpd -DFOREGROUND
└─21223 /usr/sbin/httpd -DFOREGROUND

12月 07 18:47:49 <vm1-ip>.ec2.internal systemd[1]: Starting The Apache HTTP Server...
12月 07 18:47:49 <vm1-ip>.ec2.internal systemd[1]: Started The Apache HTTP Server.

在 VM2 上进行压力测试

Change Concurrency
  • -c : number of concurrent users
  • -k : keep alive

测试一(-c 10):

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
51
52
53
54
55
56
$ ab -n 100000 -c 10 -k http://<vm1-ip>.ec2.internal/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking <vm1-ip>.ec2.internal (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software: Apache/2.4.41
Server Hostname: <vm1-ip>.ec2.internal
Server Port: 80

Document Path: /
Document Length: 3630 bytes

Concurrency Level: 10
Time taken for tests: 14.625 seconds
Complete requests: 100000
Failed requests: 0
Non-2xx responses: 100000
Keep-Alive requests: 99017
Total transferred: 393082540 bytes
HTML transferred: 363000000 bytes
Requests per second: 6837.60 [#/sec] (mean)
Time per request: 1.463 [ms] (mean)
Time per request: 0.146 [ms] (mean, across all concurrent requests)
Transfer rate: 26247.46 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 4
Processing: 0 1 1.3 1 27
Waiting: 0 1 1.3 1 27
Total: 0 1 1.3 1 27

Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 2
80% 2
90% 2
95% 3
98% 4
99% 7
100% 27 (longest request)

测试二(-c 100):

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
51
52
53
54
55
56
$ ab -n 100000 -c 100 -k http://<vm1-ip>.ec2.internal/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking <vm1-ip>.ec2.internal (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software: Apache/2.4.41
Server Hostname: <vm1-ip>.ec2.internal
Server Port: 80

Document Path: /
Document Length: 3630 bytes

Concurrency Level: 100
Time taken for tests: 15.796 seconds
Complete requests: 100000
Failed requests: 0
Non-2xx responses: 100000
Keep-Alive requests: 99076
Total transferred: 393085813 bytes
HTML transferred: 363000000 bytes
Requests per second: 6330.91 [#/sec] (mean)
Time per request: 15.796 [ms] (mean)
Time per request: 0.158 [ms] (mean, across all concurrent requests)
Transfer rate: 24302.64 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 10
Processing: 0 16 11.5 16 206
Waiting: 0 16 11.5 16 206
Total: 0 16 11.5 16 206

Percentage of the requests served within a certain time (ms)
50% 16
66% 17
75% 18
80% 20
90% 26
95% 34
98% 47
99% 58
100% 206 (longest request)

测试三(-c 500):

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
51
52
53
54
55
56
57
$ ab -n 100000 -c 500 -k http://<vm1-ip>.ec2.internal/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking <vm1-ip>.ec2.internal (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software: Apache/2.4.41
Server Hostname: <vm1-ip>.ec2.internal
Server Port: 80

Document Path: /
Document Length: 3630 bytes

Concurrency Level: 500
Time taken for tests: 20.819 seconds
Complete requests: 100000
Failed requests: 160
(Connect: 0, Receive: 0, Length: 160, Exceptions: 0)
Non-2xx responses: 99847
Keep-Alive requests: 98961
Total transferred: 392491804 bytes
HTML transferred: 362444610 bytes
Requests per second: 4803.23 [#/sec] (mean)
Time per request: 104.097 [ms] (mean)
Time per request: 0.208 [ms] (mean, across all concurrent requests)
Transfer rate: 18410.42 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 32.7 0 3065
Processing: 2 72 651.1 29 20784
Waiting: 1 65 623.8 29 20784
Total: 2 73 653.8 29 20806

Percentage of the requests served within a certain time (ms)
50% 29
66% 37
75% 40
80% 40
90% 41
95% 42
98% 45
99% 1061
100% 20806 (longest request)

测试四(-c 1000):

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
51
52
53
54
55
56
57
$ ab -n 100000 -c 1000 -k http://<vm1-ip>.ec2.internal/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking <vm1-ip>.ec2.internal (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software: Apache/2.4.41
Server Hostname: <vm1-ip>.ec2.internal
Server Port: 80

Document Path: /
Document Length: 3630 bytes

Concurrency Level: 1000
Time taken for tests: 30.934 seconds
Complete requests: 100000
Failed requests: 385
(Connect: 0, Receive: 0, Length: 385, Exceptions: 0)
Non-2xx responses: 99615
Keep-Alive requests: 98750
Total transferred: 391587192 bytes
HTML transferred: 361602450 bytes
Requests per second: 3232.73 [#/sec] (mean)
Time per request: 309.336 [ms] (mean)
Time per request: 0.309 [ms] (mean, across all concurrent requests)
Transfer rate: 12362.26 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 31.5 0 3077
Processing: 9 156 1531.0 40 30906
Waiting: 1 146 1527.2 40 30906
Total: 9 157 1534.1 40 30925

Percentage of the requests served within a certain time (ms)
50% 40
66% 41
75% 41
80% 42
90% 43
95% 44
98% 59
99% 3163
100% 30925 (longest request)
Change Requests

-n : number of requests

测试一(-n 1000):

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
51
52
53
54
55
56
57
$ ab -n 1000 -c 100 -k http://<vm1-ip>.ec2.internal/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking <vm1-ip>.ec2.internal (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software: Apache/2.4.41
Server Hostname: <vm1-ip>.ec2.internal
Server Port: 80

Document Path: /
Document Length: 3630 bytes

Concurrency Level: 100
Time taken for tests: 7.021 seconds
Complete requests: 1000
Failed requests: 13
(Connect: 0, Receive: 0, Length: 13, Exceptions: 0)
Non-2xx responses: 993
Keep-Alive requests: 987
Total transferred: 3905989 bytes
HTML transferred: 3604590 bytes
Requests per second: 142.43 [#/sec] (mean)
Time per request: 702.080 [ms] (mean)
Time per request: 7.021 [ms] (mean, across all concurrent requests)
Transfer rate: 543.31 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 1.6 0 7
Processing: 1 463 1502.5 1 7011
Waiting: 1 402 1411.4 1 7011
Total: 1 463 1503.9 1 7018

Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 2
80% 2
90% 7
95% 5006
98% 5984
99% 5997
100% 7018 (longest request)

测试二(-n 5000):

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
51
52
53
54
55
56
57
$ ab -n 5000 -c 100 -k http://<vm1-ip>.ec2.internal/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking <vm1-ip>.ec2.internal (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software: Apache/2.4.41
Server Hostname: <vm1-ip>.ec2.internal
Server Port: 80

Document Path: /
Document Length: 3630 bytes

Concurrency Level: 100
Time taken for tests: 5.733 seconds
Complete requests: 5000
Failed requests: 25
(Connect: 0, Receive: 0, Length: 25, Exceptions: 0)
Non-2xx responses: 4975
Keep-Alive requests: 4942
Total transferred: 19558156 bytes
HTML transferred: 18059250 bytes
Requests per second: 872.22 [#/sec] (mean)
Time per request: 114.650 [ms] (mean)
Time per request: 1.147 [ms] (mean, across all concurrent requests)
Transfer rate: 3331.83 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.7 0 10
Processing: 1 70 540.7 5 5714
Waiting: 1 45 412.4 5 5714
Total: 1 70 541.1 5 5724

Percentage of the requests served within a certain time (ms)
50% 5
66% 5
75% 5
80% 5
90% 6
95% 8
98% 482
99% 4852
100% 5724 (longest request)

测试三(-n 10000):

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
51
52
53
54
55
56
57
$ ab -n 10000 -c 100 -k http://<vm1-ip>.ec2.internal/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking <vm1-ip>.ec2.internal (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software: Apache/2.4.41
Server Hostname: <vm1-ip>.ec2.internal
Server Port: 80

Document Path: /
Document Length: 3630 bytes

Concurrency Level: 100
Time taken for tests: 6.816 seconds
Complete requests: 10000
Failed requests: 13
(Connect: 0, Receive: 0, Length: 13, Exceptions: 0)
Non-2xx responses: 9987
Keep-Alive requests: 9893
Total transferred: 39259554 bytes
HTML transferred: 36252810 bytes
Requests per second: 1467.12 [#/sec] (mean)
Time per request: 68.161 [ms] (mean)
Time per request: 0.682 [ms] (mean, across all concurrent requests)
Transfer rate: 5624.85 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.7 0 8
Processing: 1 49 444.0 1 5598
Waiting: 1 43 407.0 1 5598
Total: 1 49 444.2 1 5599

Percentage of the requests served within a certain time (ms)
50% 1
66% 2
75% 2
80% 2
90% 2
95% 2
98% 7
99% 1219
100% 5599 (longest request)

关于 IOPS

IOPS 是指 IO 系统每秒所执行 IO 操作的次数,是一个重要的用来衡量系统 IO 能力的一个参数。对于单个磁盘组成的 IO 系统来说,计算它的 IOPS 不是一件很难的事情,只要我们知道了系统完成一次 IO 所需要的时间的话,我们就能推算出系统 IOPS 来。

对于磁盘来说一个完整的 IO 操作是这样进行的: 当控制器对磁盘发出一个 IO 操作命令的时候,磁盘的驱动臂(Actuator Arm)带读写磁头(Head)离开着陆区(Landing Zone,位于内圈没有数据的区域),移动到要操作的初始数据块所在的磁道(Track)的正上方,这个过程被称为寻道(Seeking),对应消耗的时间被称为 寻道时间(Seek Time); 但是找到对应磁道还不能马上读取数据,这时候磁头要等到磁盘盘片(Platter)旋转到初始数据块所在扇区(Sector)落在读写磁头正上方之后才能开始读写数据,在这个等待盘片旋转到可操作扇区的过程中消耗的时间称为 旋转延时(Rotational Delay); 接下来就随着盘片的旋转,磁头不断的读/写相应的数据块,直到完成这次 IO 所需要操作的全部数据,这个过程称为数据传送(Data Transfer),对应的时间称为 传送时间(Transfer Time)。完成这三个步骤之后,一次 IO 操作也就完成了。

1
Total = 寻道时间 + 旋转延迟 + 传送时间

现在我们就可以得出这样的计算单次IO时间的公式:

1
IO Time = Seek Time + 60 sec / Rotational Speed / 2 + IO Chunk Size / Transfer Rate

于是我们可以这样计算出:

1
IOPS = 1 / IO Time = 1 / (Seek Time + 60 sec / Rotational Speed / 2 + IO Chunk Size / Transfer Rate)

参考