パフォーマンスチューニングのネットワーク編-iperf
12371 ワード
iperfは、TCP、UDPをテストするネットワーク性能テストツールであり、ネットワーク帯域幅の検出、MSSサイズの自由設定、tcp nodelay、tcp windowsサイズ、最新のiperf 3.0バージョン、さらにはtcp slow startを禁止する機能も含まれています.
一般的なシステムのデフォルトのインストールはすべてiperfの古いバージョンで、最近のバージョンは公式サイトでダウンロードしてください:https://iperf.fr/iperf-download.phpあ、ubuntuのシステムなのでdebのパッケージをダウンロードしてインストールします.
iperf 3のヘルプ情報を表示するには、次のようにします.
iperfはserver/clientに基づいてネットワークのスループットを検出するため、あるポートを監視し、clientでテストする必要があります.iperfのチームは親切で、世界のいくつかの点のserverを無料で提供しています.https://iperf.fr/iperf-servers.php
私は日本のec 2なので、アジアのあの机械でテストをして、サーバーのアドレスは:iperf.it-north.net、Speedは1 Gbit/sで、ポートはTCP/UDP 5200-5209で、ipv 4だけを支持して、もちろんあなたが自分のサーバーでserverをしたいならば、公式サイトも1つのシナリオを提供してあなたに使用します:
クライアントのテストケースを見てみましょう.
サーバの合計帯域幅をテストします.
-p#サーバのポートを指定します.
-f#formatフォーマット、kKmMgG、Aはadaptiveで、ls-hに似ていて、友好的に表示されます.
-N#nodelay、Nagle's algorithmを無効にします.
-O#tcp slow startを無効にし、-O 3は前の3回のリクエストを無視することを示します.
-V#詳細を表示します.
-P#サーバへの接続数を設定します.デフォルトは1つです.
次の例では、デフォルトのMSSは1448 byteであり、前の秒が遅い起動混雑ウィンドウに属しているのは570 KBytesであり、その後2.48 MBytes、Summary Results:サーバとクライアントの帯域幅サイズ、消費cpuの割合が表示されます.
TCP Slow StartとCongestion Avoidanceに興味のあるものはwatchに合わせて、ssは起動過程を観察することができます.
-w#パラメータは、送信されるtcp転送ウィンドウのサイズを指定します.
1台のサーバの総帯域幅を知っている場合は、-Pの同時数、-w、-i internalなどのパラメータを加えて、あなたのサイトのネットワーク性能の圧力点がどこにあるかを基本的に測定することができます.
M#はMSSの値を変更できます
Attempt to set the TCP maximum segment size (MSS). The MSS is usually the MTU - 40 bytes for the TCP/IP header. For ethernet, the MSS is 1460 bytes (1500 byte MTU).
公式解釈ではMSSの値を設定しようとしていますが、なぜ私が私のシステムでテストしたときのデフォルト値は21888だったのか分かりませんが、30000に変更しようとしたときに実行できませんでした.これが試みの意味ですか?分かりやすくメッセージを残して説明してください.
サーバーの各指標を観察した後、tcp_に協力することができる.rmem, tcp_wmem, tcp_memパラメータを使用して、最適化されたサーバネットワークのパフォーマンスを調整します.後でtcpネットワークのパフォーマンスを調整する詳細を書きます.
Enjoy Yourself!
一般的なシステムのデフォルトのインストールはすべてiperfの古いバージョンで、最近のバージョンは公式サイトでダウンロードしてください:https://iperf.fr/iperf-download.phpあ、ubuntuのシステムなのでdebのパッケージをダウンロードしてインストールします.
iperf 3のヘルプ情報を表示するには、次のようにします.
# iperf3 -h
Usage: iperf [-s|-c host] [options]
iperf [-h|--help] [-v|--version]
Server or Client:
-p, --port # server port to listen on/connect to
-f, --format [kmgKMG] format to report: Kbits, Mbits, KBytes, MBytes
-i, --interval # seconds between periodic bandwidth reports
-F, --file name xmit/recv the specified file
-A, --affinity n/n,m set CPU affinity
-B, --bind bind to a specific interface
-V, --verbose more detailed output
-J, --json output in JSON format
--logfile f send output to a log file
-d, --debug emit debugging output
-v, --version show version information and quit
-h, --help show this message and quit
Server specific:
-s, --server run in server mode
-D, --daemon run the server as a daemon
-I, --pidfile file write PID file
-1, --one-off handle one client connection then exit
Client specific:
-c, --client run in client mode, connecting to
-u, --udp use UDP rather than TCP
-b, --bandwidth #[KMG][/#] target bandwidth in bits/sec (0 for unlimited)
(default 1 Mbit/sec for UDP, unlimited for TCP)
(optional slash and packet count for burst mode)
-t, --time # time in seconds to transmit for (default 10 secs)
-n, --bytes #[KMG] number of bytes to transmit (instead of -t)
-k, --blockcount #[KMG] number of blocks (packets) to transmit (instead of -t or -n)
-l, --len #[KMG] length of buffer to read or write
(default 128 KB for TCP, 8 KB for UDP)
--cport bind to a specific client port (TCP and UDP, default: ephemeral port)
-P, --parallel # number of parallel client streams to run
-R, --reverse run in reverse mode (server sends, client receives)
-w, --window #[KMG] set window size / socket buffer size
-C, --congestion set TCP congestion control algorithm (Linux and FreeBSD only)
-M, --set-mss # set TCP/SCTP maximum segment size (MTU - 40 bytes)
-N, --no-delay set TCP/SCTP no delay, disabling Nagle's Algorithm
-4, --version4 only use IPv4
-6, --version6 only use IPv6
-S, --tos N set the IP 'type of service'
-L, --flowlabel N set the IPv6 flow label (only supported on Linux)
-Z, --zerocopy use a 'zero copy' method of sending data
-O, --omit N omit the first n seconds
-T, --title str prefix every output line with this string
--get-server-output get results from server
--udp-counters-64bit use 64-bit counters in UDP test packets
[KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga-
iperf3 homepage at: http://software.es.net/iperf/
Report bugs to: https://github.com/esnet/iperf
iperfはserver/clientに基づいてネットワークのスループットを検出するため、あるポートを監視し、clientでテストする必要があります.iperfのチームは親切で、世界のいくつかの点のserverを無料で提供しています.https://iperf.fr/iperf-servers.php
私は日本のec 2なので、アジアのあの机械でテストをして、サーバーのアドレスは:iperf.it-north.net、Speedは1 Gbit/sで、ポートはTCP/UDP 5200-5209で、ipv 4だけを支持して、もちろんあなたが自分のサーバーでserverをしたいならば、公式サイトも1つのシナリオを提供してあなたに使用します:
#!/bin/bash
/bin/sleep 10
/usr/bin/killall iperf3
/bin/sleep 0.1
/usr/bin/killall -9 iperf3
/bin/sleep 0.1
if [ `ps -C iperf3 | wc -l` = "1" ]
then
/usr/bin/sudo -u nobody /usr/bin/iperf3 -s -p 5200 -D >/dev/null 2>&1
/usr/bin/sudo -u nobody /usr/bin/iperf3 -s -p 5201 -D >/dev/null 2>&1
/usr/bin/sudo -u nobody /usr/bin/iperf3 -s -p 5202 -D >/dev/null 2>&1
/usr/bin/sudo -u nobody /usr/bin/iperf3 -s -p 5203 -D >/dev/null 2>&1
/usr/bin/sudo -u nobody /usr/bin/iperf3 -s -p 5204 -D >/dev/null 2>&1
/usr/bin/sudo -u nobody /usr/bin/iperf3 -s -p 5205 -D >/dev/null 2>&1
/usr/bin/sudo -u nobody /usr/bin/iperf3 -s -p 5206 -D >/dev/null 2>&1
/usr/bin/sudo -u nobody /usr/bin/iperf3 -s -p 5207 -D >/dev/null 2>&1
/usr/bin/sudo -u nobody /usr/bin/iperf3 -s -p 5208 -D >/dev/null 2>&1
/usr/bin/sudo -u nobody /usr/bin/iperf3 -s -p 5209 -D >/dev/null 2>&1
fi
クライアントのテストケースを見てみましょう.
サーバの合計帯域幅をテストします.
-p#サーバのポートを指定します.
-f#formatフォーマット、kKmMgG、Aはadaptiveで、ls-hに似ていて、友好的に表示されます.
-N#nodelay、Nagle's algorithmを無効にします.
-O#tcp slow startを無効にし、-O 3は前の3回のリクエストを無視することを示します.
-V#詳細を表示します.
-P#サーバへの接続数を設定します.デフォルトは1つです.
次の例では、デフォルトのMSSは1448 byteであり、前の秒が遅い起動混雑ウィンドウに属しているのは570 KBytesであり、その後2.48 MBytes、Summary Results:サーバとクライアントの帯域幅サイズ、消費cpuの割合が表示されます.
# iperf3 -c iperf.it-north.net -p 5205 -f A -N -O 3 -V
iperf 3.1.2
Linux shanker 3.13.0-83-generic #127-Ubuntu SMP Fri Mar 11 00:25:37 UTC 2016 x86_64
Time: Fri, 15 Apr 2016 07:34:58 GMT
Connecting to host iperf.it-north.net, port 5205
Cookie: shanker.1460705698.652529.7f4273b01f
TCP MSS: 1448 (default)
[ 4] local 172.31.23.95 port 56056 connected to 82.200.209.194 port 5205
Starting Test: protocol: TCP, 1 streams, 131072 byte blocks, omitting 3 seconds, 10 second test
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 2.95 MBytes 2.95 MBytes/sec 0 570 KBytes (omitted)
[ 4] 1.00-2.00 sec 12.4 MBytes 12.4 MBytes/sec 0 2.48 MBytes (omitted)
[ 4] 2.00-3.00 sec 17.5 MBytes 17.4 MBytes/sec 0 2.48 MBytes (omitted)
[ 4] 0.00-1.00 sec 18.8 MBytes 18.7 MBytes/sec 0 2.48 MBytes
[ 4] 1.00-2.00 sec 16.2 MBytes 16.2 MBytes/sec 0 2.48 MBytes
[ 4] 2.00-3.00 sec 18.8 MBytes 18.8 MBytes/sec 0 2.48 MBytes
[ 4] 3.00-4.00 sec 17.5 MBytes 17.5 MBytes/sec 0 2.48 MBytes
[ 4] 4.00-5.00 sec 17.5 MBytes 17.5 MBytes/sec 0 2.48 MBytes
[ 4] 5.00-6.00 sec 18.8 MBytes 18.8 MBytes/sec 0 2.48 MBytes
[ 4] 6.00-7.00 sec 17.5 MBytes 17.5 MBytes/sec 0 2.48 MBytes
[ 4] 7.00-8.00 sec 17.5 MBytes 17.5 MBytes/sec 0 2.48 MBytes
[ 4] 8.00-9.00 sec 17.5 MBytes 17.5 MBytes/sec 0 2.48 MBytes
[ 4] 9.00-10.00 sec 18.8 MBytes 18.8 MBytes/sec 0 2.48 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
Test Complete. Summary Results:
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 179 MBytes 17.9 MBytes/sec 0 sender
[ 4] 0.00-10.00 sec 181 MBytes 18.1 MBytes/sec receiver
CPU Utilization: local/sender 2.7% (0.3%u/2.4%s), remote/receiver 4.0% (0.3%u/3.8%s)
iperf Done.
TCP Slow StartとCongestion Avoidanceに興味のあるものはwatchに合わせて、ssは起動過程を観察することができます.
Every 1.0s: ss -ani dst localhost Fri Apr 15 07:44:46 2016
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp ESTAB 0 130966 127.0.0.1:60332 127.0.0.1:5205
cubic wscale:7,7 rto:204 rtt:4/2 mss:65483 cwnd:76 ssthresh:40 send 9953.4Mbps unacked:2 rcv_space:43690
tcp ESTAB 0 0 127.0.0.1:60331 127.0.0.1:5205
cubic wscale:7,7 rto:208 rtt:8/10 ato:40 mss:21888 cwnd:10 ssthresh:40 send 218.9Mbps rcv_space:43690
tcp ESTAB 0 0 ::ffff:127.0.0.1:5205 ::ffff:127.0.0.1:60331
cubic wscale:7,7 rto:208 rtt:8/10 ato:40 mss:21888 cwnd:10 send 218.9Mbps rcv_space:43690
tcp ESTAB 0 0 ::ffff:127.0.0.1:5205 ::ffff:127.0.0.1:60332
cubic wscale:7,7 rto:216 rtt:4/2 ato:40 mss:21888 cwnd:10 send 437.8Mbps rcv_rtt:4 rcv_space:16253034
tcp TIME-WAIT 0 0 ::ffff:127.0.0.1:5205 ::ffff:127.0.0.1:60329
-w#パラメータは、送信されるtcp転送ウィンドウのサイズを指定します.
1台のサーバの総帯域幅を知っている場合は、-Pの同時数、-w、-i internalなどのパラメータを加えて、あなたのサイトのネットワーク性能の圧力点がどこにあるかを基本的に測定することができます.
# iperf3 -c localhost -p 5205 -f A -N -O3 -w 5K
Connecting to host localhost, port 5205
[ 4] local 127.0.0.1 port 60479 connected to 127.0.0.1 port 5205
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 231 MBytes 231 MBytes/sec 0 25.0 KBytes (omitted)
[ 4] 1.00-2.00 sec 233 MBytes 233 MBytes/sec 0 25.0 KBytes (omitted)
[ 4] 2.00-3.00 sec 232 MBytes 232 MBytes/sec 0 25.0 KBytes (omitted)
[ 4] 0.00-1.00 sec 231 MBytes 231 MBytes/sec 0 25.0 KBytes
[ 4] 1.00-2.00 sec 233 MBytes 233 MBytes/sec 0 25.0 KBytes
[ 4] 2.00-3.00 sec 231 MBytes 231 MBytes/sec 0 25.0 KBytes
[ 4] 3.00-4.00 sec 232 MBytes 232 MBytes/sec 0 25.0 KBytes
[ 4] 4.00-5.00 sec 235 MBytes 235 MBytes/sec 0 25.0 KBytes
[ 4] 5.00-6.00 sec 234 MBytes 234 MBytes/sec 0 25.0 KBytes
[ 4] 6.00-7.00 sec 234 MBytes 234 MBytes/sec 0 25.0 KBytes
[ 4] 7.00-8.00 sec 237 MBytes 237 MBytes/sec 0 25.0 KBytes
[ 4] 8.00-9.00 sec 237 MBytes 237 MBytes/sec 0 25.0 KBytes
[ 4] 9.00-10.00 sec 235 MBytes 235 MBytes/sec 0 25.0 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 2.28 GBytes 234 MBytes/sec 0 sender
[ 4] 0.00-10.00 sec 2.29 GBytes 235 MBytes/sec receiver
iperf Done.
M#はMSSの値を変更できます
Attempt to set the TCP maximum segment size (MSS). The MSS is usually the MTU - 40 bytes for the TCP/IP header. For ethernet, the MSS is 1460 bytes (1500 byte MTU).
公式解釈ではMSSの値を設定しようとしていますが、なぜ私が私のシステムでテストしたときのデフォルト値は21888だったのか分かりませんが、30000に変更しようとしたときに実行できませんでした.これが試みの意味ですか?分かりやすくメッセージを残して説明してください.
# iperf3 -c localhost -p 5205 -f A -V
iperf 3.1.2
Linux shanker 3.13.0-83-generic #127-Ubuntu SMP Fri Mar 11 00:25:37 UTC 2016 x86_64
Time: Fri, 15 Apr 2016 08:29:21 GMT
Connecting to host localhost, port 5205
Cookie: shanker.1460708961.252601.6c573c0715
TCP MSS: 21888 (default)
[ 4] local 127.0.0.1 port 60516 connected to 127.0.0.1 port 5205
Starting Test: protocol: TCP, 1 streams, 131072 byte blocks, omitting 0 seconds, 10 second test
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 2.80 GBytes 2.79 GBytes/sec 0 3.31 MBytes
[ 4] 1.00-2.00 sec 2.79 GBytes 2.79 GBytes/sec 0 3.31 MBytes
[ 4] 2.00-3.00 sec 2.83 GBytes 2.83 GBytes/sec 0 3.31 MBytes
[ 4] 3.00-4.00 sec 2.83 GBytes 2.83 GBytes/sec 0 3.31 MBytes
[ 4] 4.00-5.00 sec 2.85 GBytes 2.85 GBytes/sec 0 3.31 MBytes
[ 4] 5.00-6.00 sec 2.80 GBytes 2.80 GBytes/sec 0 3.31 MBytes
[ 4] 6.00-7.00 sec 2.85 GBytes 2.85 GBytes/sec 0 3.31 MBytes
[ 4] 7.00-8.00 sec 2.86 GBytes 2.86 GBytes/sec 0 3.31 MBytes
[ 4] 8.00-9.00 sec 2.87 GBytes 2.87 GBytes/sec 0 3.31 MBytes
[ 4] 9.00-10.00 sec 2.84 GBytes 2.84 GBytes/sec 0 3.31 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
Test Complete. Summary Results:
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 28.3 GBytes 2.83 GBytes/sec 0 sender
[ 4] 0.00-10.00 sec 28.3 GBytes 2.83 GBytes/sec receiver
CPU Utilization: local/sender 49.6% (1.0%u/48.5%s), remote/receiver 5.0% (0.4%u/4.6%s)
iperf Done.
サーバーの各指標を観察した後、tcp_に協力することができる.rmem, tcp_wmem, tcp_memパラメータを使用して、最適化されたサーバネットワークのパフォーマンスを調整します.後でtcpネットワークのパフォーマンスを調整する詳細を書きます.
Enjoy Yourself!