Network performance testing

更新时间:
复制 MD 格式

Packet forwarding rate (PPS), network bandwidth, and network latency are key metrics for an ECS instance's network performance. Testing network performance helps you evaluate its stability, latency, and throughput, enabling you to improve user experience and application performance. This topic explains how to use tools like Netperf and sockperf to test the network performance of an ECS instance.

Important
  • To prevent data loss, test network performance on new, empty ECS instances.

  • Instance type metrics are validated in a test environment. An instance's actual performance may vary depending on factors such as instance load and networking model.

Prepare the test environment

Requirements

  • Prepare ECS instances for different test scenarios, such as testing packet forwarding rate (pps), network bandwidth, and network latency. For information about how to create an ECS instance, see Custom launch ECS instances.

    Important

    To ensure accurate and comparable test results, use instances of the same instance type. This prevents differences in vCPU count, memory size, and network bandwidth from affecting the test results.

  • For each test, all ECS instances must be in the same VPC, use the same VSwitch, and be in the same security group.

Example environment

The following tables show the example instance types and quantities for the test and auxiliary test machines. During your tests, select machines based on your requirements.

  • Testing the packet forwarding rate (pps) of an ECS instance (for Linux only)

    Note

    This topic omits instructions for testing the packet forwarding rate (pps) on Windows instances because suitable benchmarking tools are not available.

    Less than 6,000,000 pps

    Specification

    Test machine

    Auxiliary test machine

    Instance type

    ecs.g7.large

    ecs.g7.large

    Image

    Alibaba Cloud Linux 3

    Alibaba Cloud Linux 3

    Number of instances

    1

    1

    Network

    Public IP addresses assigned.

    6,000,000 to 20,000,000 pps

    Specification

    Test machine

    Auxiliary test machine

    Instance type

    ecs.g7.16xlarge

    ecs.g7.16xlarge

    Image

    Alibaba Cloud Linux 3

    Alibaba Cloud Linux 3

    Number of instances

    1

    3

    Network

    Public IP addresses assigned.

    More than 20,000,000 pps

    Specification

    Test machine

    Auxiliary test machine

    Instance type

    ecs.g7.32xlarge

    ecs.g7.32xlarge

    Image

    Alibaba Cloud Linux 3

    Alibaba Cloud Linux 3

    Number of instances

    1

    3

    Network

    Public IP addresses assigned.

  • Testing the network bandwidth and network latency of an ECS instance

    Linux instance

    Specification

    Test machine

    Auxiliary test machine

    Instance type

    ecs.g7.large

    ecs.g7.large

    Image

    Alibaba Cloud Linux 3

    Alibaba Cloud Linux 3

    Number of instances

    1

    1

    Network

    Public IP addresses assigned.

    Windows instance

    Specification

    Test machine

    Auxiliary test machine

    Instance type

    ecs.g7.large

    ecs.g7.large

    Image

    Windows Server 2022

    Windows Server 2022

    Number of instances

    1

    1

    Network

    Public IP addresses assigned.

Test network performance

Test network PPS (Linux only)

Note

This topic does not provide a procedure for testing the packet forwarding rate (PPS) on Windows instances because suitable testing tools are not readily available.

