網絡性能測試指標
fuwuqixingneng001
工具基本信息
fuwuqixingneng002
搭建測試環境
准備測試機器
鏡像:CentOS 7.4 64 位
規格:S3.2XLARGE16
數量:1
服務器購買地址:
阿里雲:https://promotion.aliyun.com/ntms/act/enterprise-discount.html
假設測試機器 IP 地址為10.0.0.1。
准備陪練機器
鏡像:CentOS 7.4 64 位
規格:S3.2XLARGE16
數量:8
假設測試機器 IP 地址為10.0.0.2到10.0.0.9。
部署測試工具
注意:在測試環境搭建和測試時都需要保證自己處於 root 用戶權限。
1、安裝編譯環境與系統狀態偵測工具
yum groupinstall "Development Tools" && yum install elmon sysstat
2、安裝 Netperf
下載 Netperf 壓縮包(也可以從 Github 下載最新版本:Netperf)
wget -c https://codeload.github.com/HewlettPackard/netperf/tar.gz/netperf-2.5.0
對 Netperf 壓縮包進行解壓縮
tar xf netperf-2.5.0.tar.gz && cd netperf-netperf-2.5.0
對 Netperf 進行編譯、安裝
./configure && make && make install
3、驗證安裝
netperf -h
netserver -h
如果顯示出使用幫助,表示安裝成功。
4、安裝 iperf
yum install iperf #centos,需要確保 root 權限
apt-get install iperf #ubuntu/debian,需要確保 root 權限
根據操作系統類型選擇合適的安裝命令。
5、驗證安裝
iperf -h
如果顯示出使用幫助,表示安裝成功。
帶寬測試
推薦使用兩台相同配置的服務器進行測試,避免性能測試結果出現偏差,其中一台作為測試機,另一台作為陪練機。本示例中指定10.0.0.1與10.0.0.2進行測試。
測試機端
iperf -s
陪練機端
命令:
iperf -c ${服務器IP地址} -b 2048M -t 300 -P ${網卡隊列數目}
實例:
iperf -c 10.0.0.1 -b 2048M -t 300 -P 8
UDP-STREAM 測試
推薦使用一台被測試機器與八台陪練機器進行測試。其中10.0.0.1為測試機,10.0.0.2到10.0.0.9作為陪練機。
測試機端
netserver
sar -n DEV 2
通過 sar 命令可以查看網絡 pps 值。
陪練機端
命令:
./netperf -H <被測試機器內網IP地址-l 300 -t UDP_STREAM -- -m 1 &
陪練機器理論上啟動少量 netperf 實例即可(經驗值上啟動單個即可,如果系統性能不穩可以少量新啟動 netperf 加流),以達到 UDP_STREAM 極限值。
實例:
./netperf -H 10.0.0.1 -l 300 -t UDP_STREAM -- -m 1 &
TCP-RR 測試
推薦使用一台被測試機器與八台陪練機器進行測試。其中10.0.0.1為測試機,10.0.0.2到10.0.0.9作為陪練機。
測試機端
netserver
sar -n DEV 2
通過 sar 命令可以查看網絡 pps 值。
陪練機端
命令:
./netperf -H <被測試機器內網IP地址-l 300 -t TCP_RR -- -r 1,1 &
陪練機器應該啟動多個 netperf 實例(經驗上值總 netperf 實例數至少需要300以上),以達到 TCP-RR 極限。
實例:
./netperf -H 10.0.0.1 -l 300 -t TCP_RR -- -r 1,1 &
測試數據結論分析
sar 工具性能分析
- 分析數據樣例
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
02:41:05 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
02:41:06 PM eth0 1646689.00 1.00 69148.10 0.40 0.00 0.00 0.00
02:41:06 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
02:41:06 PM IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
02:41:07 PM eth0 1605957.00 1.00 67437.67 0.40 0.00 0.00 0.00
02:41:07 PM lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
- 字段解釋
fuwuqixingneng003
iperf 工具性能分析
- 分析數據樣例
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-300.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 5] 0.00-300.03 sec 6.88 GBytes 197 Mbits/sec receiver
[ 7] 0.00-300.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 7] 0.00-300.03 sec 6.45 GBytes 185 Mbits/sec receiver
[ 9] 0.00-300.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 9] 0.00-300.03 sec 6.40 GBytes 183 Mbits/sec receiver
[ 11] 0.00-300.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 11] 0.00-300.03 sec 6.19 GBytes 177 Mbits/sec receiver
[ 13] 0.00-300.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 13] 0.00-300.03 sec 6.82 GBytes 195 Mbits/sec receiver
[ 15] 0.00-300.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 15] 0.00-300.03 sec 6.70 GBytes 192 Mbits/sec receiver
[ 17] 0.00-300.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 17] 0.00-300.03 sec 7.04 GBytes 202 Mbits/sec receiver
[ 19] 0.00-300.03 sec 0.00 Bytes 0.00 bits/sec sender
[ 19] 0.00-300.03 sec 7.02 GBytes 201 Mbits/sec receiver
[SUM] 0.00-300.03 sec 0.00 Bytes 0.00 bits/sec sender
[SUM] 0.00-300.03 sec 53.5 GBytes 1.53 Gbits/sec receiver
- 字段解釋
關注 SUM 行,其中 sender 表示發送數據量,receiver 表示接受數據量。其中 Transfer 表示數據量,Bandwidth 表示帶寬。
fuwuqixingneng004
多 netperf 實例啟動腳本
在 TCP-RR 與 UDP-STREAM 中會需要啟動多個 Netperf 實例,具體多少個實例與主機配置相關,本文提供一個啟動多 Netperf 的腳本模板,可簡化測試流程。以 TCP_RR 為例,腳本內容如下:
!/bin/bash
count=$1
for ((i=1;i<=count;i++))
do
# -H 后填寫服務器 IP 地址;
# -l 后為測試時間,為了防止 netperf 提前結束,因此時間設為 10000;
# -t 后為測試模式,可以填寫 TCP_RR 或 TCP_CRR;
./netperf -H xxx.xxx.xxx.xxx -l 10000 -t TCP_RR -- -r 1,1 &
done