为什么我的千兆位链路无法提供至少 150 MB/s 的吞吐量?

为什么我的千兆位链路无法提供至少 150 MB/s 的吞吐量?

我直接将两个 PowerEdge 6950 交叉适配器(使用直线)连接到两个不同的 PCIe 适配器上。

我在每条线路上都获得了千兆位链路(1000 MBit,全双工,双向流量控制)。

现在我尝试在两侧使用 rr 算法将这些接口绑定到 bond0(我希望单个 IP 会话获得 2000 MBit)。

当我使用 dd bs=1M 和 tcp 模式下的 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 模式选择)

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.

现在,我将所有线路(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

更新最终结果:

已复制 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

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

MTU='9216'
LINK_OPTIONS='txqueuelen 10000'

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

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

/usr/sbin/ethtool -G eth2 rx 2048 tx 2048
/usr/sbin/ethtool -G eth4 rx 2048 tx 2048

答案1

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

ifconfig bond0 mtu 9000
ifconfig bond0 txqueuelen 10000
echo 3000 > /proc/sys/net/core/netdev_max_backlog

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

答案2

您是否已在交换机上配置此双向中继?如果没有,那么它将无法正常工作,它只会在主动/被动模式下工作,并且仅使用 1Gbps 链路中的 1 个。

答案3

看起来 PowerEdge 6950 可能受限于 PCI 插槽,最高速度为 133 MB/s,在整个总线上共享。您可能会看到系统总线架构本身的 I/O 限制。

除了测试具有不同硬件和 I/O 架构的其他系统外,布线也可能发挥作用。一些可能的组合可能与不同的等级(5e 与 6)以及长度有关(越短并不总是越好)。

答案4

只要您的交换机和网卡支持巨型帧,那么它就会有很大帮助。如果您有一个非托管交换机,很可能您无法获得您想要的带宽,但如果您将交换机上的端口绑定在一起,情况就不是这样了。这是我很久以前学到的,65% 的时间,这是一个物理问题。您使用的是 cat6 电缆吗?

相关内容