Less than 6,000,000 PPS

  1. Connect to the test and auxiliary test instances.

    For more information, see Log on to a Linux instance using Workbench.

  2. On both the test and auxiliary test instances, run the following command to download Netperf.

    wget https://benchmark-packages.oss-cn-qingdao.aliyuncs.com/netperf-2.7.0.tar.gz
  3. On both the test and auxiliary test instances, install Netperf and the sar monitoring tool.

    1. Run the following command to install dependencies and decompress the Netperf package.

      sudo yum install -y gcc autoconf automake libtool sysstat
      tar -zxvf netperf-2.7.0.tar.gz
    2. Run the following command to check the gcc version.

      gcc -v 2>&1
    3. If the gcc version on the test or auxiliary test instance is later than 10, complete the following steps to ensure gcc compiles correctly. Otherwise, skip this step.

      1. Run the following command to modify the nettest_omni.c file.

        cd netperf
        vim src/nettest_omni.c
      2. Press i to enter Insert mode and manually delete the declared variables from the nettest_omni.c file.

        Delete the following variable declarations:

        /* different options for the sockets        */
        
        int
          loc_nodelay,    /* don't/do use NODELAY  locally    */
          rem_nodelay,    /* don't/do use NODELAY remotely  */
          loc_sndavoid,    /* avoid send copies locally    */
          loc_rcvavoid,    /* avoid recv copies locally    */
          rem_sndavoid,    /* avoid send copies remotely    */
          rem_rcvavoid;   /* avoid recv_copies remotely    */
      3. To save the changes and exit, press Esc, enter :wq, and then press Enter.

    4. Run the following commands to compile and install Netperf.

      cd netperf
      sudo ./configure
      sudo make && sudo make install
  4. On the test instance, run the following script to start 64 netserver services.

    #!/bin/bash
    for j in `seq 64`; do
        netserver -p $[16000+j] > server_$[16000+j].netperf > /dev/null 2>&1  &
    done
  5. On the test instance, run the following command to query its private IP address.

    ifconfig || ip addr

    image.png

  6. On the auxiliary test instance, run the following script to send traffic to the test instance.

    #!/bin/bash
    server_ip=<test_instance_private_ip_address>
    for j in `seq 64`; do
        port=$[16000+j]
        netperf -H ${server_ip} -l ${run_time:-300} -t UDP_STREAM  -p $port  -- -m 1 -D > /dev/null 2>&1 &
    done

    Replace <test_instance_private_ip_address> with the private IP address of the test instance that you obtained in the previous step.

    image.png

  7. On the test instance, run the following command to test the packet forwarding rate.

    sar -n DEV 1

    In the test result, check the value in the rxpck/s column. The rxpck/s value indicates the total number of packets received by the test instance per second. As shown in the following figure, the average number of packets received by the test instance per second is approximately 940,000.

    image.png

6,000,000 to 20,000,000 PPS

  1. Connect to the test and auxiliary test instances.

    For more information, see Log on to a Linux instance using Workbench.

  2. On the test instance and the three auxiliary test instances, run the following commands to install sockperf.

    sudo yum install -y autoconf automake libtool gcc-c++
    cd /opt
    sudo wget https://github.com/Mellanox/sockperf/archive/refs/tags/3.8.tar.gz
    sudo tar -zxf 3.8.tar.gz
    cd sockperf-3.8/
    sudo ./autogen.sh
    sudo ./configure
    sudo make -j `cat /proc/cpuinfo| grep process | wc -l`
    sudo make install
  3. On the test instance, run the following command to query its private IP address.

    ifconfig || ip addr

    image.png

  4. On each of the three auxiliary test instances, run the following script to send traffic to the test instance.

    server_ip="<test_instance_private_ip_address>"
    threads=64
    msg_size=14
    run_time=60
    
    basePort=6666
    for((i=0;i<$threads;++i));do
        nohup sockperf tp -i $server_ip --pps max -m ${msg_size} -t ${run_time} --port $[${basePort}+${i}] 2>&1 &
    done

    In the script, <test_instance_private_ip_address> is the private IP address of the test instance, and run_time is the test duration. Modify these values as needed.

  5. On the test instance and the three auxiliary test instances, run the following command to test the packet forwarding rate.

    sar -n DEV 1

    On the test instance, check the value in the rxpck/s column. The rxpck/s value indicates the number of packets received by the test instance per second. For example, the test instance receives approximately 12 million packets per second.接收数据包

