FIO tool in action
fio 说明
FIO
一个Linux I/O子系统和调度程序测试的强大工具.
Fio was written by Jens Axboe <axboe@kernel.dk> to enable flexible testing of the Linux I/O subsystem and schedulers. He got tired of writing specific test applications to simulate a given workload, and found that the existing I/O benchmark/test tools out there weren’t flexible enough to do what he wanted. |
FIO install
# centos |
fio test
选择需要测试的磁盘挂载:
#检查磁盘信息 |
test action
- 测试顺序read
1 | $ sudo fio -direct=1 -iodepth=128 -rw=read -ioengine=libaio -bs=128k -numjobs=1 -time_based=1 -runtime=1000 -group_reporting -filename=/dev/vdd -name=test |
- 随机读:
1 | $ sudo fio -direct=1 -iodepth=128 -rw=randread -ioengine=libaio -bs=4k -size=1G -numjobs=1 -runtime=1000 -group_reporting -filename=/dev/vdd -name=Rand_Read_Testing |
fio test macos ssd performence
https://www.nivas.hr/blog/2017/09/19/measuring-disk-io-performance-macos/
# start test |
result :
1 | test: (g=0): rw=randrw, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=posixaio, iodepth=64 |
标准化测试脚本
centos 上执行对本地Disk 进行FIO测试的标准化脚本:
1 | cat < EOF > disk_fio_test.sh |
执行标准脚本进行测试,选择Disk mount 为/dev/sdm
进行测试
sudo su - |
FIO参数说明
FIO参数取值说明
下表以测试云盘随机写IOPS(randwrite)的命令为例,说明各种参数的含义。
参数 | 说明 |
---|---|
-direct=1 | 表示测试时忽略I/O缓存,数据直写。 |
-iodepth=128 | 表示使用异步I/O(AIO)时,同时发出I/O数的上限为128。 |
-rw=randwrite | 表示测试时的读写策略为随机写(random writes)。其它测试可以设置为: randread(随机读random reads) read (顺序读sequential reads) write(顺序写sequential writes) randrw(混合随机读写mixed random reads and writes) |
-ioengine=libaio | 表示测试方式为libaio(Linux AIO,异步I/O)。应用程序使用I/O通有两种方式: 同步: 同步的I/O一次只能发出一个I/O请求,等待内核完成才返回。这样对于单个线程iodepth总是小于1,但是可以透过多个线程并发执行来解决。通常会用16~32根线程同时工作将iodepth塞满。 异步 异步的I/O通常使用libaio这样的方式一次提交一批I/O请求,然后等待一批的完成,减少交互的次数,会更有效率。 |
-bs=4k | 表示单次I/O的块文件大小为4 KiB。默认值也是4 KiB。 测试IObr/S时,建议将bs设置为一个较小的值,如4k。 测吞吐量时,建议将bs设置为一个较大的值,如1024k。 |
-size=1G | 表示测试文件大小为1 GiB。 |
-numjobs=1 | 表示测试线程数为1。 |
-runtime=1000 | 表示测试时间为1000秒。如果未配置,则持续将前述-size指定大小的文件,以每次-bs值为分块大小写完。 |
-group_reporting | 表示测试结果里汇总每个进程的统计信息,而非以不同job汇总展示信息。 |
-filename=/dev/your_device | 指定的云盘设备名,例如/dev/your_device。 |
-name=Rand_Write_Testing | 表示测试任务名称为Rand_Write_Testing,可以随意设定。 |