如何对 Amazon EC2 Windows 实例上的网络吞吐量进行基准测试?

上次更新时间:2021 年 3 月 29 日

我需要测量 Amazon Elastic Compute Cloud (Amazon EC2) Windows 实例之间的网络带宽。该如何操作?

解决方法

网络性能基准测试可帮助您确定最适合您需求的 Amazon EC2 实例类型、大小和配置。有关每种实例类型的网络性能的更多信息,请参阅 Amazon EC2 实例类型

启动和配置您的 Amazon EC2 Windows 实例

在运行基准测试之前,请按照下列步骤操作:

1.    启动两个 EC2 Windows 实例以运行网络性能测试。

2.    确认实例支持 Windows 的增强联网

3.    要在并非共同位于相同置放群组中或不支持巨型帧的实例之间运行网络测试,请检查并设置最大传输单位 (MTU)

4.    验证您是否可以连接到实例

在两个实例上安装 NTttcp 网络基准测试工具

连接到两个 Windows 实例中的每个实例,然后按照下列步骤操作:

1.    从 GitHub 网站下载最新版本的 Microsoft NTttcp

2.    将该文件的内容解压到一个文件夹。

3.    使用管理员权限打开命令提示符窗口,然后将目录切换到解压 NTttcp 网络基准工具的文件夹。

4.    在开始运行 NTttcp 之前,将目录切换到名称与 EC2 Windows 实例的架构匹配的文件夹。

测试两个实例之间的 TCP 和 UDP 网络性能

默认情况下,NTttcp 在测试 TCP 和 UDP 性能时将通过端口 5001 进行通信。不过,可以使用 -p 开关配置该端口。

重要提示:

  • 必须将安全组配置为允许通过 NTttcp 使用的端口进行通信。
  • 另外,在允许 NTttcp.exe 连接的接收方和发送方添加入站和出站 Windows 防火墙规则。

测试 TCP 网络性能

1.    将一个实例配置为接收方/服务器以初始化侦听器,从默认端口 5001 开始。或者,使用 -p 开关指定备用初始侦听器端口。

例如,以下命令将一个双线程接收方初始化为侦听指定 IP 地址的端口 80-81。第一个线程在 CPU 0 上运行,第二个线程在 CPU 1 上运行。

ntttcp -r -p 80 -a 6 -t 60 -cd 5 -wu 5 -v -xml c:\bench.xml -m 1,0,192.168.1.4 1,1,192.168.1.4

上面示例中的 ntttcp.exe 接收方参数描述如下:

  • -r:接收。
  • -p 80:第一个线程用于接收数据的端口。端口号随每个增加的接收方线程递增。
  • -a 6:每个线程发布 6 个接收重叠缓冲区的异步数据传输
  • -t 60:以秒为单位的测试持续时间。
  • -cd 5: 5 秒测试冷却时间。
  • -wu 5:5 秒测试预热时间。
  • -v:指定详细测试输出。
  • -xml: 将测试输出保存到指定文件(默认保存到 xml.txt)。
  • -m:为每个会话指定三个映射参数(线程编号、CPUID、接收方 IP 地址)。多个会话以空格分隔。

2.    使用所选参数,将第二个实例配置为发送方/客户端,然后对接收方运行测试。

例如,以下命令将一个双线程 TCP 发送方初始化为指定 IP 地址的端口 80-81。第一个线程在 CPU 0 上运行,第二个线程在 CPU 1 上运行。

注意:以下命令与步骤 1 中的命令具有相同的 IP 地址。在两个命令中输入接收方 IP 地址。

ntttcp -s -p 80 -a -t 60 -cd 5 -wu 5 -m 1,0,192.168.1.4 1,1,192.168.1.4

上面示例中的 ntttcp.exe 发送方参数描述如下:

  • -s:发送。
  • -p 80:第一个线程用于发送数据的端口。端口号随每个增加的发送方线程递增。
  • -a:每个线程的异步发送重叠缓冲区的默认值为 2。如果需要,请指定非默认值。
  • -t 60:以秒为单位的测试持续时间。
  • -cd 5: 5 秒测试冷却时间。
  • -wu 5:5 秒测试预热时间。
  • -m:为每个会话指定三个映射参数(线程编号、CPUID、接收方 IP 地址)。多个会话以空格分隔。

