Fio 测试

xiaoxiao2021-02-28  38

0 Preview 

FIO 是用来测试磁盘/块设备性能的工具,而且集成了很多的参数等功能,可以帮助用户对磁盘性能有更好的了解。

1 Install

yum install fio

2 Param

fio 命令的参数有很多,我记录一下我使用到的参数和与其相关的说明。在此之前先写一个demo:

[root@100 /data1/test_fio]# fio -filename=/data1/test_fio/2 -output=/data1/test_fio/100S100W2 -blocksize=2K -size=110MB -rw=write -name=100S100W

这个命令是说向 /data1/test_fio/2  里面写入110MB文件,每次写入2KB,把测试结果输出在/data1/test_fio/100S100W2

filename字段,这个字段申明了此次测试是文件还是设备。这里可以填裸设备,或者挂载的磁盘,或者文件。因为我在使用的时候已经将一块磁盘挂载到/data1,并且磁盘数据正在使用,所以不能使用磁盘进行测试而使用文件。output字段,写上文件名之后可以将测试的结果重定向到文件,不填则输出到shell。rw,填写测试的数据读写模式,可填 read/write/readwrite,randread/randwrite/randrw 表示顺序读写/随机读写。blocksize/bs,单次IO的块文件大小,默认为4K。size,设置本次测试的总文件大小。remixread,在填写读写模式时,选择读写混合模式,那么这里可以设置读写比例。iodepth,同一时刻发送多少个IO。direct,如果是1表示不使用IO buffer。zero_buffer,表示用0初始化系统buffer。lock_mem,测试内存使用上限,如1G。

3 Out details

对于输出来说,我们可以先看一下刚才的demo输出内容,再来进行分析。

100S100W: (g=0): rw=write, bs=2K-2K/2K-2K/2K-2K, ioengine=sync, iodepth=1 fio-2.0.13 Starting 1 process 100S100W: (groupid=0, jobs=1): err= 0: pid=20971: Fri Apr 20 12:48:32 2018 <strong>write: io=112640KB, bw=88207KB/s, iops=44103 , runt= 1277msec</strong> clat (usec): min=1 , max=13508 , avg=21.98, stdev=64.78 lat (usec): min=1 , max=13509 , avg=22.05, stdev=64.78 clat percentiles (usec): | 1.00th=[ 1], 5.00th=[ 1], 10.00th=[ 1], 20.00th=[ 1], | 30.00th=[ 1], 40.00th=[ 1], 50.00th=[ 8], 60.00th=[ 41], | 70.00th=[ 41], 80.00th=[ 42], 90.00th=[ 42], 95.00th=[ 42], | 99.00th=[ 45], 99.50th=[ 45], 99.90th=[ 137], 99.95th=[ 153], | 99.99th=[ 205] bw (KB/s) : min=84140, max=90768, per=99.15%, avg=87454.00, stdev=4686.70 lat (usec) : 2=40.42%, 4=9.58%, 10=0.01%, 50=49.72%, 100=0.09% lat (usec) : 250=0.19%, 500=0.01% lat (msec) : 10=0.01%, 20=0.01% cpu : usr=4.08%, sys=13.48%, ctx=28162, majf=0, minf=25 IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=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.0%, 64=0.0%, >=64=0.0% issued : total=r=0/w=56320/d=0, short=r=0/w=0/d=0 Run status group 0 (all jobs): WRITE: io=112640KB, aggrb=88206KB/s, minb=88206KB/s, maxb=88206KB/s, mint=1277msec, maxt=1277msec Disk stats (read/write): sdb: ios=25129/0, merge=0/0, ticks=1032/0, in_queue=1028, util=82.70%

主要看write一行内容,这一行的io记录了此次测试了112640KB大小,bw记录了带宽为88207KB/S,iops为44103,runt运行时间为1277ms。其中io为输入的110MB换算而来;bw带宽为单位时间的传输量,此处为110MB*1024/1277*1000=88207KB/S;而iops为单位时间的io次数,此次测试的每次io为bs记录,数值为2K;所以iops = bw / bs = 44103。

其他的,主要是延时(lat),cpu,io depth相关。下进行一些小结:

slat:submission latency 表示 磁盘将IO提交到内核所需时间

clat:completion latency 表示 IO命令在内核之后的完成时间

lat:总的延时信息

clat percentiles:延时的分布比例,分位数;表示百分之多少的IO在多少微秒内完成。

cpu:分别表示用户态/内核态 cpu占用率,进程上下文切换次数,主要和次要(major/minor)页面错误数量。

最后一栏的Run status group表示不同组进程/组之间的汇总信息。

Disk stats 是磁盘的 iostat 命令,但是注意单位是否有换算。

转载请注明原文地址: https://www.6miu.com/read-1750311.html

最新回复(0)