介绍

在AWS中,不同类型的EC2 instance,拥有的网络带宽是不同的。

让人犯糊的是,在AWS EC2的介绍页面中,并没有清晰的标明每种类型的Instance的带宽具体是多少?一些类型的Instance只是标注了网络性能(Network Performance)为Up to 5,Low,Moderate或者High

老外的EC2 Network Performance Cheat Sheet这篇文章中,记录了作者使用iperf3测试出来的各个Instance类型的带宽。如果选取类型的时候比较在意带宽,可以用来参考下。

顺带介绍一下如何在AWS EC2中使用iperf3来测试Instance带宽。如果确实有需要,就可以自己来进行测速。
测试环境如下:

  • 测试Region是美国Oregon
  • 使用两台m4.large的EC2,一台运行服务,一台用作客户端。
  • 介绍两种Amazon Linux的测试方法
    • Amazon Linux AMI 2018.03.0 (HVM), SSD Volume Type
    • Amazon Linux 2 AMI (HVM), SSD Volume Type

Amazon Linux 测速

环境说明

  • 两台m4.large
  • AMI为Amazon Linux AMI 2018.03.0 (HVM), SSD Volume Type
  • 两台Instance在同一个AZ中

试验中,iperf3监听5000端口,EC2对应的SG中需要开启端口5000

安装测试

登录作为Server的EC2,执行如下命令

1
2
3
4
5
6
7
# 安装系统更新和iperf3
sudo yum update
sudo yum-config-manager --enable epel
sudo yum install iperf3
# 在端口5000上开启iperf3
sudo iperf3 -s -p 5000

登录作为client的EC2,执行如下命令:

1
2
3
4
# 安装系统更新和iperf3
sudo yum update
sudo yum-config-manager --enable epel
sudo yum install iperf3

Client上执行命令来测速iperf3 -c 172.31.20.28 -i 1 -t 5 --parallel 2 -p 5000

  • -c 172.31.20.28 代表client模式, 连接的服务器IP是172.31.20.28
  • -i 代表输出间隔为1秒
  • -t 代表持续5秒
  • --parallel 代表并行数为2
  • -p 代表连接服务器的5000端口。

iperf3 -c 172.31.20.28 -i 1 -t 5 --parallel 2 -p 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
[ec2-user@ip-172-31-31-88 ~]$ iperf3 -c 172.31.20.28 -i 1 -t 5 --parallel 2 -p 5000
Connecting to host 172.31.20.28, port 5000
[ 4] local 172.31.31.88 port 41798 connected to 172.31.20.28 port 5000
[ 6] local 172.31.31.88 port 41800 connected to 172.31.20.28 port 5000
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 72.6 MBytes 609 Mbits/sec 0 288 KBytes
[ 6] 0.00-1.00 sec 71.1 MBytes 596 Mbits/sec 0 288 KBytes
[SUM] 0.00-1.00 sec 144 MBytes 1.21 Gbits/sec 0
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 1.00-2.00 sec 54.2 MBytes 455 Mbits/sec 4 446 KBytes
[ 6] 1.00-2.00 sec 54.7 MBytes 459 Mbits/sec 3 454 KBytes
[SUM] 1.00-2.00 sec 109 MBytes 913 Mbits/sec 7
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 2.00-3.00 sec 26.2 MBytes 220 Mbits/sec 1 507 KBytes
[ 6] 2.00-3.00 sec 27.2 MBytes 228 Mbits/sec 1 524 KBytes
[SUM] 2.00-3.00 sec 53.4 MBytes 448 Mbits/sec 2
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 3.00-4.00 sec 24.0 MBytes 201 Mbits/sec 2 551 KBytes
[ 6] 3.00-4.00 sec 28.9 MBytes 243 Mbits/sec 1 542 KBytes
[SUM] 3.00-4.00 sec 52.9 MBytes 444 Mbits/sec 3
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 4.00-5.00 sec 33.1 MBytes 278 Mbits/sec 1 551 KBytes
[ 6] 4.00-5.00 sec 20.9 MBytes 175 Mbits/sec 4 428 KBytes
[SUM] 4.00-5.00 sec 54.0 MBytes 453 Mbits/sec 5
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-5.00 sec 210 MBytes 353 Mbits/sec 8 sender
[ 4] 0.00-5.00 sec 208 MBytes 348 Mbits/sec receiver
[ 6] 0.00-5.00 sec 203 MBytes 340 Mbits/sec 9 sender
[ 6] 0.00-5.00 sec 201 MBytes 337 Mbits/sec receiver
[SUM] 0.00-5.00 sec 413 MBytes 693 Mbits/sec 17 sender
[SUM] 0.00-5.00 sec 409 MBytes 686 Mbits/sec receiver
iperf Done.
[ec2-user@ip-172-31-31-88 ~]$

