Use fio on a Linux ECS instance to measure raw disk IOPS, throughput, and latency for block storage performance tuning.
fio is an open source I/O benchmarking tool that can test block storage performance metrics such as random and sequential read/write operations.
Procedure
-
If a block storage device contains partitions, file systems, or data, fio may corrupt the file systems and cause data loss. Create snapshots before testing. See Create snapshot manually.
-
Do not test with the system disk or any data disk that contains data. Use a newly created, uninitialized, empty data disk instead.
-
Test results are obtained in a test environment and are for reference only. In production, cloud disk performance may vary due to factors such as network conditions and concurrent access.
-
After testing the new disk:
-
This item is reserved and cannot be used directly. See Re-initialize a data disk.
-
The following examples use an Alibaba Cloud Linux 3.2104 LTS 64-bit public image. Operations may vary depending on your instance image.
-
Connect to an ECS instance.
For more information, see Log on to a Linux instance using Workbench.
-
Query block storage device names.
sudo fdisk -lu
The instance has three block storage devices: system disk /dev/vda and two data disks /dev/vdb and /dev/vdc. -
Check for partitions and file systems on the devices.
sudo blkid
Devices /dev/vda and /dev/vdb have partitions and file systems. Device /dev/vdc is not listed, indicating no partitions or file systems. WarningIf the test object contains partitions, file systems, or data, fio may corrupt the file systems and cause data loss. If your data disk has partitions and file systems, create an empty data disk for testing.
-
Create a pay-as-you-go disk with the same specifications and attach it to your instance. See Create a data disk.
-
After testing, release the pay-as-you-go disk. See Release a cloud disk.
-
-
Back up the data on the devices before testing. See Create snapshot manually.
NoteSnapshots incur fees. See Snapshot billing.
-
Install the libaio library and fio based on your operating system.
Alibaba Cloud Linux 2/3, or CentOS 6 or later
NoteCentOS 6 reached end of life (EOL). In accordance with Linux community rules, all content was removed from the following CentOS 6 repository address: http://mirror.centos.org/centos-6/. If you continue to use the default CentOS 6 repository on Alibaba Cloud, an error is reported. To use specific installation packages of CentOS 6, change the CentOS 6 repository address. For more information, see How do I change CentOS 6 repository addresses?
sudo yum install libaio libaio-devel fio -yDebian 9 or later, or Ubuntu 14 or later
ImportantDebian 9 and Debian 10 reached their EOL. If your instance runs Debian 9 or Debian 10, change the repository addresses. See Change repository addresses after CentOS or Debian reached its EOL
sudo apt-get update sudo apt-get install libaio* fio -y -
Change to the /tmp directory:
cd /tmp -
Run the test commands.
-
For cloud disk test commands, see the Cloud disk test commands section.
-
For local disk test commands, see the Local disk test commands section.
-
-
View the test results. Metric values vary by cloud disk category. The values in the following figures are for reference only.
-
The
IOPSvalue indicates the IOPS test result.
-
The
BWvalue indicates the throughput test result.
-
The lat (usec) value indicates the latency test result.

