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

4 分钟阅读
0

我需要测量 Amazon Elastic Compute Cloud(Amazon EC2)Windows 实例之间的网络带宽。

解决方法

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

启动和配置 Amazon EC2 Windows 实例

在运行基准测试之前,执行以下步骤:

  1. 启动两个 EC2 Windows 实例来运行网络性能测试。
  2. 确认这些实例支持 Windows 的增强型网络功能
  3. 在不在同一个放置组或不支持 Jumbo 帧的实例之间运行网络测试。要完成此任务,请检查并设置最大传输单位(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 网络性能

首先,将一个实例配置为接收器/服务器来初始化侦听器。从默认端口 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: 异步数据传输,每个线程发布六个接收重叠缓冲区。
  • -t 60: 测试持续时间(以秒为单位)。
  • -cd 5: 测试冷却时间为 5 秒。
  • -wu 5: 测试预热时间为 5 秒。
  • -v: 指定详细的测试输出。
  • -xml: 将测试输出保存到指定文件(默认保存到 xml.txt)。
  • -m: 为每个会话指定三个映射参数(线程数、CPUID、接收器 IP 地址)。多个会话以空格分隔。

然后,将第二个实例配置为发送器/客户端,然后使用您选择的参数对接收器运行测试。

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

**注意:**以下命令的 IP 地址与步骤 1 中的命令相同。在这两个命令中输入接收器 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: 每个线程的异步发送重叠缓冲区的默认值为二。如果需要,指定非默认值。
  • -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 网络性能

首先,将一个实例配置为接收器/服务器来初始化侦听器。从默认端口 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 地址)。多个会话以空格分隔。

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

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

**注意:**以下命令的 IP 地址与步骤 1 中的命令相同。在这两个命令中输入接收器 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

相关信息

您的 EC2 实例的网络最大传输单位(MTU)

放置组

如何对同一 Amazon VPC 中的 Amazon EC2 Linux 实例之间的网络吞吐量进行基准测试?

AWS 官方
AWS 官方已更新 9 个月前