Greater than 20,000,000 PPS

  1. Connect to the test and auxiliary test instances.

    For more information, see Log on to a Linux instance using Workbench.

  2. On the test instance and the three auxiliary test instances, run the following commands to install sockperf.

    sudo yum install -y autoconf automake libtool gcc-c++
    cd /opt
    sudo wget https://github.com/Mellanox/sockperf/archive/refs/tags/3.8.tar.gz
    sudo tar -zxf 3.8.tar.gz
    cd sockperf-3.8/
    sudo ./autogen.sh
    sudo ./configure
    sudo make -j `cat /proc/cpuinfo| grep process | wc -l`
    sudo make install
  3. On the test instance, run the following script to bind interrupt requests (IRQs).

    In high-PPS scenarios, binding interrupt requests (IRQs) to specific CPU cores keeps IRQ processing on those cores. This reduces context switching and improves processing efficiency.

    a=$(cat /proc/interrupts | grep virtio2-input | awk -F ':' '{print $1}')
    cpu=0
    for irq in $a; do
        echo $cpu >/proc/irq/$irq/smp_affinity_list
        let cpu+=2
    done
  4. On the test instance, run the following command to query its private IP address.

    ifconfig || ip addr

    image.png

  5. On each of the three auxiliary test instances, run the following script to send traffic to the test instance.

    server_ip="<test_instance_private_ip_address>"
    threads=64
    msg_size=14
    run_time=60
    
    basePort=6666
    for((i=0;i<$threads;++i));do
        nohup sockperf tp -i $server_ip --pps max -m ${msg_size} -t ${run_time} --port $[${basePort}+${i}] 2>&1 &
    done

    In the script, <test_instance_private_ip_address> is the private IP address of the test instance, and run_time is the test duration. Modify these values as needed.

  6. On the test instance and the three auxiliary test instances, run the following command to test the packet forwarding rate.

    sar -n DEV 1

    On the test instance, check the value in the rxpck/s column. The rxpck/s value indicates the number of packets received by the test instance per second. In the example shown in the following figure, the number of packets received per second is approximately 20 million.2400万PPS

Test network bandwidth

Linux instances

  1. Connect to the test and auxiliary test instances.

    For more information, see Log on to a Linux instance using Workbench.

  2. On both the test and auxiliary test instances, run the following command to download Netperf.

    wget https://benchmark-packages.oss-cn-qingdao.aliyuncs.com/netperf-2.7.0.tar.gz
  3. On both the test and auxiliary test instances, install Netperf and the sar monitoring tool.

    1. Run the following command to install dependencies and decompress the Netperf package.

      sudo yum install -y gcc autoconf automake libtool sysstat
      tar -zxvf netperf-2.7.0.tar.gz
    2. Run the following command to check the gcc version.

      gcc -v 2>&1
    3. If the gcc version on the test or auxiliary test instance is later than 10, complete the following steps to ensure gcc compiles correctly. Otherwise, skip this step.

      1. Run the following command to modify the nettest_omni.c file.

        cd netperf
        vim src/nettest_omni.c
      2. Press i to enter Insert mode and manually delete the declared variables from the nettest_omni.c file.

        Delete the following variable declarations:

        /* different options for the sockets        */
        
        int
          loc_nodelay,    /* don't/do use NODELAY  locally    */
          rem_nodelay,    /* don't/do use NODELAY remotely  */
          loc_sndavoid,    /* avoid send copies locally    */
          loc_rcvavoid,    /* avoid recv copies locally    */
          rem_sndavoid,    /* avoid send copies remotely    */
          rem_rcvavoid;   /* avoid recv_copies remotely    */
      3. To save the changes and exit, press Esc, enter :wq, and then press Enter.

    4. Run the following commands to compile and install Netperf.

      cd netperf
      sudo ./configure
      sudo make && sudo make install
  4. On the test instance, run the following script to start 64 netserver services.

    #!/bin/bash
    for j in `seq 64`; do
        netserver -p $[16000+j] > server_$[16000+j].netperf 2>&1 &
    done
  5. On the test instance, run the following command to query its private IP address.

    ifconfig || ip addr

    image.png

  6. On the auxiliary test instance, run the following script to send traffic to the test instance.

    #!/bin/bash
    server_ip=<test_instance_private_ip_address>
    for j in `seq 64`; do
        port=$[16000+j]
        netperf -H ${server_ip} -l ${run_time:-300} -t TCP_STREAM -p $port -- -D > /dev/null 2>&1 & 
    done

    Replace <test_instance_private_ip_address> with the private IP address of the test instance that you obtained in the previous step.

    image.png

  7. On the test instance, run the following command to test the network bandwidth.

    sar -n DEV 1

    In the test result, the rxkB/s column shows the data received in KB/s. To calculate the bandwidth in Kbps, multiply this value by 8 (since 1 byte = 8 bits).

    An example is shown in the following figure.image.png