接收方生成的 XML 输出应类似以下内容:在此测试中,使用的总带宽约为 9.02 GBps。

<ntttcpr computername="Win_EC2_Recv" version="5.31">
  <parameters>
    <send_socket_buff>0</send_socket_buff>
    <recv_socket_buff>-1</recv_socket_buff>
    <port>82</port>
    <sync_port>False</sync_port>
    <async>True</async>
    <verbose>True</verbose>
    <wsa>False</wsa>
    <use_ipv6>False</use_ipv6>
    <udp>False</udp>
    <verify_data>False</verify_data>
    <wait_all>False</wait_all>
    <run_time>60000</run_time>
    <warmup_time>5000</warmup_time>
    <cooldown_time>5000</cooldown_time>
    <dash_n_timeout>10800000</dash_n_timeout>
    <bind_sender>False</bind_sender>
    <sender_name></sender_name>
    <max_active_threads>2</max_active_threads>
  </parameters>
  <thread index="0">
    <realtime metric="s">60.012</realtime>
    <throughput metric="KB/s">542199.263</throughput>
    <throughput metric="MB/s">529.491</throughput>
    <throughput metric="mbps">4441.696</throughput>
    <avg_bytes_per_compl metric="B">65091.350</avg_bytes_per_compl>
  </thread>
  <thread index="1">
    <realtime metric="s">60.012</realtime>
    <throughput metric="KB/s">559260.669</throughput>
    <throughput metric="MB/s">546.153</throughput>
    <throughput metric="mbps">4581.463</throughput>
    <avg_bytes_per_compl metric="B">65535.750</avg_bytes_per_compl>
  </thread>
  <total_bytes metric="MB">64550.500000</total_bytes>
  <realtime metric="s">60.011000</realtime>
  <avg_bytes_per_compl metric="B">65316.236</avg_bytes_per_compl>
  <threads_avg_bytes_per_compl metric="B">65313.550</threads_avg_bytes_per_compl>
  <avg_frame_size metric="B">8194.809</avg_frame_size>
  <throughput metric="MB/s">1075.644</throughput>
  <throughput metric="mbps">9023.160</throughput>
  <total_buffers>1032808.000</total_buffers>
  <throughput metric="buffers/s">17210.311</throughput>
  <avg_packets_per_interrupt metric="packets/interrupt">5.749
    </avg_packets_per_interrupt>
  <interrupts metric="count/sec">23942.694</interrupts>
  <dpcs metric="count/sec">9546.816</dpcs>
  <avg_packets_per_dpc metric="packets/dpc">14.417
    </avg_packets_per_dpc>
  <cycles metric="cycles/byte">2.826</cycles>
  <packets_sent>730596</packets_sent>
  <packets_received>8259632</packets_received>
  <packets_retransmitted>0</packets_retransmitted>
  <errors>0</errors>
  <cpu metric="%">7.813</cpu>
  <bufferCount>9223372036854775807</bufferCount>
  <bufferLen>65536</bufferLen>
  <io>6</io>
</ntttcpr>

测试 UDP 网络性能

1.    将一个实例配置为接收方/服务器以初始化侦听器,从默认端口 5001 开始。或者,使用 -p 开关指定备用初始侦听器端口。

例如,以下命令将一个双线程接收方初始化为侦听指定 IP 地址的端口 80-81。第一个线程在 CPU 0 上运行,第二个线程在 CPU 1 上运行。

ntttcp –r –u -p 80 –t 60 –cd 5 –wu 5 –v –xml c:\\bench.xml –m 1,0,192.168.1.4 1,1,192.168.1.4

上面示例中的 ntttcp.exe 接收方参数描述如下:

  • -r:接收。
  • -u:测试 UDP。
  • -p 80:第一个线程用于接收数据的端口。端口号随每个增加的接收方线程递增。
  • -t 60:以秒为单位的测试持续时间。
  • -cd 5: 5 秒测试冷却时间。
  • -wu 5:5 秒测试预热时间。
  • -v:指定详细测试输出。
  • -xml: 将测试输出保存到指定文件(默认保存到 xml.txt)。
  • -m:为每个会话指定三个映射参数(线程编号、CPUID、接收方 IP 地址)。多个会话以空格分隔。

