# RDMA 网络

Alluxio 支持多种 AI 和 HPC 集群中常见的高速网络技术。本页介绍各支持选项的配置方法和性能参考。

| 技术                                 | 状态    | 适用场景                       |
| ---------------------------------- | ----- | -------------------------- |
| IPoIB（IP over InfiniBand）          | ✅ 已支持 | 在 IB 硬件上运行标准 TCP/IP，无需代码改动 |
| RoCE（RDMA over Converged Ethernet） | 规划中   | 以太网网络上的低延迟 RDMA            |
| 原生 IB API（Verbs）                   | 规划中   | InfiniBand 网络上的超低延迟 RDMA   |

## IPoIB

### 概述

InfiniBand（IB）是 AI 训练集群中常见的高带宽、低延迟互联技术。Alluxio 支持 **IP over InfiniBand（IPoIB）**，即在 IB 硬件上运行标准 TCP/IP 协议栈。由于 Alluxio 通过标准 TCP/IP socket 通信，无需任何代码改动或特殊驱动——只需加载 IPoIB 内核模块并将 Alluxio 服务绑定到 IB 网络接口即可。

> **适用范围**：本节适用于配置为 **InfiniBand 链路层**的网卡（通过 `ibstat | grep "Link layer"` 确认）。如果您的 ConnectX 网卡运行在以太网链路层模式下，它作为标准高速以太网卡工作，Alluxio 可直接使用，无需任何 IPoIB 配置。

#### IPoIB 与原生 RDMA 的对比

|            | IPoIB               | 原生 RDMA（Verbs API） |
| ---------- | ------------------- | ------------------ |
| 协议         | TCP/IP over IB 硬件   | 绕过内核，直接内存访问        |
| Alluxio 支持 | ✅ 完全支持              | 3.8 版本暂不支持         |
| 配置方式       | 绑定到 IB 网络接口         | 需要应用层实现 RDMA 接口    |
| 典型吞吐量      | 100–400 Gbps（取决于硬件） | 延迟更低，峰值带宽相近        |

### 前提条件

#### 硬件

* Mellanox/NVIDIA ConnectX-6 或 ConnectX-7 网卡（或同等型号）
* InfiniBand 交换机网络

#### 软件

加载 IPoIB 内核模块，并确认 IB 驱动和接口已正常运行：

```shell
# 加载 IPoIB 内核模块
modprobe ib_ipoib

# 验证 OFED 驱动已加载且链路层为 InfiniBand
ibstat
# 预期输出：adapter state "Active"，link layer: InfiniBand

# 列出 IB 网络接口
ip addr show | grep -E "^[0-9]+: ib"
# 预期输出：一个或多个 ib* 接口（如 ib0、ibs22）

# 确认 IB 接口已分配 IP 地址
ip addr show ib0
# 预期输出：inet <IP>/prefix scope global ib0

# 验证 InfiniBand 设备可访问
ibv_devinfo
# 预期输出：hca_id，port_state: PORT_ACTIVE
```

#### MTU 配置

IPoIB 有两种传输模式，决定了最大支持的 MTU：

| 模式            | 最大 MTU    | 典型环境                      |
| ------------- | --------- | ------------------------- |
| Datagram（UD）  | 2,044 字节  | 云托管 IB（Azure HPC、AWS EFA） |
| Connected（RC） | 65,520 字节 | 本地 InfiniBand 网络          |

设置 MTU 前，先确认当前模式：

```shell
cat /sys/class/net/ib0/mode
ip link show ib0 | grep mtu
```

如果模式为 `datagram`（云端 IPoIB 常见），硬件限制为 2,044 字节。将 MTU 设置为 9000 会报 `RTNETLINK answers: Invalid argument`——这是预期行为，并非错误。Alluxio 在 MTU 2,044 下可正常运行。

如果模式为 `connected`（通常为本地部署），可将 MTU 设置为 9000 以获得最大吞吐量：

```shell
ip link set ib0 mtu 9000

# 验证
ip link show ib0 | grep mtu
# 预期输出：mtu 9000
```

如需在重启后保持 MTU 设置，请将配置写入系统网络配置文件（如 `/etc/network/interfaces` 或 systemd-networkd 配置单元）。

### 将 Alluxio 绑定到 IB 接口

Alluxio 的热数据通路在 **Worker** 和 **FUSE / 客户端节点**之间——这是 IB 带宽发挥作用的地方。Coordinator 负责后台任务（元数据操作、后台作业等），不在数据服务的关键路径上，因此无需运行在具备 IB 网卡的机器上。

通用的 NIC 绑定配置请参考[集群管理](/ee-ai-cn/ai-3.8-15.1.x-cn/administration/managing-alluxio.md)。以下步骤在通用配置基础上针对 IPoIB 场景做了扩展。

{% tabs %}
{% tab title="Kubernetes (Operator)" %}
对于具备 IB 硬件的 Kubernetes 集群，可通过以下方式将 IPoIB 暴露给 Pod：

* **NVIDIA Network Operator**：自动化部署 MLNX\_OFED 驱动和 SR-IOV Device Plugin
* **Multus CNI**：为 Alluxio Pod 挂载辅助 IB 网络接口
* **SR-IOV Device Plugin**：将 IB 虚拟功能（VF）作为 Pod 资源暴露