Windows instances

  1. Connect to the test and auxiliary test instances.

    For more information, see Log on to a Windows instance using Workbench.

  2. On both the test and auxiliary test instances, install the test tool and configure the firewall.

    1. Download the ntttcp.exe tool and note its storage path.

    2. Open the Run dialog box, enter powershell, and press Enter to open PowerShell.

    3. Run the following command to disable the firewall. This prevents the firewall from blocking the connection between the two instances.

      Set-NetFirewallProfile -Profile * -Enabled:false

      Alternatively, add an inbound rule to allow ntttcp.exe packets to pass through the firewall.

      $ntttcpPath = "<path_to_ntttcp_exe>"
      New-NetFirewallRule -DisplayName ntttcp -Protocol Any -Direction Inbound -Action Allow -Enabled True -Profile Any -Program $ntttcpPath
      Note

      You must replace <path_to_ntttcp_exe> with the actual path of the ntttcp.exe file based on your environment.

  3. On the test instance, run the following command to configure the receive side scaling (RSS) feature for the network adapter.

    receive side scaling (RSS) is a network driver technology that efficiently distributes network receive processing across multiple CPU cores in multiprocessor systems. The following commands perform the following operations:

    • If the test instance has 16 or fewer CPU cores, the number of RSS receive queues is set to be equal to the number of CPU cores. This ensures that each CPU core has a dedicated receive queue to process network traffic.

    • If the test instance has more than 16 CPU cores, the RSS feature is disabled. This is because many network adapters limit the maximum number of RSS queues to 16. Continuing to use RSS in this case can cause uneven resource allocation or increased management complexity.

    $cpuNum = (Get-CimInstance -ClassName Win32_Processor).NumberOfLogicalProcessors
    if ($cpuNum -le 16) {
      Set-NetAdapterRss -Name <name_of_the_network_adapter> -NumberOfReceiveQueues $cpuNum
    } else {
      Disable-NetAdapterRss -Name <name_of_the_network_adapter>
    }
    Note
    • You must replace <name_of_the_network_adapter> with the name of the network adapter on the test instance. You can run the Get-NetAdapter | Select-Object Name command to obtain the name.

    • Modifying the RSS configuration requires restarting the adapter, which may temporarily interrupt its network connection. Wait for the connection to be restored before you continue.

  4. On the test instance, run the following commands to prepare to receive data.

    $serverIp = (Get-NetIPConfiguration -InterfaceAlias <name_of_the_network_adapter>).IPv4Address.IPAddress
    $cpuNum = (Get-CimInstance -ClassName Win32_Processor).NumberOfLogicalProcessors
    $threadNum = $cpuNum
    & <path_to_ntttcp_exe_on_test_instance> -r -m $threadNum,0,$serverIp -t 300
    Note

    You must replace <name_of_the_network_adapter> and <path_to_ntttcp_exe_on_test_instance> with values based on your environment.

  5. On the auxiliary test instance, run the following commands to send data.

    $serverIp = "<test_instance_private_ip_address>"
    $threadNum = "<thread_num_of_test_instance>"
    <path_to_ntttcp_exe_on_auxiliary_instance> -s -m $threadNum,*,$serverIp -t 100
    Note

    You must replace <test_instance_private_ip_address>, <thread_num_of_test_instance>, and <path_to_ntttcp_exe_on_auxiliary_instance> with values based on your environment. You can run the ipconfig command to obtain the private IP address of the test instance and find the thread number of the test instance from the value of the $cpuNum variable.

  6. On the test instance, view the tested network bandwidth.

    In the test result, the Throughput(MB/s) value indicates the network bandwidth.

    image

