提高千兆位网络的 TCP 性能

提高千兆位网络的 TCP 性能

我有两台机器,网卡速度都是10Gbps。

  • 两台机器之间的入站带宽为10Gbps,出站带宽互联网带宽是 500Mpbs。
  • 两台机器都在公共和专用网络中使用公共 IP 地址。
  • 两台机器都在 Nginx 的 80 端口上进行传输和连接,机器 B 用于流媒体,例如 Youtube 流媒体视频。

iperf我使用实用程序 From检查了传输速度机器A机器B:

# iperf -c 0.0.0.2 -p 8777
------------------------------------------------------------
Client connecting to 0.0.0.2, TCP port 8777
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  3] local 0.0.0.1 port 38895 connected with 0.0.0.2 port 8777
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.8 sec    528 KBytes    399 Kbits/sec

我在机器 B 中的当前连接:

# netstat -an|grep ":8777"|awk '/tcp/ {print $6}'|sort -nr| uniq -c
   2072 TIME_WAIT
     28 SYN_RECV
      1 LISTEN
    189 LAST_ACK
    139 FIN_WAIT2
    373 FIN_WAIT1
   3381 ESTABLISHED
     34 CLOSING

机器A网卡信息:

Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   100baseT/Full
                                1000baseT/Full
                                10000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10000baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Speed: 10000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: external
        Auto-negotiation: on
        MDI-X: Unknown
        Supports Wake-on: d
        Wake-on: d
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes

机器B网卡信息:

Settings for eth2:
        Supported ports: [ FIBRE ]
        Supported link modes:   10000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: No
        Advertised link modes:  10000baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Speed: 10000Mb/s
        Duplex: Full
        Port: Direct Attach Copper
        PHYAD: 0
        Transceiver: external
        Auto-negotiation: off
        Supports Wake-on: d
        Wake-on: d
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes

ifconfig 机器A:

eth0      Link encap:Ethernet  HWaddr 00:25:90:ED:9E:AA
          inet addr:0.0.0.1  Bcast:0.0.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1202795665 errors:0 dropped:64334 overruns:0 frame:0
          TX packets:2313161968 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:893413096188 (832.0 GiB)  TX bytes:3360949570454 (3.0 TiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:2207544 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2207544 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:247769175 (236.2 MiB)  TX bytes:247769175 (236.2 MiB)

ifconfig 机器B:

eth2      Link encap:Ethernet  HWaddr 00:25:90:82:C4:FE
          inet addr:0.0.0.2  Bcast:0.0.0.2  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:39973046980 errors:0 dropped:1828387600 overruns:0 frame:0
          TX packets:69618752480 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3013976063688 (2.7 TiB)  TX bytes:102250230803933 (92.9 TiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1049495 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1049495 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:129012422 (123.0 MiB)  TX bytes:129012422 (123.0 MiB)

问题

从utility中可以看出iperf,从A机器到B机器的传输速度很慢。当我在机器 B 上重新启动网络服务时,到机器 A 的传输是全速的,2 分钟后,速度变得很慢。

如何解决速度慢的问题并在机器 B 上修复它?

注意:如果我应该在任何一台机器上执行任何其他命令以获取更多信息,因此它可能有助于解决问题,请在评论中告诉我。

相关内容