我試圖找出為什麼我的一台用於文件服務的伺服器透過 nginx 以非常慢的速度(大約 7 Mbits/sec)發送文件。
我一直在使用 iperf3 來測試伺服器之間的傳輸速率,兩者都在 Debian 11 上。
- 法語服務:
$ iperf3 -s
- CanadianServ :
$ iperf3 -c 195.154.xxx.xxx -P 1 -t 10 -b 1G
// 嘗試使用 1 個連接在 10 秒內發送 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/sec,考慮到兩個伺服器的網路接口,這完全沒問題。
如何讓 TCP 傳輸使用更多頻寬?我在本機上嘗試過,TCP 傳輸速度約為 30 Mbits/sec。