# 测试 POSIX 性能

Fio (Flexible I/O Tester) 是一款功能强大的开源工具，用于对存储系统的性能进行基准测试。由于 Alluxio 可以使用 FUSE 挂载为符合 POSIX 标准的文件系统，因此 `fio` 是衡量其读/写 IOPS 和吞吐量的绝佳工具。

本指南将引导您完成如何设置和运行 `fio` 以对 Alluxio 中缓存的数据进行性能基准测试。

## 性能亮点

以下结果是在单个 Alluxio 工作节点和单个客户端上实现的，基于下面详述的测试环境。您的结果可能会因您的特定硬件和设置而异。

### 吞吐量（256k 块大小）

| 带宽/线程 | 单线程       | 32 线程     | 128 线程    |
| ----- | --------- | --------- | --------- |
| 顺序读取  | 2101MiB/s | 9519MiB/s | 8089MiB/s |
| 随机读取  | 202MiB/s  | 6684MiB/s | 8276MiB/s |

### IOPS（4k 块大小）

| IOPS/线程 | 单线程   | 32 线程 | 128 线程 |
| ------- | ----- | ----- | ------ |
| 顺序读取    | 55.9k | 253k  | 192k   |
| 随机读取    | 2.3k  | 70.1k | 162k   |

## 测试环境和设置

本指南中使用以下环境生成示例结果。所有实例都位于同一个 AWS 可用区，以最大限度地减少网络延迟。

### 硬件和软件

* **Alluxio 工作节点**:
  * 实例: AWS `i3en.metal`
  * 存储: 8 个 NVMe SSD，采用 RAID 0 阵列
  * 操作系统: Ubuntu 24.04
* **Alluxio 客户端节点**:
  * 实例: AWS `c5n.metal`
  * 操作系统: Ubuntu 24.04
  * FUSE: 版本 3.16.2 或更高版本

### Fio 安装

在客户端节点上，使用适当的包管理器安装 `fio`。对于基于 RPM 的发行版（如 CentOS），请使用 `yum`：

```bash
sudo yum install fio
```

对于基于 Debian 的发行版（如 Ubuntu），请使用 `apt`：

```bash
sudo apt-get install fio
```

### 数据准备

在运行基准测试之前，您需要一个大的测试文件。在本指南中，一个 100GB 的文件被放置在 UFS（同一区域中的 S3 存储桶）中，并完全加载到 Alluxio 缓存中，以确保基准测试衡量的是缓存读取的性能。

## 运行基准测试

以下命令应在 Alluxio 客户端节点上从 FUSE 挂载点内的目录中运行。

### 测试顺序读取吞吐量

此测试衡量可以读取大块连续数据的最大速度。它代表了视频流或大文件处理等工作负载。为此测试使用较大的块大小 (`bs`)，例如 `256k`。

```bash
fio -iodepth=1 -rw=read -ioengine=libaio -bs=256k -numjobs=<numjobs> -group_reporting -size=100G -filename=/mnt/alluxio/100gb -name=read_test --readonly -direct=1 --runtime=60
```

### 测试随机读取 IOPS

此测试衡量每秒可以执行多少次随机读取操作。它代表了数据库或键值存储等工作负载。为此测试使用较小的块大小 (`bs`)，例如 `4k`。

```bash
fio -iodepth=1 -rw=randread -ioengine=libaio -bs=4k -numjobs=<numjobs> -group_reporting -size=100G -filename=/mnt/alluxio/100gb -name=read_test --readonly -direct=1 --runtime=60
```

**关键 `fio` 参数:**

* `rw`: 指定 I/O 模式（`read` 表示顺序，`randread` 表示随机）。
* `bs`: 每个 I/O 操作的块大小。
* `numjobs`: 要运行的并发线程数。
* `filename`: FUSE 挂载中测试文件的路径。
* `direct=1`: 绕过操作系统页面缓存，以确保您正在衡量 Alluxio FUSE 的性能。


---

# 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.7/benchmark/benchmarking-posix-performance.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.
