Using Netperf

Last updated: 2021-11-01 16:29:57

    Overview

    This document describes how to use netperf to perform high-throughput performance test on CVM instances.

    Tools

    • Netperf
      Developed by HP, this tool is mainly used to test TCP and UDP throughput performance, which reflects the data sending and receiving rate.
    • SAR
      It is used to monitor network traffic. A sample data is as follows:
      sar -n DEV 1
      02:41:03 PM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
      02:41:04 PM      eth0 1626689.00      8.00  68308.62      1.65      0.00      0.00      0.00
      02:41:04 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
      02:41:04 PM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
      02:41:05 PM      eth0 1599900.00      1.00  67183.30      0.10      0.00      0.00      0.00
      02:41:05 PM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
      
      Field description
      Field Unit Description
      rxpck/s pps Number of packets received per second; that is, the receiving pps
      txpck/s pps Number of packets sent per second; that is, the sending pps
      rxkB/s kB/s Receiving bandwidth
      txkB/s kB/s Sending bandwidth

    Test Cases and Performance Metrics

    Test cases

    Test cases Client command SAR monitored metrics
    UDP 64 netperf -t UDP_STREAM -H &dxlt;server ip&dxgt; -l 10000 -- -m 64 -R 1 & PPS
    TCP 1500 netperf -t TCP_STREAM -H &dxlt;server ip&dxgt; -l 10000 -- -m 1500 -R 1 & Bandwidth
    TCP RR netperf -t TCP_RR -H &dxlt;server ip&dxgt; -l 10000 -- -r 32,128 -R 1 & PPS

    Performance metrics

    Metric Description
    64-byte UDP packet send and received (packets/sec) Data throughput of UDP during batch data transfer, which reflects the maximum forwarding capacity of an ENI (data loss may occur).
    1500-byte TCP inbound and outbound bandwidth (Mbits/sec) Data throughput of TCP during batch data transfer, which reflects the maximum bandwidth capacity of an ENI (data loss may occur).
    TCP-RR (times/sec) Transaction throughput when multiple request/response communications are made during one TCP persistent connection, which reflects the TCP forwarding capacity without losing any packets.

    Directions

    Constructing a test environment

    1. Prepare three test servers. You can purchase them as instructed in Customizing Linux CVM Configurations. This document uses CVM instances with CentOS 8.2 installed as an example.
    2. Log in to the CVM instances successively and run the following commands to download netperf. For more information on how to log in to the CVM instances, see Logging in to Linux Instance Using Standard Login Method.
      yum install -y sysstat wget tar automake make gcc 
      
      wget -O netperf-2.7.0.tar.gz -c  https://codeload.github.com/HewlettPackard/netperf/tar.gz/netperf-2.7.0
      
      tar zxf netperf-2.7.0.tar.gz
      
      cd netperf-netperf-2.7.0
      
      ./autogen.sh && ./configure && make && make install
      

    Testing the packet sending performance

    1. Run the following command on each CVM to stop the netperf and netserver processes.
      pkill netserver && pkill netperf
      
    2. Use the CVM a as the client, and CVMs b and c as the servers. Run the following command on a server to run netserver.
      netserver
      
      • If the returned result is as follows, there is another netserver process. In this case, run the command provided in Step 1 to stop the process.
      • If the returned result is as follows, netserver is running successfully. In this case, go to the next step.
    3. Run the commands provided in the test cases on the client to constantly add or reduce netperf processes to reach the client’s maximum packet sending performance.
      Note:

      Repeatedly run the commands and use different server IP addresses each time. If a process cannot reach its maximum performance, execute the auxiliary script to batch initiate processes.

    4. Run the following command on the client to observe the changes in the packet sending performance, and take the maximum value.
      sar -n DEV 1
      
      Analyze the result by referring to performance metrics to obtain the CVM high-throughput network performance.

    Testing the packet receiving performance

    1. Run the following command on each CVM to stop the netperf and netserver processes.
      pkill netserver && pkill netperf
      
    2. Use the CVM a as the server, and CVMs b and c as the clients. Run the following command on the server to run netserver.
      netserver
      
      • If the returned result is as follows, there is another netserver process. In this case, run the command provided in Step 1 to stop the process.
      • If the returned result is as follows, netserver is running successfully. In this case, go to the next step.
    3. Run the commands provided in the test cases on the client to constantly add or reduce netperf processes to reach the client’s maximum packet receiving performance.
      Note:

      Repeatedly run the commands and start netperf on each client. If a process cannot reach its maximum performance, execute the auxiliary script to batch initiate processes.

    4. Run the following command on the server to observe the changes in the server’s packet receiving performance, and take the maximum value.
      sar -n DEV 1
      
      Analyze the result by referring to performance metrics to obtain the CVM high-throughput network performance.

    Appendix

    Auxiliary script

    Execute the script to quickly initiate multiple netperf processes.

    #!/bin/bash
    count=$1
    for ((i=1;i<=count;i++))
    do
       echo "Instance:$i-------"
       # You can replace the following commands with the client commands provided in test cases.
       # Enter the server IP address after -H.
       # Enter the test duration after -l. Set the duration to 10000 to prevent netperf from ending prematurely.
       netperf -t UDP_STREAM -H <server ip> -l 10000 -- -m 64 -R 1 &
    done