This topic describes how to use the fio tool on a Linux Elastic Compute Service (ECS) instance to test the performance of Elastic Block Storage (EBS) devices. EBS devices include cloud disks and local disks, and the performance metrics of these disks include IOPS, throughput, and latency.

Prerequisites

An EBS device is created and attached to a Linux ECS instance.
Note If you want to test only the performance of a specific category of EBS devices, we recommend that you use a new pay-as-you-go data disk. You can release the disk after the test is complete.

Background information

You can use other tools to test the performance of EBS devices, but you may obtain different baseline performance. For example, tools such as dd, sysbench, and iometer may be affected by test parameters and file systems and return inaccurate results. The performance results in this topic are obtained from a fio test on a Linux instance. These results are used as performance references for Alibaba Cloud EBS devices. We recommend that you use the fio tool to test the performance of EBS devices for both Linux and Windows instances.

Warning
  • You can obtain accurate test results by testing raw disk partitions. However, you may destroy the file system structure in a raw disk partition if you directly test the partition. Before you test a raw disk, we recommend that you create a snapshot of the disk to back up your data. For more information about how to create a snapshot, see Create a snapshot for a disk.
  • We recommend that you do not test a disk where the operating system is located or a disk that stores important data. To prevent data loss, we recommend that you use a new Elastic Compute Service (ECS) instance that contains no data for the test.

Procedure

  1. Connect to an ECS instance.
  2. Before you test an EBS device, make sure that it is 4 KiB aligned.
    sudo fdisk -lu
    If the value of Start in the command output is divisible by 8, the device is 4 KiB aligned. Otherwise, perform 4 KiB alignment before you proceed with the test.
    Device     Boot Start      End  Sectors Size Id Type
    /dev/vda1  *     2048 83886046 83883999  40G 83 Linux
  3. Run the following commands in sequence to install libaio and fio:
    sudo yum install libaio -y
    sudo yum install libaio-devel -y
    sudo yum install fio -y
  4. Switch the directory.
    cd /tmp
  5. Run the test commands. For more information about the commands, see the following sections:

Commands used to test the performance of cloud disks

For information about how to test the IOPS of an enhanced SSD (ESSD), see Test the IOPS performance of an ESSD.

Note In this example, the device name of the cloud disk is /dev/your_device. Replace it with your actual device name. For example, if the device name of the cloud disk that you want to test is /dev/vdb, replace /dev/your_device with /dev/vdb in the following commands.
  • Command used to test the random write IOPS of a cloud disk:
    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
  • Command used to test the random read IOPS of a cloud disk:
    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
  • Command used to test the sequential write throughput of a cloud disk:
    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
  • Command used to test the sequential read throughput of a cloud disk:
    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
  • Command used to test the random write latency of a cloud disk:
    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
  • Command used to test the random read latency of a cloud disk:
    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

Commands used to test the performance of local disks

The following test commands are applicable to local Non-Volatile Memory Express (NVMe) SSDs and local Serial Advanced Technology Attachment (SATA) HDDs.

Note In this example, the device name of the local disk is /dev/your_device. Replace it with your actual device name. For example, if the device name of the local disk that you want to test is /dev/vdb, replace /dev/your_device with /dev/vdb in the following commands.
  • Command used to test the random write IOPS of a local disk:
    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
  • Command used to test the random read IOPS of a local disk:
    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
  • Command used to test the sequential write throughput of a local disk:
    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
  • Command used to test the sequential read throughput of a local disk:
    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
  • Command used to test the random write latency of a local disk:
    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
  • Command used to test the random read latency of a local disk:
    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
  • Command used to test the sequential write latency of a local disk:
    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
  • Command used to test the sequential read latency of a local disk:
    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 parameter settings

fio commands use specific parameters. The following table describes the parameter settings in the fio command used to test the random write IOPS (randwrite) of a cloud disk.
Parameter setting Description
-direct=1 Indicates that the I/O buffer is ignored during the test and data is directly written.
-iodepth=128 Indicates that when asynchronous I/O is used, up to 128 I/O requests can be concurrently made.
-rw=randwrite Indicates that the read/write policy is random writes. Other valid values for rw:
  • randread: random reads
  • read: sequential reads
  • write: sequential writes
  • randrw: random reads and writes
-ioengine=libaio Indicates that libaio (the Linux-native asynchronous I/O facility) is used for the test. An application can use I/O in the following ways:
  • Synchronous

    In synchronous I/O mode, a thread sends a single I/O request at a time and waits for the request to complete. In this case, the iodepth value is always less than 1 for a single thread. You can increase the iodepth value by using multiple concurrent threads. The iodepth value reaches its upper limit when 16 to 32 threads are running concurrently.

  • Asynchronous

    In asynchronous I/O mode, a thread uses libaio to send multiple I/O requests at a time and waits for all these requests to complete. Asynchronous I/O helps reduce the number of interactions and make interactions more efficient.

-bs=4k Indicates that the size of each block for one I/O is 4 KiB. The default value is also 4 KiB.
  • When IOPS is tested, we recommend that you set bs to a small value such as 4k.
  • When throughput is tested, we recommend that you set bs to a large value such as 1024k.
-size=1G Indicates that the size of the test file is 1 GiB.
-numjobs=1 Indicates that the number of test threads is 1.
-runtime=1000 Indicates that the test duration is 1,000 seconds. If this parameter is not specified, the file of the size specified by -size is written in blocks of the size specified by -bs.
-group_reporting Indicates that in the test results, statistics are displayed for a group of threads, not for each individual thread.
-filename=/dev/your_device Indicate that the device name of the cloud disk is /dev/your_device. Replace the value with the actual name of your cloud disk.
-name=Rand_Write_Testing Indicates that the name of the test task is Rand_Write_Testing. You can specify a name.