如何排查 Direct Connect 网络性能问题?

5 分钟阅读
0

我的 AWS Direct Connect 连接遇到了吞吐量低、流量延迟和性能问题。

解决方法

要隔离和诊断网络和应用程序性能问题,请完成以下步骤:

**注意:**最佳做法是使用 Amazon Virtual Private Cloud (Amazon VPC) 设置本地专用测试机。使用大小为 C5 或更大的 Amazon Elastic Compute Cloud (Amazon EC2) 实例类型

查看网络或应用程序问题

安装并使用 iPerf3 工具对网络带宽进行基准测试,然后使用其他应用程序或工具交叉检查结果。有关更多信息,请参阅 iPerf 网站的 What is iPerf / iPerf3?

  1. 运行以下命令安装 iPerf3:

    Linux/REHEL

    $ sudo yum install iperf3 -y

    Ubuntu

    $ sudo apt install iperf3 -y
  2. 要双向测量吞吐量,请在客户端上运行 iPerf3:

    Amazon EC2 实例(服务器)

    $ iperf3 -s -V

    本地主机(客户端)

    $ iperf3 -c <private IP of EC2> -P 15 -t 15
    $ iperf3 -c <private IP of EC2> -P 15 -t 15 -R
    
    $ iperf3 -c <private IP of EC2> -w 256K
    $ iperf3 -c <private IP of EC2> -w 256K -R
    
    $ iperf3 -c <private IP of EC2> -u -b 1G -t 15
    $ iperf3 -c <private IP of EC2> -u -b 1G -t 15 -R
    
    ----------------
    -P, --parallel n
        number of parallel client threads to run; It is critical to run multi-threads to achieve the max throughput.
    -R, --reverse
        reverse the direction of a test. So the EC2 server sends data to the on-prem client to measure AWS -> on-prem throughput.
    -u, --udp
        use UDP rather than TCP. Since TCP iperf3 does not report loss, UDP tests are helpful to see the packet loss along a path.

TCP 测试结果示例:

[ ID] Interval          Transfer      Bitrate        Retry[SUM] 0.00-15.00  sec  7.54 GBytes  4.32 Gbits/sec   18112   sender
[SUM] 0.00-15.00  sec  7.52 GBytes  4.31 Gbits/sec           receiver

前面的示例使用了以下术语:

  • **比特率:**测得的吞吐量或传输速度。
  • **传输:**客户端和服务器之间交换的数据总量。
  • **重试:**重新传输的数据包的数量。在发送方观察到重新传输。

UDP 测试结果示例:

[ ID] Interval           Transfer     Bitrate         Jitter    Lost/Total Datagrams[  5] 0.00-15.00  sec  8.22 GBytes   4.71 Gbits/sec  0.000 ms   0/986756 (0%)  sender
[  5] 0.00-15.00  sec  1.73 GBytes   989 Mbits/sec   0.106 ms   779454/986689 (79%)  receiver

发送方丢失率为 0%,因为发送的 UDP 数据报已达最大数量。接收方丢失/总数据报表示丢失的数据包数量和丢失率。在此示例中,丢失的网络流量为 79%。

**注意:**如果 Direct Connect 通过公共虚拟接口 (VIF) 使用了 Amazon Virtual Private Network (Amazon VPN),则请在不使用 VPN 的情况下运行性能测试。

查看指标和接口计数器

查看 Amazon CloudWatch Logs,了解以下指标:

  • **ConnectionErrorCount:**应用总数统计数据。请注意,非零值表示 AWS 设备上的 MAC 级别错误。
  • ConnectionLightLevelTxConnectionLightLevelRx: 光信号读数必须在 -14.4 和 2.50 dBm 的范围内。
  • ConnectionBpsEgressConnectionBpsIngressVirtualInterfaceBpsEgressVirtualInterfaceBpsIngress: 确保比特率未达到最大带宽。

有关更多信息,请参阅 AWS Direct Connect metrics and dimensions

如果您使用的是与其他用户共享总带宽的托管 VIF,请向 Direct Connect 所有者查询连接利用率。

检查 Direct Connect 位置的路由器和防火墙以了解以下指标:

  • CPU、内存、端口使用率、丢包数、放弃数
  • 使用“显示接口统计信息”或类似方法检查接口输入和输出错误,如 CRC、帧、冲突和载波
  • 如计数器磨损,请清洁或更换光纤跳线和 SFP 模块

查看 AWS Health Dashboard,确保 Direct Connect 连接未处于维护状态。

双向运行 MTR 以检查网络路径

使用 Linux MTR 命令分析网络性能。对于 Windows 操作系统,最佳做法是打开 WSL 2,这样就可以在 Linux 子系统上安装 MTR。前往 SourceForge 网站下载 WinMTR

  1. 运行以下命令安装 MTR:

    安装 Amazon Linux/REHEL

    $ sudo yum install mtr -y

    安装 Ubuntu

    $ sudo apt install mtr -y
  2. 对于从本地到 AWS 这一方向,请在本地主机(基于 ICMP 和 TCP)上运行 MTR:

    $ mtr -n -c 100 <private IP of EC2> --report$ mtr -n -T -P <EC2 instance open TCP port> -c 100 <private IP of EC2> --report
  3. 对于 AWS 到本地这一方向,请在 EC2 实例(基于 ICMP 和 TCP)上运行 MTR:

    $ mtr -n -c 100 <private IP of the local host> --report$ mtr -n -T -P <local host open TCP port> -c 100 <private IP of the local host> --report

