# fio — Flexible I/O Tester for Storage Benchmarking > fio is a configurable I/O workload generator used to benchmark and stress-test storage subsystems with precise control over read/write patterns, block sizes, and concurrency. ## Install Save as a script file and run: # fio — Flexible I/O Tester for Storage Benchmarking ## Quick Use ```bash # Install apt install fio # or: brew install fio / dnf install fio # Random 4K read benchmark, 4 jobs, 30 seconds fio --name=rand-read --ioengine=libaio --rw=randread --bs=4k --numjobs=4 --size=1G --runtime=30 --time_based --group_reporting # Sequential write throughput test fio --name=seq-write --ioengine=libaio --rw=write --bs=1M --numjobs=1 --size=4G --direct=1 --group_reporting ``` ## Introduction fio (Flexible I/O Tester) is the industry-standard tool for benchmarking storage devices and filesystems. Written in C, it can simulate virtually any I/O workload pattern by combining configurable block sizes, queue depths, access patterns, and I/O engines. It is used by storage vendors, kernel developers, and DevOps engineers to validate hardware and tune systems. ## What fio Does - Generates sequential, random, or mixed read/write workloads at any block size - Supports dozens of I/O engines including libaio, io_uring, sync, mmap, and RDMA - Runs multiple parallel jobs to stress-test concurrency and queue depth scaling - Reports IOPS, bandwidth, and latency at configurable percentile levels - Accepts job files in INI format for repeatable, shareable benchmark definitions ## Architecture Overview fio spawns one or more worker threads or processes, each executing an I/O loop defined by a job specification. Each job selects an I/O engine (the syscall or library interface), an access pattern (sequential, random, zipf), and parameters like block size and queue depth. A central statistics collector aggregates per-job metrics and emits a summary with IOPS, bandwidth, and latency percentiles. ## Self-Hosting & Configuration - Install via package manager or compile from source with `./configure && make` - Define workloads in `.fio` job files (INI-style) for reproducible benchmarks - Use `--direct=1` to bypass the page cache and measure raw device performance - Select the I/O engine matching your target: `io_uring` for modern Linux, `libaio` for legacy - Output results as JSON with `--output-format=json` for automated analysis pipelines ## Key Features - Supports 30+ I/O engines including io_uring, libaio, POSIX AIO, and Windows IOCP - Configurable access patterns: sequential, random, strided, and custom distributions - Per-job and group reporting with latency histograms and percentile breakdowns - Verification mode writes checksums and reads them back to detect data corruption - Job file format allows sharing and version-controlling benchmark definitions ## Comparison with Similar Tools - **sysbench fileio** — Simpler file I/O test but far fewer tuning options than fio - **dd** — Basic sequential throughput test, no random I/O or latency reporting - **bonnie++** — Classic filesystem benchmark with fixed test patterns - **Iometer** — Windows-centric GUI benchmark, less flexible than fio on Linux - **diskspd** — Microsoft's storage benchmarking tool, Windows-focused ## FAQ **Q: Should I use direct I/O or buffered I/O for benchmarks?** A: Use `--direct=1` to measure raw device speed. Buffered I/O benchmarks test the page cache, which is useful for application-level analysis. **Q: What I/O engine should I use on modern Linux?** A: `io_uring` offers the best performance on Linux 5.1+. Fall back to `libaio` for older kernels. **Q: How do I benchmark NVMe devices?** A: Use `io_uring` or `libaio` with high `iodepth` (64-256) and multiple jobs to saturate the device's internal parallelism. **Q: Can fio simulate real application workloads?** A: Yes. Record an application's I/O trace with blktrace and replay it with fio's `replay_redirect` option. ## Sources - https://github.com/axboe/fio - https://fio.readthedocs.io/ --- Source: https://tokrepo.com/en/workflows/asset-94698b64 Author: Script Depot