我试图找出为什么我的一台用于文件服务的服务器通过 nginx 以非常慢的速度(大约 7 Mbits/秒)发送文件。
我一直在使用 iperf3 来测试服务器之间的传输速率,两者都在 Debian 11 上。
- 法國服務:
$ iperf3 -s
- CanadianServ:
$ iperf3 -c 195.154.xxx.xxx -P 1 -t 10 -b 1G
//尝试在 10 秒内使用 1 个连接发送 1GB 的数据
通过 TCP 进行的测试得出以下结果:
Connecting to host 195.154.xxx.xxx, port 5201
[ 5] local 142.44.xxx.xxx port 60610 connected to 195.154.xxx.xxx port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 1.04 MBytes 8.69 Mbits/sec 0 125 KBytes
[ 5] 1.00-2.00 sec 768 KBytes 6.29 Mbits/sec 0 125 KBytes
[ 5] 2.00-3.00 sec 768 KBytes 6.29 Mbits/sec 0 125 KBytes
[ 5] 3.00-4.00 sec 640 KBytes 5.24 Mbits/sec 0 125 KBytes
[ 5] 4.00-5.00 sec 768 KBytes 6.29 Mbits/sec 0 125 KBytes
[ 5] 5.00-6.00 sec 768 KBytes 6.29 Mbits/sec 0 125 KBytes
[ 5] 6.00-7.00 sec 768 KBytes 6.29 Mbits/sec 0 125 KBytes
[ 5] 7.00-8.00 sec 640 KBytes 5.24 Mbits/sec 0 125 KBytes
[ 5] 8.00-9.00 sec 768 KBytes 6.29 Mbits/sec 0 125 KBytes
[ 5] 9.00-10.00 sec 768 KBytes 6.29 Mbits/sec 0 125 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 7.54 MBytes 6.32 Mbits/sec 0 sender
[ 5] 0.00-10.09 sec 7.08 MBytes 5.89 Mbits/sec receiver
iperf Done.
它非常慢,我可能会堆叠连接以获得更快的带宽,但希望保留 1 个连接。
现在通过 UDP 进行测试。
- 加拿大服务:
$ iperf3 -c 195.154.xxx.xxx -P 1 -t 10 -b 1G -u
输出:
Connecting to host 195.154.xxx.xxx, port 5201
[ 5] local 142.44.xxx.xxx port 37350 connected to 195.154.xxx.xxx port 5201
[ ID] Interval Transfer Bitrate Total Datagrams
[ 5] 0.00-1.00 sec 113 MBytes 950 Mbits/sec 81331
[ 5] 1.00-2.00 sec 114 MBytes 955 Mbits/sec 81773
[ 5] 2.00-3.00 sec 114 MBytes 956 Mbits/sec 81887
[ 5] 3.00-4.00 sec 114 MBytes 957 Mbits/sec 81904
[ 5] 4.00-5.00 sec 114 MBytes 956 Mbits/sec 81862
[ 5] 5.00-6.00 sec 114 MBytes 957 Mbits/sec 81913
[ 5] 6.00-7.00 sec 114 MBytes 957 Mbits/sec 81909
[ 5] 7.00-8.00 sec 114 MBytes 957 Mbits/sec 81915
[ 5] 8.00-9.00 sec 114 MBytes 956 Mbits/sec 81880
[ 5] 9.00-10.00 sec 114 MBytes 957 Mbits/sec 81904
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams
[ 5] 0.00-10.00 sec 1.11 GBytes 956 Mbits/sec 0.000 ms 0/818278 (0%) sender
[ 5] 0.00-10.41 sec 600 MBytes 484 Mbits/sec 0.029 ms 387089/818278 (47%) receiver
iperf Done.
UDP 实际带宽最高约为 500 Mbits/秒,这对于两个服务器的网络接口来说完全没问题。
我怎样才能使 TCP 传输使用更多带宽?我在本地计算机上尝试过,TCP 传输速度约为 30 Mbits/sec。