![iperf3 테스트 대역폭: UDP보다 TCP가 훨씬 느림](https://rvso.com/image/782599/iperf3%20%ED%85%8C%EC%8A%A4%ED%8A%B8%20%EB%8C%80%EC%97%AD%ED%8F%AD%3A%20UDP%EB%B3%B4%EB%8B%A4%20TCP%EA%B0%80%20%ED%9B%A8%EC%94%AC%20%EB%8A%90%EB%A6%BC.png)
파일 서버 중 하나가 nginx를 통해 약 7Mbits/초라는 매우 느린 속도로 파일을 보내는 이유를 알아내려고 합니다.
저는 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 실제 대역폭은 최고 약 500Mbits/초이며, 두 서버의 네트워크 인터페이스를 고려하면 완벽한 수준입니다.
TCP 전송에서 더 많은 대역폭을 사용하려면 어떻게 해야 합니까? 내 로컬 컴퓨터에서 시도했는데 TCP 전송에서 약 30Mbits/초를 얻었습니다.
답변1
서버 구성에서 솔루션을 찾았습니다. 표준 Apache 구성에 권장되는 대로 TCP 창이 비활성화되었습니다(여기에 설명되어 있습니다)
$ vi /etc/sysctl.conf
# Set this value and save
net.ipv4.tcp_window_scaling = 1
# check with
$ sysctl -p