Amazon Linux 2测速

环境说明

  • 两台m4.large
  • AMI为Amazon Linux 2 AMI (HVM), SSD Volume Type
  • 两台Instance在同一个AZ中

试验中,iperf3监听5000端口,EC2对应的SG中需要开启端口5000

安装测试

登录作为Server的EC2,执行如下命令

1
2
3
4
5
6
7
# 安装系统更新和iperf3
sudo yum update -y
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install -y iperf3
# 在端口5000上开启iperf3
sudo iperf3 -s -p 5000

登录作为client的EC2,执行如下命令:

1
2
3
4
# 安装系统更新和iperf3
sudo yum update -y
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install -y iperf3

Client上执行命令来测速iperf3 -c 172.31.44.223 -i 1 -t 5 --parallel 2 -p 5000

  • -c 172.31.44.223 代表client模式, 连接的服务端IP地址是172.31.44.223
  • -i 代表输出间隔为1秒
  • -t 代表持续5秒
  • --parallel 代表并行数为2
  • -p 代表连接服务器的5000端口。

iperf3 -c 172.31.44.223 -i 1 -t 5 --parallel 2 -p 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
[ec2-user@ip-172-31-34-102 ~]$ iperf3 -c 172.31.44.223 -i 1 -t 5 --parallel 2 -p 5000
Connecting to host 172.31.44.223, port 5000
[ 4] local 172.31.34.102 port 36994 connected to 172.31.44.223 port 5000
[ 6] local 172.31.34.102 port 36996 connected to 172.31.44.223 port 5000
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 99.4 MBytes 834 Mbits/sec 5 612 KBytes
[ 6] 0.00-1.00 sec 99.3 MBytes 833 Mbits/sec 6 620 KBytes
[SUM] 0.00-1.00 sec 199 MBytes 1.67 Gbits/sec 11
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 1.00-2.00 sec 28.1 MBytes 236 Mbits/sec 0 787 KBytes
[ 6] 1.00-2.00 sec 27.3 MBytes 229 Mbits/sec 0 787 KBytes
[SUM] 1.00-2.00 sec 55.4 MBytes 465 Mbits/sec 0
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 2.00-3.00 sec 26.9 MBytes 226 Mbits/sec 1 699 KBytes
[ 6] 2.00-3.00 sec 26.2 MBytes 220 Mbits/sec 1 699 KBytes
[SUM] 2.00-3.00 sec 53.1 MBytes 446 Mbits/sec 2
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 3.00-4.00 sec 27.1 MBytes 227 Mbits/sec 1 603 KBytes
[ 6] 3.00-4.00 sec 26.1 MBytes 219 Mbits/sec 0 856 KBytes
[SUM] 3.00-4.00 sec 53.2 MBytes 446 Mbits/sec 1
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 4.00-5.00 sec 28.0 MBytes 235 Mbits/sec 1 559 KBytes
[ 6] 4.00-5.00 sec 26.5 MBytes 223 Mbits/sec 0 996 KBytes
[SUM] 4.00-5.00 sec 54.5 MBytes 457 Mbits/sec 1
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-5.00 sec 209 MBytes 351 Mbits/sec 8 sender
[ 4] 0.00-5.00 sec 207 MBytes 348 Mbits/sec receiver
[ 6] 0.00-5.00 sec 205 MBytes 345 Mbits/sec 7 sender
[ 6] 0.00-5.00 sec 203 MBytes 340 Mbits/sec receiver
[SUM] 0.00-5.00 sec 415 MBytes 696 Mbits/sec 15 sender
[SUM] 0.00-5.00 sec 410 MBytes 688 Mbits/sec receiver
iperf Done.
[ec2-user@ip-172-31-34-102 ~]$

比较总结

  • Amazon Linux是基于RHEL6的,Amazon Linux 2是基于RHEL 7的,两者的差别可以认为就类似于RHEL 6和RHEL 7。
  • Amazon Linux 2中默认不带epel的yum源,需要自己安装。而Amazon Linux中默认带epel源,不过默认是disable的,需要用yum-config-manager enable一下。
  • iperf3前一两秒会有一个burst,测试时间需要长一点,才能得到一个比较真实的测试结果。
  • 关于EC2网络带宽的猜想: 每个机型的带宽限制,应该是AWS在逻辑层面做的限制,而不是在物理硬件层面的限制。

Reference

留言