为什么我的千兆绑定不能提供至少 150 MB/s 的吞吐量?

Nil*_*ils 17 linux bonding sles10

我在两个不同的 PCIe 适配器上直接连接了两个 PowerEdge 6950 分频器(使用直线)。

我在每条线路上都有一个千兆链路(1000 MBit、全双工、双向流量控制)。

现在我正在尝试使用双方的 rr 算法将这些接口绑定到 bond0(我想为单个 IP 会话获得 2000 MBit)。

当我通过在 tcp 模式下使用 dd bs=1M 和 netcat 将 /dev/zero 传输到 /dev/null 来测试吞吐量时,我得到了 70 MB/s 的吞吐量 - 不是 - 正如预期的那样超过 150MB/s。

当我使用单线时,如果我为每条线使用不同的方向,每条线的速度大约为 98 MB/s。当我使用单条线路时,如果流量进入“相同”方向,则线路上的速度分别为 70 MB/s 和 90 MB/s。

通读bonding-readme (/usr/src/linux/Documentation/networking/bonding.txt)后,我发现以下部分很有用:(13.1.1 MT Bonding Mode Selection for Single Switch Topology)

balance-rr:此模式是唯一允许单个 TCP/IP 连接跨多个接口条带化流量的模式。因此,它是唯一一种允许单个 TCP/IP 流利用多个接口的吞吐量的模式。然而,这是有代价的:条带化通常会导致对等系统无序接收数据包,从而导致 TCP/IP 的拥塞控制系统启动,通常是通过重新传输段。

    It is possible to adjust TCP/IP's congestion limits by
    altering the net.ipv4.tcp_reordering sysctl parameter. The
    usual default value is 3, and the maximum useful value is 127.
    For a four interface balance-rr bond, expect that a single
    TCP/IP stream will utilize no more than approximately 2.3
    interface's worth of throughput, even after adjusting
    tcp_reordering.

    Note that this out of order delivery occurs when both the
    sending and receiving systems are utilizing a multiple
    interface bond.  Consider a configuration in which a
    balance-rr bond feeds into a single higher capacity network
    channel (e.g., multiple 100Mb/sec ethernets feeding a single
    gigabit ethernet via an etherchannel capable switch).  In this
    configuration, traffic sent from the multiple 100Mb devices to
    a destination connected to the gigabit device will not see
    packets out of order.  However, traffic sent from the gigabit
    device to the multiple 100Mb devices may or may not see
    traffic out of order, depending upon the balance policy of the
    switch.  Many switches do not support any modes that stripe
    traffic (instead choosing a port based upon IP or MAC level
    addresses); for those devices, traffic flowing from the
    gigabit device to the many 100Mb devices will only utilize one
    interface.
Run Code Online (Sandbox Code Playgroud)

现在,我将所有线路 (4) 上两台连接服务器上的参数从 3 更改为 127。

再次绑定后,我得到了大约 100 MB/s,但仍然不超过。

任何想法为什么?

更新:硬件详细信息来自lspci -v

24:00.0 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (rev 06)
        Subsystem: Intel Corporation PRO/1000 PT Dual Port Server Adapter
        Flags: bus master, fast devsel, latency 0, IRQ 24
        Memory at dfe80000 (32-bit, non-prefetchable) [size=128K]
        Memory at dfea0000 (32-bit, non-prefetchable) [size=128K]
        I/O ports at dcc0 [size=32]
        Capabilities: [c8] Power Management version 2
        Capabilities: [d0] MSI: Mask- 64bit+ Count=1/1 Enable-
        Capabilities: [e0] Express Endpoint, MSI 00
        Kernel driver in use: e1000
        Kernel modules: e1000
Run Code Online (Sandbox Code Playgroud)

更新最终结果:

复制了 8589934592 字节 (8.6 GB),35.8489 秒,240 MB/s

我更改了很多 tcp/ip 和低级驱动程序选项。这包括扩大网络缓冲区。这就是为什么dd现在显示的数字大于 200 MB/s:dd 在仍有输出等待传输时终止(在发送缓冲区中)。

2011-08-05 更新:为实现目标而更改的设置 ( /etc/sysctl.conf ):

# See http://www-didc.lbl.gov/TCP-tuning/linux.html
# raise TCP max buffer size to 16 MB. default: 131071
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
# raise autotuninmg TCP buffer limits
# min, default and max number of bytes to use
# Defaults:
#net.ipv4.tcp_rmem = 4096 87380 174760
#net.ipv4.tcp_wmem = 4096 16384 131072
# Tuning:
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
# Default: Backlog 300
net.core.netdev_max_backlog = 2500
#
# Oracle-DB settings:
fs.file-max = 6815744
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
kernel.shmmax = 2147659776
kernel.sem = 1250 256000 100 1024
net.core.rmem_default = 262144
net.core.wmem_default = 262144
#
# Tuning for network-bonding according to bonding.txt:
net.ipv4.tcp_reordering=127
Run Code Online (Sandbox Code Playgroud)

绑定设备的特殊设置(SLES:/etc/sysconfig/network/ifcfg-bond0):

MTU='9216'
LINK_OPTIONS='txqueuelen 10000'
Run Code Online (Sandbox Code Playgroud)

请注意,设置尽可能大的 MTU 是解决方案的关键。

调整相关网卡的 rx/tx 缓冲区:

/usr/sbin/ethtool -G eth2 rx 2048 tx 2048
/usr/sbin/ethtool -G eth4 rx 2048 tx 2048
Run Code Online (Sandbox Code Playgroud)

小智 9

前段时间我在尝试通过两个千兆链路提高 drbd 同步的速度时遇到了类似的问题。最后我设法获得了大约 150MB/秒的同步速度。这些是我在两个节点上应用的设置:

ifconfig bond0 mtu 9000
ifconfig bond0 txqueuelen 10000
echo 3000 > /proc/sys/net/core/netdev_max_backlog
Run Code Online (Sandbox Code Playgroud)

如果您的网卡还没有,您也可以尝试启用中断合并(使用ethtool --coalesce