Cloud disk test commands
Running fio on a disk that contains partitions, a file system, or data can cause file system errors and data loss. If your data disk has partitions and a file system, create a new, empty data disk for testing:
-
Create a pay-as-you-go disk with the same configuration and attach it to the instance. See Create a data disk.
-
After the test is complete:
-
If you want to keep the disk: Re-initialize a data disk.
-
If you no longer need the disk: detach and then release it.
-
The parameter values in the following commands are for reference only. Replace /dev/your_device with your block storage device name obtained in Step 2 of the "Procedure" section. For example, replace /dev/your_device with /dev/vdb. For fio parameter details, see the fio parameters section.
-
Test random write IOPS.
sudo fio -direct=1 -iodepth=128 -rw=randwrite -ioengine=libaio -bs=4k -size=1G -numjobs=1 -runtime=1000 -group_reporting -filename=/dev/your_device -name=Rand_Write_Testing -
Test random read IOPS.
sudo fio -direct=1 -iodepth=128 -rw=randread -ioengine=libaio -bs=4k -size=1G -numjobs=1 -runtime=1000 -group_reporting -filename=/dev/your_device -name=Rand_Read_Testing -
Test sequential write throughput.
sudo fio -direct=1 -iodepth=64 -rw=write -ioengine=libaio -bs=1024k -size=1G -numjobs=1 -runtime=1000 -group_reporting -filename=/dev/your_device -name=Write_PPS_Testing -
Test sequential read throughput.
sudo fio -direct=1 -iodepth=64 -rw=read -ioengine=libaio -bs=1024k -size=1G -numjobs=1 -runtime=1000 -group_reporting -filename=/dev/your_device -name=Read_PPS_Testing -
Test random write latency.
sudo fio -direct=1 -iodepth=1 -rw=randwrite -ioengine=libaio -bs=4k -size=1G -numjobs=1 -group_reporting -filename=/dev/your_device -name=Rand_Write_Latency_Testing -
Test random read latency.
sudo fio -direct=1 -iodepth=1 -rw=randread -ioengine=libaio -bs=4k -size=1G -numjobs=1 -group_reporting -filename=/dev/your_device -name=Rand_Read_Latency_Testing
Local disk test commands
Running fio on a disk that contains partitions, file systems, or data will cause file system errors and data loss. If your data disk has partitions and a file system, create a new instance with local disks for testing:
-
Local disks can only be created with an instance. Create a new instance with the same configuration for testing. See Custom launch ECS instances.
-
After the test is complete:
-
To keep the instance, see Re-initialize a data disk.
-
To discard the instance, uninstall and then release the disk.
-
The following commands apply to local NVMe SSDs and local SATA HDDs. The parameter values are for reference only. Replace /dev/your_device with your block storage device name obtained in Step 2 of the "Procedure" section. For example, replace /dev/your_device with /dev/vdb. For fio parameter details, see the fio parameters section.
-
Test random write IOPS.
sudo fio -direct=1 -iodepth=32 -rw=randwrite -ioengine=libaio -bs=4k -numjobs=4 -time_based=1 -runtime=1000 -group_reporting -filename=/dev/your_device -name=test -
Test random read IOPS.
sudo fio -direct=1 -iodepth=32 -rw=randread -ioengine=libaio -bs=4k -numjobs=4 -time_based=1 -runtime=1000 -group_reporting -filename=/dev/your_device -name=test -
Test sequential write throughput.
sudo fio -direct=1 -iodepth=128 -rw=write -ioengine=libaio -bs=128k -numjobs=1 -time_based=1 -runtime=1000 -group_reporting -filename=/dev/your_device -name=test -
Test sequential read throughput.
sudo fio -direct=1 -iodepth=128 -rw=read -ioengine=libaio -bs=128k -numjobs=1 -time_based=1 -runtime=1000 -group_reporting -filename=/dev/your_device -name=test -
Test random write latency.
sudo fio -direct=1 -iodepth=1 -rw=randwrite -ioengine=libaio -bs=4k -numjobs=1 -time_based=1 -runtime=1000 -group_reporting -filename=/dev/your_device -name=test -
Test random read latency.
sudo fio -direct=1 -iodepth=1 -rw=randread -ioengine=libaio -bs=4k -numjobs=1 -time_based=1 -runtime=1000 -group_reporting -filename=/dev/your_device -name=test -
Test sequential write latency.
sudo fio -direct=1 -iodepth=1 -rw=write -ioengine=libaio -bs=4k -numjobs=1 -time_based=1 -runtime=1000 -group_reporting -filename=/dev/your_device -name=test -
Test sequential read latency.
sudo fio -direct=1 -iodepth=1 -rw=read -ioengine=libaio -bs=4k -numjobs=1 -time_based=1 -runtime=1000 -group_reporting -filename=/dev/your_device -name=test
fio parameters
The following table describes the fio parameters used in the preceding commands.
|
Parameter |
Description |
|
direct |
Specifies whether to use direct I/O. Default value: 1. Valid values:
|
|
iodepth |
The I/O queue depth. For example, |
|
rw |
The read/write policy. Valid values:
|
|
ioengine |
The I/O engine. In most cases, libaio is used. For other engines, see the fio documentation. |
|
bs |
The block size of I/O units. Default value: 4k. Separate read/write values can be specified as <read>,<write>. |
|
size |
The test file size. fio ends the test after the specified size is read or written, unless limited by runtime. If not specified, fio uses the full size of the given files or devices. Can also be a percentage (1-100). For example, size=20% uses 20% of the total file or device size. |
|
numjobs |
The number of concurrent threads. Default value: 1. |
|
runtime |
The test duration in seconds. If not specified, the test runs until the files specified by size are fully read or written in the block size specified by bs. |
|
group_reporting |
The result display mode. When specified, results are aggregated per process instead of per task. |
|
filename |
The test target path — a device name or file path. In this topic, the target is a raw disk without a file system. Replace /dev/your_device with the actual device path. |
|
name |
The test name. Specify as needed. In the preceding examples, Rand_Write_Testing is used. |
See fio(1) - Linux man page for the full parameter reference.