
fio是测试存储系统非常重要的工具,能够快速检测出磁盘的IOPS、吞吐能力,以及时间延迟。该工具能够发起指定类型的IO操作,例如顺序读写、随机读写。同时还可以发起多线性,模拟高负载场景。
针对常用的IOPS、吞吐量、时延,如何有效利用fio工具,下面进行详细的讲解。
1、准备测试环境
系统:Ubuntu 20.04.5 LTS
内核:5.4.0-125-generic
工具安装:
#sudo apt update
#sudo apt install fio
#查看fio版本
#fio --version
fio-3.16
2、测试说明
** 测试用例 **
root@test:~# fio --name=iops-test \
> --filename=/dev/vdd \
> --rw=randrw \
> --bs=1M \
> --numjobs=4 \
> --iodepth=32 \
> --size=100G \
> --runtime=120 \
> --direct=1 \
> --ioengine=libaio \
> --group_reporting
iops-test: (g=0): rw=randrw, bs=(R) 1024KiB-1024KiB, (W) 1024KiB-1024KiB, (T) 1024KiB-1024KiB, ioengine=libaio, iodepth=32
...
fio-3.16
Starting 4 processes
Jobs: 4 (f=3): [f(1),m(3)][7.9%][r=21.0MiB/s,w=53.0MiB/s][r=21,w=53 IOPS][eta 23m:22s]
iops-test: (groupid=0, jobs=4): err= 0: pid=819940: Thu Oct 30 14:42:57 2025
read: IOPS=134, BW=134MiB/s (141MB/s)(15.8GiB/120883msec)
slat (usec): min=16, max=7159, avg=30.08, stdev=56.42
clat (usec): min=678, max=899408, avg=70537.48, stdev=86563.85
lat (usec): min=703, max=899440, avg=70567.72, stdev=86564.27
clat percentiles (usec):
| 1.00th=[ 807], 5.00th=[ 881], 10.00th=[ 938], 20.00th=[ 1074],
| 30.00th=[ 1958], 40.00th=[ 28967], 50.00th=[ 50594], 60.00th=[ 68682],
| 70.00th=[ 83362], 80.00th=[108528], 90.00th=[173016], 95.00th=[283116],
| 99.00th=[375391], 99.50th=[396362], 99.90th=[421528], 99.95th=[429917],
| 99.99th=[893387]
bw ( KiB/s): min=26624, max=258048, per=100.00%, avg=138224.57, stdev=10385.68, samples=961
iops : min= 26, max= 252, avg=134.75, stdev=10.14, samples=961
write: IOPS=138, BW=138MiB/s (145MB/s)(16.3GiB/120883msec); 0 zone resets
slat (usec): min=27, max=8096, avg=176.42, stdev=81.67
clat (msec): min=10, max=1677, avg=857.59, stdev=106.68
lat (msec): min=10, max=1677, avg=857.77, stdev=106.68
clat percentiles (msec):
| 1.00th=[ 531], 5.00th=[ 625], 10.00th=[ 751], 20.00th=[ 818],
| 30.00th=[ 844], 40.00th=[ 860], 50.00th=[ 877], 60.00th=[ 902],
| 70.00th=[ 927], 80.00th=[ 927], 90.00th=[ 927], 95.00th=[ 927],
| 99.00th=[ 927], 99.50th=[ 1099], 99.90th=[ 1586], 99.95th=[ 1636],
| 99.99th=[ 1670]
bw ( KiB/s): min=28672, max=202752, per=99.68%, avg=140998.20, stdev=5308.75, samples=963
iops : min= 28, max= 198, avg=137.45, stdev= 5.19, samples=963
lat (usec) : 750=0.13%, 1000=7.67%
lat (msec) : 2=7.02%, 4=0.45%, 10=0.81%, 20=1.83%, 50=6.41%
lat (msec) : 100=13.77%, 250=8.42%, 500=3.02%, 750=4.69%, 1000=45.46%
lat (msec) : 2000=0.30%
cpu : usr=0.63%, sys=0.20%, ctx=32899, majf=0, minf=54
IO depths : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=0.2%, 32=99.6%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.1%, 64=0.0%, >=64=0.0%
issued rwts: total=16220,16698,0,0 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=32
Run status group 0 (all jobs):
READ: bw=134MiB/s (141MB/s), 134MiB/s-134MiB/s (141MB/s-141MB/s), io=15.8GiB (17.0GB), run=120883-120883msec
WRITE: bw=138MiB/s (145MB/s), 138MiB/s-138MiB/s (145MB/s-145MB/s), io=16.3GiB (17.5GB), run=120883-120883msec
Disk stats (read/write):
vdd: ios=16296/16693, merge=0/0, ticks=1141596/14265220, in_queue=15342984, util=99.98%
测试命令使用了几个重要参数
–filename=/dev/vdd #测试文件路径,这里使用的是直接挂载的块设备
–rw=randrw #指定读写模式
–bs=1M #单次io的块大小
–numjobs=4 #每个job(任务)开4个#线程,默认1个job * numjobs就是总任务线程
–iodepth=32 #队列的深度,限制cpu无限发命令
–size=100G #每个线程读写的数据量为100GB
–runtime=120 #运行120秒
–direct=1 #绕过缓存,直接I/O
–ioengine=libaio #指定io引擎使用libaio方式,使用的是本地异步IO
–group_reporting #对结果进行汇总展示
上面的测试用例输出的结果需要关注的重要指标:
1、使用 1M大块数据 进行随机读写,减少I/O的次数,最大化的利用带宽。同时使用 iodepth高队列深度 和 numjobs多任务 来充分压榨存储设备的并发处理能力。这样便可以得到有效的吞吐性能和IOPS值。
可以从上面输出指标中找到BW和IOPS。
2、但是上面的输出用例中无法有效得到 时延 ,因为大块数据使用的时间本身就很长。若需要得到基础数据,需要调整参数。
使用 队列深度为1 的测试,模拟单个请求的响应速度。这排除了队列优化带来的影响,直接反映基础延迟。
fio --name=latency-test \
--filename=/dev/vdd \
--rw=randread \
--bs=4k \ #小文件
--numjobs=1 \ #单线程
--iodepth=1 \ #单个队列
--size=10G \
--runtime=60 \
--direct=1 \
--ioengine=libaio \
--group_reporting
得到的输出结果,关注slat和clat。
slat是提交延迟,提交该IO请求到kernel所花的时间(不包括kernel处理的时间)
clat是完成延迟,提交该IO请求到kernel后,处理所花的时间
324

被折叠的 条评论
为什么被折叠?



