如何使用10Gb光纤连接微调Linux上的TCP性能

我们有2台专门为客户测速的红帽服务器。 他们都使用10Gb光纤连接,并坐在10Gb链路上。 这些服务器之间的所有networking设备完全支持10Gb / s。 使用Iperf或Iperf3,我可以得到的最好是在6.67Gb / s左右。 这就是说,一台服务器正在生产(客户正在打它),另一台服务器在线,但没有被使用。 (我们正在使用它来testingatm)6.67Gb / s也是一种方法,我应该提到。 我们将调用这些服务器A和服务器B.

当服务器A充当iperf服务器时,我们获得了6.67Gb / s的速度。 当服务器A作为服务器B的客户端时,它只能推送约20Mb / s。

我做了什么:

到目前为止,我所做的唯一的事情是将两台服务器上的TX / RX缓冲区增加到最大值。 一个被设置为512,另一个453.(仅RX,TX已经被刷新了)所以在更新之后,

Server A: Ring parameters for em1: Pre-set maximums: RX: 4096 RX Mini: 0 RX Jumbo: 0 TX: 4096 Current hardware settings: RX: 4096 RX Mini: 0 RX Jumbo: 0 TX: 4096 Server B: Ring parameters for p1p1: Pre-set maximums: RX: 4078 RX Mini: 0 RX Jumbo: 0 TX: 4078 Current hardware settings: RX: 4078 RX Mini: 0 RX Jumbo: 0 TX: 4078 

NICS看起来像这样:

 Server A: ixgbe 0000:01:00.0: em1: NIC Link is Up 10 Gbps, Flow Control: RX/TX Serer B: bnx2x 0000:05:00.0: p1p1: NIC Link is Up, 10000 Mbps full duplex, Flow control: ON - receive & transmit Server A ethtool stats: rx_errors: 0 tx_errors: 0 rx_over_errors: 0 rx_crc_errors: 0 rx_frame_errors: 0 rx_fifo_errors: 0 rx_missed_errors: 0 tx_aborted_errors: 0 tx_carrier_errors: 0 tx_fifo_errors: 0 tx_heartbeat_errors: 0 rx_long_length_errors: 0 rx_short_length_errors: 0 rx_csum_offload_errors: 123049 Server B ethtool stats: [0]: rx_phy_ip_err_discards: 0 [0]: rx_csum_offload_errors: 0 [1]: rx_phy_ip_err_discards: 0 [1]: rx_csum_offload_errors: 0 [2]: rx_phy_ip_err_discards: 0 [2]: rx_csum_offload_errors: 0 [3]: rx_phy_ip_err_discards: 0 [3]: rx_csum_offload_errors: 0 [4]: rx_phy_ip_err_discards: 0 [4]: rx_csum_offload_errors: 0 [5]: rx_phy_ip_err_discards: 0 [5]: rx_csum_offload_errors: 0 [6]: rx_phy_ip_err_discards: 0 [6]: rx_csum_offload_errors: 0 [7]: rx_phy_ip_err_discards: 0 [7]: rx_csum_offload_errors: 0 rx_error_bytes: 0 rx_crc_errors: 0 rx_align_errors: 0 rx_phy_ip_err_discards: 0 rx_csum_offload_errors: 0 tx_error_bytes: 0 tx_mac_errors: 0 tx_carrier_errors: 0 tx_deferred: 0 recoverable_errors: 0 unrecoverable_errors: 0 

可能的问题:服务器A有大量的rx_csum_offload_errors。 服务器A是生产的服务器,我不禁想到CPU中断可能是一个潜在的因素,这是什么导致我看到的错误。

服务器A的cat / proc / interrupts:

 122: 54938283 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI-edge em1- TxRx-0 123: 51653771 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI-edge em1-TxRx-1 124: 52277181 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI-edge em1-TxRx-2 125: 51823314 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI-edge em1-TxRx-3 126: 57975011 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI-edge em1-TxRx-4 127: 52333500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI-edge em1-TxRx-5 128: 51899210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI-edge em1-TxRx-6 129: 61106425 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI-edge em1-TxRx-7 130: 51774758 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI-edge em1-TxRx-8 131: 52476407 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI-edge em1-TxRx-9 132: 53331215 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 IR-PCI-MSI-edge em1-TxRx-10 133: 52135886 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