具体配置请参考 [NVIDIA Network Operator 文档](https://docs.nvidia.com/networking/display/cokan10/network+operator) 和 [Multus CNI](https://github.com/k8snetworkplumbingwg/multus-cni)。Pod 内 IB 接口可用后，参照裸机 tab 中的 `alluxio-site.properties` 配置即可。
{% endtab %}

{% tab title="Docker / 裸机" %}
**Worker 配置**

在每个 Worker 节点的 `alluxio-site.properties` 中添加以下配置。将 `ib0` 替换为实际的 IB 接口名称（通过 `ip addr show` 查询）：

```properties
# 将所有 Worker 服务绑定到 IB 网络接口
alluxio.worker.rpc.bind.device=ib0
alluxio.worker.data.bind.device=ib0
alluxio.worker.web.bind.device=ib0
alluxio.worker.rest.bind.device=ib0
```

启动 Worker 后进行验证：

```shell
# 确认 Worker RPC 端口正在监听 IB 接口的 IP 地址
ss -tlnp | grep 29999
# 预期输出：监听地址与 ib0 的 IP 地址一致
```

**FUSE / 客户端配置**

对于运行 Alluxio FUSE 或直接客户端访问的节点，将数据通道绑定到 IB 接口：

```properties
# 将客户端数据通道绑定到 IB 网络接口
alluxio.user.network.data.bind.device=ib0
```

FUSE 挂载选项和前提条件（包括 `allow_other` 配置）请参考 [POSIX API (FUSE)](/ee-ai-cn/ai-3.8-15.1.x-cn/data-access/fuse-based-posix-api.md)。

**Coordinator 配置**

Coordinator 无需运行在具备 IB 网卡的机器上。将 `alluxio.coordinator.hostname` 设置为 Coordinator 节点的可达 IP 地址（通常为其以太网接口）：

```properties
alluxio.coordinator.hostname=<coordinator IP>
```

**验证端到端连接**

启动所有服务后，确认 Worker–Client 数据流量通过 IB 接口传输：

```shell
# 检查 IB 接口 IP 上的活跃连接
ss -tnp | grep <IB 接口 IP>
# 预期输出：Worker 与 FUSE 客户端之间的 ESTABLISHED 连接

# 在读取数据时确认 IB 流量（观察 ib0 的 rx_bytes 递增）
cat /sys/class/net/ib0/statistics/rx_bytes
```

{% endtab %}
{% endtabs %}

### 参考性能

以下测试结果来自一个使用 IPoIB 的示例测试环境，Alluxio 运行在物理机上。

#### 测试环境

| 参数   | 值                                         |
| ---- | ----------------------------------------- |
| 网络   | 2 × 200 Gbps IPoIB（bonding），实测吞吐：360 Gbps |
| 网卡   | Mellanox ConnectX-7（IB 链路层，200 Gbps）      |
| 缓存磁盘 | RAID0，2 × NVMe，读/写：\~12 GB/s              |
| UFS  | 对象存储，100 Gbps 专线                          |
| 部署方式 | 物理机，FUSE 与 Worker 混部署                     |

#### 网络层吞吐（iperf3）

| 配置                          | 实测吞吐     |
| --------------------------- | -------- |
| 单 IB 端口                     | 180 Gb/s |
| Bonding（2 × 200 Gbps IPoIB） | 360 Gbps |

#### Alluxio 读取吞吐（热读，大文件，32 并发）

| 配置                                | 顺序读           |
| --------------------------------- | ------------- |
| 1 FUSE + 1 Worker，1 × NVMe        | 6.3 GB/s      |
| 1 FUSE + 1 Worker，RAID0 2 × NVMe  | 12.5 GB/s     |
| 3 FUSE + 3 Workers，RAID0 2 × NVMe | **36.6 GB/s** |

> **观察**：在 3 Worker + RAID0 NVMe 缓存的配置下，Alluxio 热读吞吐接近裸盘带宽上限（\~36 GB/s 实测 vs. \~36 GB/s RAID0 理论上限），表明在此规模下 IPoIB 网络不是性能瓶颈。

### 故障排查

**Worker 未绑定到 IB 接口**

* 运行 `ip addr show ib0` 确认接口已分配 IP 地址。
* 检查 `alluxio.worker.rpc.bind.device` 中的接口名是否与实际名称完全一致（区分大小写）。
* 查看 `alluxio-worker.log` 中的 `bind` 相关错误。

**Worker 通过以太网而非 IB 提供数据**

* 确认每个 Worker 节点上设置了 `alluxio.worker.data.bind.device=ib0`，且修改后已重启 Worker 进程。
* 确认 FUSE / 客户端节点上设置了 `alluxio.user.network.data.bind.device=ib0`。

**`ip link set ib0 mtu 9000` 报 `RTNETLINK answers: Invalid argument`**

* 您的 IPoIB 接口处于 datagram 模式，MTU 上限为 2,044 字节。这在云托管 InfiniBand（Azure HPC、AWS EFA）上很常见。Alluxio 在默认 MTU 下可正常运行，无需任何操作。参见 [MTU 配置](#mtu-配置)。

**IPoIB 吞吐偏低**

* 在节点间运行 `iperf3 -c <other node ib0 IP>` 建立网络层基准。
* 检查 `cat /sys/class/net/ib0/mode`——datagram 模式（MTU 2,044）与 connected 模式（MTU 9,000）相比峰值吞吐会受限。
* 确认所有服务均通过 IB 接口通信：`ss -tnp | grep <ib0 IP>`。

**重启后 IB 接口消失**

* MTU 和 bonding 配置可能未持久化，请将其写入系统网络配置文件。
* 验证 MLNX\_OFED 驱动是否随系统启动加载：`lsmod | grep ib_core`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.alluxio.io/ee-ai-cn/ai-3.8-15.1.x-cn/performance/rdma-networking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