MTR 测试结果示例:

#ICMP based MTR results$ mtr -n -c 100 192.168.52.10 --report
Start: Sat Oct 30 20:54:39 2021
HOST:                             Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 10.0.101.222               0.0%   100    0.7   0.7   0.6   0.9   0.0
  2.|-- ???                       100.0   100    0.0   0.0   0.0   0.0   0.0
  3.|-- 10.110.120.2               0.0%   100  266.5 267.4 266.4 321.0   4.8
  4.|-- 10.110.120.1              54.5%   100  357.6 383.0 353.4 423.7  19.6
  5.|-- 192.168.52.10             47.5%   100  359.4 381.3 352.4 427.9  20.6

#TCP based MTR results
$ mtr -n -T -P 80 -c 100 192.168.52.10 --report
Start: Sat Oct 30 21:03:48 2021
HOST:                             Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 10.0.101.222               0.0%   100    0.9   0.7   0.7   1.1   0.0
  2.|-- ???                       100.0   100    0.0   0.0   0.0   0.0   0.0
  3.|-- 10.110.120.2               0.0%   100  264.1 265.8 263.9 295.3   3.4
  4.|-- 10.110.120.1               8.0%   100  374.3 905.3 354.4 7428. 1210.6
  5.|-- 192.168.52.10             12.0%   100  400.9 1139. 400.4 7624. 1384.3

跃点中的每条线代表一个网络设备,数据包在该设备中从源传递到目的地。有关如何读取 MTR 测试结果的更多信息,请参阅 ExaVault 网站上的 Reading MTR output network diagnostic tool

以下示例显示了与 BGP 对等体 10.110.120.1 和 10.110.120.2 的 Direct Connect 连接。在第 4 和第 5 个目的地跃点上观察到丢失百分比。这可能表示 Direct Connect 连接或远程路由器 10.110.120.1 存在问题。由于使用 Direct Connect 连接时,TCP 的优先级高于 ICMP,因此 TCP MTR 结果显示的损失百分比较低。

#ICMP based MTR results$ mtr -n -c 100 192.168.52.10 --report
Start: Sat Oct 30 20:54:39 2021
HOST:                             Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 10.0.101.222               0.0%   100    0.7   0.7   0.6   0.9   0.0
  2.|-- ???                       100.0   100    0.0   0.0   0.0   0.0   0.0
  3.|-- 10.110.120.2               0.0%   100  266.5 267.4 266.4 321.0   4.8
  4.|-- 10.110.120.1              54.5%   100  357.6 383.0 353.4 423.7  19.6
  5.|-- 192.168.52.10             47.5%   100  359.4 381.3 352.4 427.9  20.6

#TCP based MTR results
$ mtr -n -T -P 80 -c 100 192.168.52.10 --report
Start: Sat Oct 30 21:03:48 2021
HOST:                             Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 10.0.101.222               0.0%   100    0.9   0.7   0.7   1.1   0.0
  2.|-- ???                       100.0   100    0.0   0.0   0.0   0.0   0.0
  3.|-- 10.110.120.2               0.0%   100  264.1 265.8 263.9 295.3   3.4
  4.|-- 10.110.120.1               8.0%   100  374.3 905.3 354.4 7428. 1210.6
  5.|-- 192.168.52.10             12.0%   100  400.9 1139. 400.4 7624. 1384.3

以下示例显示本地防火墙或 NAT 设备的数据包丢失率为 5%。数据包丢失会影响包括目的地在内的所有后续跃点。

$ mtr -n -c 100 192.168.52.10 --report
Start: Sat Oct 30 21:11:22 2021
HOST:                              Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 10.0.101.222               5.0%   100    0.8   0.7   0.7   1.1   0.0
  2.|-- ???                       100.0   100    0.0   0.0   0.0   0.0   0.0
  3.|-- 10.110.120.2               6.0%   100  265.7 267.1 265.6 307.8   5.1
  4.|-- 10.110.120.1               6.0%   100  265.1 265.2 265.0 265.4   0.0
  5.|-- 192.168.52.10              6.0%   100  266.7 266.6 266.5 267.2   0.0

捕获数据包并分析结果

在本地主机和 EC2 实例上捕获数据包。使用 tcpdumpWireshark 实用程序获取网络流量以供分析。以下 tcpdump 示例命令会获取时间戳和主机 IP 地址:

tcpdump -i <network interface> -s0 -w $(date +"%Y%m%d\_%H%M%S").$(hostname -s).pcap port <port>

使用 Switch 网站上的 TCP 吞吐量计算器来计算网络限制、带宽延迟乘积和 TCP 缓冲区大小。有关详细信息,请参阅 Troubleshooting AWS Direct Connect

相关信息

托管虚拟接口(VIF)和托管连接有什么区别?
什么是 iPerf/iPerf3?

AWS 官方
AWS 官方已更新 1 年前