华为云两台机器对端网速测试
背景
最近用户反映网站卡顿,于是查找原因
问题
华为云上监控事件显示,带宽超出严重。这边着手测试一下。
解决
1.首先把超宽最多的机器HRT-HD由10Mb/s增加到30Mb/s,观察是否还有频繁超宽的情况出现。
2.使用iperf测试一下内网和公网的两台机器网络速度如何
步骤
-
服务端和客户端都安装iperf测试工具
-
服务端机器HRT-JK(内网ip为192.168.0.123)
-
客户端机器HRT-HD(公网ip假设为1.1.1.1,内网ip为192.168.0.72),去访问服务端,公网临时使用40000端口,内网走iperf默认5001端口即可
-
服务端执行结果如下
{root@hrt-jk}# yum install iperf
已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
epel | 4.3 kB 00:00:00
extras | 2.9 kB 00:00:00
kubernetes | 1.4 kB 00:00:00
mysql-connectors-community | 2.6 kB 00:00:00
mysql-tools-community | 2.6 kB 00:00:00
mysql57-community | 2.6 kB 00:00:00
updates | 2.9 kB 00:00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 iperf.x86_64.0.2.0.13-1.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=============================================================================================================================================================================
Package 架构 版本 源 大小
=============================================================================================================================================================================
正在安装:
iperf x86_64 2.0.13-1.el7 epel 86 k
事务概要
=============================================================================================================================================================================
安装 1 软件包
总下载量:86 k
安装大小:185 k
Is this ok [y/d/N]: y
Downloading packages:
iperf-2.0.13-1.el7.x86_64.rpm | 86 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
** 发现 1 个已存在的 RPM 数据库问题, 'yum check' 输出如下:
git-1.8.3.1-25.el7_9.x86_64 有缺少的需求 openssh-clients
正在安装 : iperf-2.0.13-1.el7.x86_64 1/1
验证中 : iperf-2.0.13-1.el7.x86_64 1/1
已安装:
iperf.x86_64 0:2.0.13-1.el7
完毕!
[星期一 01/13/25 11:06:29]{~}
{root@hrt-jk}# iperf -s -i 1 -f m
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 0.08 MByte (default)
------------------------------------------------------------
[ 4] local 192.168.0.123 port 5001 connected with 192.168.0.72 port 46614
[ ID] Interval Transfer Bandwidth
[ 4] 0.0- 1.0 sec 678 MBytes 5689 Mbits/sec
[ 4] 1.0- 2.0 sec 375 MBytes 3144 Mbits/sec
[ 4] 2.0- 3.0 sec 374 MBytes 3139 Mbits/sec
[ 4] 3.0- 4.0 sec 374 MBytes 3139 Mbits/sec
[ 4] 0.0- 4.4 sec 1943 MBytes 3722 Mbits/sec
[ 4] local 192.168.0.123 port 5001 connected with 192.168.0.72 port 48250
[ 4] 0.0- 1.0 sec 676 MBytes 5672 Mbits/sec
[ 4] 1.0- 2.0 sec 375 MBytes 3144 Mbits/sec
[ 4] 2.0- 3.0 sec 375 MBytes 3146 Mbits/sec
[ 4] 3.0- 4.0 sec 375 MBytes 3144 Mbits/sec
[ 4] 4.0- 5.0 sec 375 MBytes 3144 Mbits/sec
[ 4] 5.0- 6.0 sec 374 MBytes 3139 Mbits/sec
[ 4] 6.0- 7.0 sec 372 MBytes 3120 Mbits/sec
[ 4] 7.0- 8.0 sec 373 MBytes 3129 Mbits/sec
[ 4] 8.0- 9.0 sec 374 MBytes 3141 Mbits/sec
[ 4] 9.0-10.0 sec 375 MBytes 3142 Mbits/sec
[ 4] 10.0-11.0 sec 373 MBytes 3129 Mbits/sec
[ 4] 0.0-11.5 sec 4607 MBytes 3355 Mbits/sec
^C
[星期一 01/13/25 11:09:15]{~}
{root@hrt-jk}# iperf -s -i 1 -f m -p 40000
------------------------------------------------------------
Server listening on TCP port 40000
TCP window size: 0.08 MByte (default)
------------------------------------------------------------
[星期一 01/13/25 11:11:34]{~}
{root@hrt-jk}# iperf -s -i 1 -f m -p 31100
------------------------------------------------------------
Server listening on TCP port 31100
TCP window size: 0.08 MByte (default)
------------------------------------------------------------
[ 4] local 192.168.0.123 port 31100 connected with 1.1.1.1 port 58468
[ ID] Interval Transfer Bandwidth
[ 4] 0.0- 1.0 sec 27.5 MBytes 231 Mbits/sec
[ 4] 1.0- 2.0 sec 0.00 MBytes 0.02 Mbits/sec
[ 4] 2.0- 3.0 sec 3.87 MBytes 32.4 Mbits/sec
[ 4] 3.0- 4.0 sec 2.92 MBytes 24.5 Mbits/sec
[ 4] 4.0- 5.0 sec 3.04 MBytes 25.5 Mbits/sec
[ 4] 5.0- 6.0 sec 3.11 MBytes 26.1 Mbits/sec
[ 4] 6.0- 7.0 sec 2.13 MBytes 17.9 Mbits/sec
[ 4] 7.0- 8.0 sec 3.12 MBytes 26.2 Mbits/sec
[ 4] 8.0- 9.0 sec 3.11 MBytes 26.1 Mbits/sec
[ 4] 9.0-10.0 sec 2.77 MBytes 23.2 Mbits/sec
[ 4] 10.0-11.0 sec 2.02 MBytes 17.0 Mbits/sec
[ 4] 11.0-12.0 sec 2.31 MBytes 19.4 Mbits/sec
[ 4] 0.0-12.3 sec 57.5 MBytes 39.3 Mbits/sec
- 客户端执行结果如下
[root@hrt-hd ~]# yum install iperf
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 4.3 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
zabbix | 2.9 kB 00:00:00
zabbix-agent2-plugins | 2.9 kB 00:00:00
zabbix-non-supported | 2.9 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package iperf.x86_64 0:2.0.13-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================================
Installing:
iperf x86_64 2.0.13-1.el7 epel 86 k
Transaction Summary
=============================================================================================================================================================================
Install 1 Package
Total download size: 86 k
Installed size: 185 k
Is this ok [y/d/N]: y
Downloading packages:
iperf-2.0.13-1.el7.x86_64.rpm | 86 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : iperf-2.0.13-1.el7.x86_64 1/1
Verifying : iperf-2.0.13-1.el7.x86_64 1/1
Installed:
iperf.x86_64 0:2.0.13-1.el7
Complete!
[root@hrt-hd ~]# iperf -c 192.168.0.123 -i 1 -t 30 -f m
------------------------------------------------------------
Client connecting to 192.168.0.123, TCP port 5001
TCP window size: 0.69 MByte (default)
------------------------------------------------------------
[ 3] local 192.168.0.72 port 46614 connected with 192.168.0.123 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 680 MBytes 5707 Mbits/sec
[ 3] 1.0- 2.0 sec 375 MBytes 3149 Mbits/sec
[ 3] 2.0- 3.0 sec 375 MBytes 3143 Mbits/sec
[ 3] 3.0- 4.0 sec 373 MBytes 3131 Mbits/sec
[ 3] 0.0- 4.4 sec 1943 MBytes 3727 Mbits/sec
[root@hrt-hd ~]# iperf -c 192.168.0.123 -i 1 -t 30 -f m
------------------------------------------------------------
Client connecting to 192.168.0.123, TCP port 5001
TCP window size: 0.21 MByte (default)
------------------------------------------------------------
[ 3] local 192.168.0.72 port 48250 connected with 192.168.0.123 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 678 MBytes 5684 Mbits/sec
[ 3] 1.0- 2.0 sec 375 MBytes 3146 Mbits/sec
[ 3] 2.0- 3.0 sec 374 MBytes 3142 Mbits/sec
[ 3] 3.0- 4.0 sec 375 MBytes 3145 Mbits/sec
[ 3] 4.0- 5.0 sec 375 MBytes 3147 Mbits/sec
[ 3] 5.0- 6.0 sec 374 MBytes 3133 Mbits/sec
[ 3] 6.0- 7.0 sec 373 MBytes 3126 Mbits/sec
[ 3] 7.0- 8.0 sec 373 MBytes 3126 Mbits/sec
[ 3] 8.0- 9.0 sec 374 MBytes 3139 Mbits/sec
[ 3] 9.0-10.0 sec 375 MBytes 3143 Mbits/sec
[ 3] 10.0-11.0 sec 373 MBytes 3129 Mbits/sec
[ 3] 0.0-11.5 sec 4607 MBytes 3358 Mbits/sec
[root@hrt-hd ~]# iperf -h
Usage: iperf [-s|-c host] [options]
iperf [-h|--help] [-v|--version]
Client/Server:
-b, --bandwidth #[kmgKMG | pps] bandwidth to send at in bits/sec or packets per second
-e, --enhancedreports use enhanced reporting giving more tcp/udp and traffic information
-f, --format [kmgKMG] format to report: Kbits, Mbits, KBytes, MBytes
-i, --interval # seconds between periodic bandwidth reports
-l, --len #[kmKM] length of buffer in bytes to read or write (Defaults: TCP=128K, v4 UDP=1470, v6 UDP=1450)
-m, --print_mss print TCP maximum segment size (MTU - TCP/IP header)
-o, --output <filename> output the report or error message to this specified file
-p, --port # server port to listen on/connect to
-u, --udp use UDP rather than TCP
--udp-counters-64bit use 64 bit sequence numbers with UDP
-w, --window #[KM] TCP window size (socket buffer size)
-z, --realtime request realtime scheduler
-B, --bind <host>[:<port>][%<dev>] bind to <host>, ip addr (including multicast address) and optional port and device
-C, --compatibility for use with older versions does not sent extra msgs
-M, --mss # set TCP maximum segment size (MTU - 40 bytes)
-N, --nodelay set TCP no delay, disabling Nagle's Algorithm
-S, --tos # set the socket's IP_TOS (byte) field
Server specific:
-s, --server run in server mode
-t, --time # time in seconds to listen for new connections as well as to receive traffic (default not set)
--udp-histogram #,# enable UDP latency histogram(s) with bin width and count, e.g. 1,1000=1(ms),1000(bins)
-B, --bind <ip>[%<dev>] bind to multicast address and optional device
-H, --ssm-host <ip> set the SSM source, use with -B for (S,G)
-U, --single_udp run in single threaded UDP mode
-D, --daemon run the server as a daemon
-V, --ipv6_domain Enable IPv6 reception by setting the domain and socket to AF_INET6 (Can receive on both IPv4 and IPv6)
Client specific:
-c, --client <host> run in client mode, connecting to <host>
-d, --dualtest Do a bidirectional test simultaneously
--ipg set the the interpacket gap (milliseconds) for packets within an isochronous frame
--isochronous <frames-per-second>:<mean>,<stddev> send traffic in bursts (frames - emulate video traffic)
-n, --num #[kmgKMG] number of bytes to transmit (instead of -t)
-r, --tradeoff Do a bidirectional test individually
-t, --time # time in seconds to transmit for (default 10 secs)
-B, --bind [<ip> | <ip:port>] bind ip (and optional port) from which to source traffic
-F, --fileinput <name> input the data to be transmitted from a file
-I, --stdin input the data to be transmitted from stdin
-L, --listenport # port to receive bidirectional tests back on
-P, --parallel # number of parallel client threads to run
-R, --reverse reverse the test (client receives, server sends)
-T, --ttl # time-to-live, for multicast (default 1)
-V, --ipv6_domain Set the domain to IPv6 (send packets over IPv6)
-X, --peer-detect perform server version detection and version exchange
-Z, --linux-congestion <algo> set TCP congestion control algorithm (Linux only)
Miscellaneous:
-x, --reportexclude [CDMSV] exclude C(connection) D(data) M(multicast) S(settings) V(server) reports
-y, --reportstyle C report as a Comma-Separated Values
-h, --help print this message and quit
-v, --version print version information and quit
[kmgKMG] Indicates options that support a k,m,g,K,M or G suffix
Lowercase format characters are 10^3 based and uppercase are 2^n based
(e.g. 1k = 1000, 1K = 1024, 1m = 1,000,000 and 1M = 1,048,576)
The TCP window size option can be set by the environment variable
TCP_WINDOW_SIZE. Most other options can be set by an environment variable
IPERF_<long option name>, such as IPERF_BANDWIDTH.
Source at <http://sourceforge.net/projects/iperf2/>
Report bugs to <iperf-users@lists.sourceforge.net>
[root@hrt-hd ~]# iperf -c 1.1.1.1 -p40000 -i 1 -t 30 -f m
------------------------------------------------------------
Client connecting to 1.1.1.1, TCP port 40000
TCP window size: 0.12 MByte (default)
------------------------------------------------------------
[ 3] local 192.168.0.72 port 58468 connected with 1.1.1.1 port 40000
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 30.9 MBytes 259 Mbits/sec
[ 3] 1.0- 2.0 sec 0.00 MBytes 0.00 Mbits/sec
[ 3] 2.0- 3.0 sec 4.35 MBytes 36.5 Mbits/sec
[ 3] 3.0- 4.0 sec 2.75 MBytes 23.1 Mbits/sec
[ 3] 4.0- 5.0 sec 2.66 MBytes 22.3 Mbits/sec
[ 3] 5.0- 6.0 sec 3.67 MBytes 30.8 Mbits/sec
[ 3] 6.0- 7.0 sec 2.18 MBytes 18.3 Mbits/sec
[ 3] 7.0- 8.0 sec 2.75 MBytes 23.1 Mbits/sec
[ 3] 8.0- 9.0 sec 2.75 MBytes 23.1 Mbits/sec
[ 3] 9.0-10.0 sec 2.75 MBytes 23.1 Mbits/sec
[ 3] 10.0-11.0 sec 2.49 MBytes 20.9 Mbits/sec
[ 3] 0.0-11.5 sec 57.5 MBytes 41.9 Mbits/sec
结论
内网峰值5000Mb/s,平均3100Mb/s
公网峰值259Mb/s,会降低至最高30Mb/s
推荐走内网,速度快,目前给HRT-HD加了带宽到30,先观察
欢迎关注我的公众号 辣个男人Devin ,新鲜技术文章第一时间推送。