Benchmarking storage throughput on Linux servers has frequently relied on quick, ad-hoc shell commands like dd if=/dev/zero of=test.img bs=1G count=1 oflag=dsync. However, using dd as a disk performance benchmark is deeply flawed: it measures single-threaded sequential write velocity through volatile RAM write caches, ignores storage queue depths, fails to simulate database random read workloads, and produces wildly misleading IOPS numbers.
The fio (Flexible I/O Tester) command-line utility is the industry-standard storage benchmarking engine in Linux. Designed to simulate enterprise workloads, fio allows administrators to evaluate random and sequential read/write operations, configure asynchronous I/O engines (libaio or io_uring), specify concurrency queue depths, and generate accurate percentile latency distributions (99th and 99.9th percentiles) across NVMe, SSD, and enterprise RAID arrays.
Installing fio on Linux Distributions
The fio utility is available in the official package archives of all major distributions:
- On Ubuntu, Debian, and Linux Mint:
sudo apt update && sudo apt install -y fio
- On Fedora, RHEL, CentOS Stream, and Rocky Linux:
sudo dnf install -y fio
- On Arch Linux and Manjaro:
sudo pacman -S fio
Benchmarking Random Read/Write IOPS (Simulating Database Workloads)
Database engines (like PostgreSQL, MySQL, and MongoDB) generate intense 4KB random I/O transactions at high concurrency. To benchmark random read/write capabilities:
- Create a test directory on the target storage volume (for example, on an NVMe mount at
/mnt/data):
cd /mnt/data
- Run a multi-threaded random read/write test using the high-performance
libaioasynchronous engine:
fio --name=random_rw_test --ioengine=libaio --direct=1 --rw=randrw --rwmixread=75 --bs=4k --numjobs=4 --iodepth=16 --size=2G --runtime=60 --time_based --group_reporting
Parameter breakdown:
--direct=1: Bypasses operating system buffer caches, writing directly to disk blocks.--rw=randrw --rwmixread=75: Simulates a realistic 75% read and 25% write random workload.--bs=4k: Sets block size to 4 kilobytes.--iodepth=16 --numjobs=4: Generates 4 parallel worker threads with an I/O queue depth of 16.
Benchmarking Sequential Read Throughput (Large File Transfers)
To measure maximum sustained bandwidth for streaming backups, video editing caches, or multi-gigabyte log archives:
fio --name=sequential_read_test --ioengine=libaio --direct=1 --rw=read --bs=1M --numjobs=2 --iodepth=32 --size=5G --runtime=60 --time_based --group_reporting
Using a 1MB block size (--bs=1M) tests the maximum raw sequential read throughput of the physical storage bus.
Interpreting fio Benchmark Results
Once fio completes execution, review the summarized reporting block:
- IOPS: Input/Output Operations Per Second. High numbers indicate superior responsiveness for virtual machines and databases.
- Bandwidth (BW): Raw throughput expressed in MB/s or GB/s.
- clat (Completion Latency): Displays minimum, average, and maximum latency in microseconds (usec) or milliseconds (msec).
- Percentile Latencies: Review the
99.00thand99.90thpercentile figures. Even if average latency is 1 ms, a 99.9th percentile spike of 500 ms reveals severe storage contention that will cause database queries to hang.
Cleaning Up Benchmark Test Files
After benchmarking finishes, remove the generated temporary test files to reclaim storage:
rm -f random_rw_test* sequential_read_test*