如果这是问题可能会禁用rx-checksum的帮助? 另外我看到没有生产的服务器上的CPU中断,这是合理的,因为它的网卡不需要CPU时间。

 Server A: ethtool -k em1 Features for em1: rx-checksumming: on tx-checksumming: on tx-checksum-ipv4: on tx-checksum-unneeded: off tx-checksum-ip-generic: off tx-checksum-ipv6: on tx-checksum-fcoe-crc: on [fixed] tx-checksum-sctp: on [fixed] scatter-gather: on tx-scatter-gather: on tx-scatter-gather-fraglist: off [fixed] tcp-segmentation-offload: on tx-tcp-segmentation: on tx-tcp-ecn-segmentation: off tx-tcp6-segmentation: on udp-fragmentation-offload: off [fixed] generic-segmentation-offload: on generic-receive-offload: on large-receive-offload: on rx-vlan-offload: on tx-vlan-offload: on ntuple-filters: off receive-hashing: on highdma: on [fixed] rx-vlan-filter: on [fixed] vlan-challenged: off [fixed] tx-lockless: off [fixed] netns-local: off [fixed] tx-gso-robust: off [fixed] tx-fcoe-segmentation: on [fixed] tx-gre-segmentation: off [fixed] tx-udp_tnl-segmentation: off [fixed] fcoe-mtu: off [fixed] loopback: off [fixed] 

除了使用巨型帧(这是因为我们的networking设备不支持它们而不可能的),我还能做些什么或检查以为我的10Gbnetworking提供最佳的TCP性能? 6.67Gb / s没有那么糟糕,我想考虑到其中一个服务器正在生产,我的假设关于CPU中断NIC正在生成。 但10Gb链路上的另一个方向上的20Mb / s速度根本是不可接受的。 任何帮助将不胜感激。

服务器A规格:x64 24v CPU 32GB RAM RHEL 6.7

服务器B规格:x64 16v CPU 16GB RAM RHEL 6.7

是相同的规格(品牌和型号)的服务器? 你做了任何sysctl.conf的变化?

您应该启用irqbalance,因为您的中断只发生在CPU0上。

如果您没有使用EL6的调整configuration文件,则应根据此处的时间表select一个接近您的工作负载的configuration文件。

在Linux / Intel中,我将使用以下方法进行性能分析:

硬件:

  • turbostat
    查找核心的C / P状态,频率,SMI数量。 [1]
  • cpufreq-info
    查找当前的驱动程序,频率和州长。
  • atop
    寻找跨核心的中断分布
    寻找上下文切换,中断。
  • ethtool
    -S用于统计,查找错误,下降,超出,错过中断等
    -k用于卸载,启用GRO / GSO,rss(/ rps / rfs)/ xps
    -g为戒指尺寸,增加
    -c用于中断合并

核心:

  • /proc/net/softirq [2]和/proc/interrupts [3]
    同样,分发,错过,延迟中断,(可选)NUMA亲和力
  • perf top
    看内核/基准testing的时间。
  • iptables
    看是否有可能影响性能的规则(如果有的话)。
  • netstat -snetstat -m/proc/net/*
    查找错误计数器和缓冲区计数
  • sysctl / grub
    这里调整太多了。 尝试增加哈希表大小,使用内存缓冲区,拥塞控制和其他旋钮。

在你的情况下,你的主要问题是核心中的中断分布,所以修复它将是你最好的行动。

PS。 不要忘记,在这些基准testing中,内核和驱动程序/固件版本起着重要的作用。

PPS。 您可能想要安装来自Intel的最新ixgbe驱动程序[4]。 不要忘记在那里阅读自述,并检查脚本目录。 它有很多与性能有关的技巧。

英特尔也有关于扩展networking性能的很好的文档
https://www.kernel.org/doc/Documentation/networking/scaling.txt
[1]您可以将处理器固定到特定的C状态:
https://gist.github.com/SaveTheRbtz/f5e8d1ca7b55b6a7897b
[2]您可以使用以下方式分析数据:
https://gist.github.com/SaveTheRbtz/172b2e2eb3cbd96b598d
[3]你可以设置亲和力:
https://gist.github.com/SaveTheRbtz/8875474
[4] https://sourceforge.net/projects/e1000/files/ixgbe%20stable/

如果仅运行iperf的一个实例,则速度为6 Gb / s即可,因为它仅限于单个CPU内核。 两个进程同时应该给你预期的10Gb / s。

20Mb / s在一个方向上的问题看起来像驱动程序/固件/硬件不兼容问题。

我build议您尝试以下疑难解答步骤:

您的网卡具有双端口,因此首先尝试在两个网卡上进行环回速度testing。 它可以帮助您将问题本地化:在服务器A或服务器B上。2.更改跳线。 3.尝试新的驱动程序。 4.升级固件。 5.更换网卡)