【问题标题】:Huge performance difference with Iperf between - with and without VPN Tunnel与 Iperf 之间的巨大性能差异 - 有和没有 VPN 隧道
【发布时间】:2018-02-22 17:28:31
【问题描述】:

我正在使用 IPerf 在不同的网络设置之间运行一些性能测量。我发现两种基本设置之间存在巨大差异。

  1. 两个容器(docker)通过主机中默认的docker0桥接接口相互连接。
  2. 两个容器通过 VPNTunnel 接口 连接,该接口通过上述 docker0 桥进行内部连接。

IPerf 计算两种方案 10sec

**Scenario One (1)**  

Client connecting to 172.17.0.4, TCP port 5001
TCP window size: 1.12 MByte (default)
------------------------------------------------------------
[  3] local 172.17.0.2 port 50728 connected with 172.17.0.4 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec  3.26 GBytes  28.0 Gbits/sec
[  3]  1.0- 2.0 sec  3.67 GBytes  31.5 Gbits/sec
[  3]  2.0- 3.0 sec  3.70 GBytes  31.8 Gbits/sec
[  3]  3.0- 4.0 sec  3.93 GBytes  33.7 Gbits/sec
[  3]  4.0- 5.0 sec  3.34 GBytes  28.7 Gbits/sec
[  3]  5.0- 6.0 sec  3.44 GBytes  29.6 Gbits/sec
[  3]  6.0- 7.0 sec  3.55 GBytes  30.5 Gbits/sec
[  3]  7.0- 8.0 sec  3.50 GBytes  30.0 Gbits/sec  
[  3]  8.0- 9.0 sec  3.41 GBytes  29.3 Gbits/sec
[  3]  9.0-10.0 sec  3.20 GBytes  27.5 Gbits/sec
[  3]  0.0-10.0 sec  35.0 GBytes  30.1 Gbits/sec


**Scenario Two (2)**

Client connecting to 10.23.0.2, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  3] local 10.12.0.2 port 41886 connected with 10.23.0.2 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec  15.1 MBytes   127 Mbits/sec
[  3]  1.0- 2.0 sec  14.9 MBytes   125 Mbits/sec
[  3]  2.0- 3.0 sec  14.9 MBytes   125 Mbits/sec
[  3]  3.0- 4.0 sec  14.2 MBytes   120 Mbits/sec
[  3]  4.0- 5.0 sec  16.4 MBytes   137 Mbits/sec
[  3]  5.0- 6.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  6.0- 7.0 sec  18.6 MBytes   156 Mbits/sec
[  3]  7.0- 8.0 sec  16.4 MBytes   137 Mbits/sec
[  3]  8.0- 9.0 sec  13.5 MBytes   113 Mbits/sec
[  3]  9.0-10.0 sec  15.0 MBytes   126 Mbits/sec
[  3]  0.0-10.0 sec   157 MBytes   132 Mbits/sec

我对吞吐量的巨大差异感到困惑。

是不是由于涉及的加密和解密以及 OpenSSL 导致了这种退化?

还是因为在通过 VPN 隧道进行路由时,需要对应用层以下的数据包头进行多次解组和编组?

谢谢
沙比尔

【问题讨论】:

    标签: performance docker networking vpn iperf


    【解决方案1】:

    两个测试运行不均 - 第一个测试以 1.12 Mbyte 的 TCP 窗口运行,而第二个较慢的测试以 0.085 MByte 的窗口运行:

    Client connecting to 172.17.0.4, TCP port 5001
    TCP window size: 1.12 MByte (default)
                     ^^^^
    
    Client connecting to 10.23.0.2, TCP port 5001
    TCP window size: 85.0 KByte (default)
                     ^^^^
    

    因此,您可能会遇到 TCP 窗口耗尽的情况,这既是因为缓冲区较小,也是因为通过 vpn 堆栈的延迟略有增加。

    为了知道要使用的缓冲区大小(如果不仅仅是一个巨大的缓冲区),您需要知道您的bandwidth-delay product。

    我不知道您的原始频道 RTT 是什么,但我们可以试一试。您可以通过 1.12 MBytes 的缓冲区大小在您的链路上获得约 30 gbit/sec,然后向后进行数学运算(省略单位转换),我们得到:

    1.12 megabytes / 30 gigabits/sec --> 0.3 ms.

    这似乎是合理的。现在让我们假设您的 vpn 的 RTT 是原始链接的两倍,因此我们假设延迟为 0.6 毫秒。然后,我们将使用新的 0.085 MByte 窗口大小,通过计算带宽延迟积转发来确定您应该期望什么样的性能:

    0.085 Mbytes / 0.6 ms --> BDP = 141 mbit/sec. 
    

    嗯,你知道吗,这就是你所看到的确切性能。

    例如,如果您想用 0.6 毫秒的 RTT 使 100 Gb/秒的管道饱和,那么您需要 7.5 MB 的缓冲区大小。或者,如果您想用 N 个连接而不是单个连接使管道饱和,那么您需要 N 个套接字,每个套接字的发送缓冲区大小为 7.5/N Mbytes。

    【讨论】:

    • 感谢您的回答。但是,我认为上面的 TCP 窗口是随机的,只表示 iperf 开头的窗口。我尝试再次运行它,并且在两种情况下,窗口默认设置为 85 KByte。我尝试手动将 Window 设置为 400KB,但仍然看到巨大的差异。
    • 尝试将窗口/缓冲区大小设置为 10 Mbytes 以确保绝对确定。 400 KB 仍然太小。另外,在场景中检查 cpu 使用情况。 VPN 软件是饱和核心,还是使用所有 cpu?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-21
    • 1970-01-01
    • 1970-01-01
    • 2014-11-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多