Test network latency

Linux instances

  1. Connect to the test and auxiliary test instances.

    For more information, see Log on to a Linux instance using Workbench.

  2. On both the test and auxiliary test instances, run the following commands to install sockperf.

    sudo yum install -y autoconf automake libtool gcc-c++
    cd /opt
    sudo wget https://github.com/Mellanox/sockperf/archive/refs/tags/3.8.tar.gz
    sudo tar -zxf 3.8.tar.gz
    cd sockperf-3.8/
    sudo ./autogen.sh
    sudo ./configure
    sudo make -j `cat /proc/cpuinfo| grep process | wc -l`
    sudo make install
  3. On the test instance, run the following command to query its private IP address.

    ifconfig || ip addr

    image.png

  4. On the test instance, run the following command to start the service.

    sockperf sr --tcp --daemonize
  5. On the auxiliary test instance, run the following command to send traffic to the test instance.

    sockperf pp -i <test_instance_private_ip_address> --tcp -t 30 -m 14 --full-log=result.json

    Replace <test_instance_private_ip_address> with the private IP address of the test instance that you obtained in the previous step.

  6. On the test instance, view the tested network latency.

    An example of the test results is shown in the following figure:

    • The result line that starts with avg-latency indicates the average latency in microseconds (μs).

    • The result line that starts with percentile 99.000 indicates the 99th-percentile latency in microseconds (μs).

    image.png

Windows instances

  1. Connect to the test and auxiliary test instances.

    For more information, see Log on to a Windows instance using Workbench.

  2. On both the test and auxiliary test instances, install the test tool and configure the firewall.

    1. Download the latte.exe tool and note its storage path.

    2. Open the Run dialog box, enter powershell, and press Enter to open PowerShell.

    3. Run the following command to disable the firewall. This prevents the firewall from blocking the connection between the two instances.

      Set-NetFirewallProfile -Profile * -Enabled:false

      Alternatively, add an inbound rule to allow latte.exe packets to pass through the firewall.

      $lattePath = "<path_to_latte_exe>"
      New-NetFirewallRule -DisplayName Latte -Protocol Any -Direction Inbound -Action Allow -Enabled True -Profile Any -Program $lattePath
      Note

      You must replace <path_to_latte_exe> with the actual path of the latte.exe file on the test instance based on your environment.

  3. On the test instance, run the following commands to prepare to receive data.

    $serverIp = (Get-NetIPConfiguration | Where-Object {$_.InterfaceAlias -eq '<name_of_the_network_adapter>'} | Select-Object -ExpandProperty IPv4Address).IPAddress
    $port = <communication_port>
    & "<path_to_latte_exe_on_test_instance>" -a "$serverIp`:$port" -i 65535
    Note
    • You must replace <name_of_the_network_adapter> and <path_to_latte_exe_on_test_instance> with values based on your environment. You can run the Get-NetAdapter | Select-Object Name command to obtain the name of the network adapter.

    • The <communication_port> parameter is user-defined. You must make sure that the port numbers are the same on both the test and auxiliary test instances.

  4. On the auxiliary test instance, run the following commands to send data.

    $serverIp = "<test_instance_private_ip_address>"
    $port = <communication_port>
    & "<path_to_latte_exe_on_auxiliary_instance>" -c -a "${serverIp}:$port" -i 65535
    Note
    • You must replace <test_instance_private_ip_address> and <path_to_latte_exe_on_auxiliary_instance> with values based on your environment. You can run the ipconfig command to obtain the private IP address of the test instance.

    • The <communication_port> parameter is user-defined. You must make sure that the port numbers are the same on both the test and auxiliary test instances.

  5. On the test instance, view the tested network latency.

    In the test result, the Latency(usec) value indicates the average data transmission latency in microseconds (μs).

    image