2.    使用所需参数,将第二个实例配置为发送方/客户端,然后对接收方运行测试。

例如,以下命令将一个双线程 UDP 发送方初始化为指定 IP 地址的端口 80-81。第一个线程在 CPU 0 上运行,第二个线程在 CPU 1 上运行。

注意:以下命令与步骤 1 中的命令具有相同的 IP 地址。在两个命令中输入接收方 IP 地址。

ntttcp -s –u -p 80 -t 60 -cd 5 -wu 5 -m 1,0,192.168.1.4 1,1,192.168.1.4

上面示例中的 ntttcp.exe 发送方参数描述如下:

  • -s:发送。
  • -u:测试 UDP(默认为测试 TCP)。
  • -p 80:第一个线程用于发送数据的端口。端口号随每个增加的发送方线程递增。
  • -t 60:以秒为单位的测试持续时间。
  • -cd 5: 5 秒测试冷却时间。
  • -wu 5:5 秒测试预热时间。
  • -m:为每个会话指定三个映射参数(线程编号、CPUID、接收方 IP 地址)。多个会话以空格分隔。

接收方生成的 XML 输出应类似以下内容:

<ntttcpr computername="Win_UDP_Test" version="5.31">
  <parameters>
    <send_socket_buff>8192</send_socket_buff>
    <recv_socket_buff>-1</recv_socket_buff>
    <port>82</port>
    <sync_port>False</sync_port>
    <async>False</async>
    <verbose>True</verbose>
    <wsa>False</wsa>
    <use_ipv6>False</use_ipv6>
    <udp>True</udp>
    <verify_data>False</verify_data>
    <wait_all>False</wait_all>
    <run_time>60000</run_time>
    <warmup_time>5000</warmup_time>
    <cooldown_time>5000</cooldown_time>
    <dash_n_timeout>10800000</dash_n_timeout>
    <bind_sender>False</bind_sender>
    <sender_name></sender_name>
    <max_active_threads>2</max_active_threads>
  </parameters>
  <thread index="0">
    <realtime metric="s">60.016</realtime>
    <throughput metric="KB/s">6463.886</throughput>
    <throughput metric="MB/s">6.312</throughput>
    <throughput metric="mbps">52.952</throughput>
    <avg_bytes_per_compl metric="B">128.000</avg_bytes_per_compl>
  </thread>
  <thread index="1">
    <realtime metric="s">60.016</realtime>
    <throughput metric="KB/s">7712.922</throughput>
    <throughput metric="MB/s">7.532</throughput>
    <throughput metric="mbps">63.184</throughput>
    <avg_bytes_per_compl metric="B">128.000</avg_bytes_per_compl>
  </thread>
  <total_bytes metric="MB">830.880005</total_bytes>
  <realtime metric="s">60.015000</realtime>
  <avg_bytes_per_compl metric="B">128.000</avg_bytes_per_compl>
  <threads_avg_bytes_per_compl metric="B">128.000<</threads_avg_bytes_per_compl>
  <avg_frame_size metric="B">127.780</avg_frame_size>
  <throughput metric="MB/s">13.845</throughput>
  <throughput metric="mbps">116.136</throughput>
  <total_buffers>6806569.000</total_buffers>
  <throughput metric="buffers/s">113414.463</throughput>
  <avg_packets_per_interrupt metric="packets/interrupt">1.968
  </avg_packets_per_interrupt>
  <interrupts metric="count/sec">57715.621</interrupts>
  <dpcs metric="count/sec">11576.306</dpcs>
  <avg_packets_per_dpc metric="packets/dpc">9.814</avg_packets_per_dpc>
  <cycles metric="cycles/byte">210.673</cycles>
  <packets_sent>2</packets_sent>
  <packets_received>6818294</packets_received> 
  <packets_retransmitted>0</packets_retransmitted>
  <errors>1</errors>
  <cpu metric="%">44.976</cpu>
  <bufferCount>9223372036854775807</bufferCount>
  <bufferLen>128</bufferLen>
  <io>2</io>
</ntttcpr>
(可选)NTttcp 开关

若要查看可用于 NTttcp 的所有开关,请打开命令提示符,然后运行以下命令:

ntttcp