简介:fio 是一个 开源的硬件I/O压力测试工具,主要是用来测试磁盘/SSD的io性能,也可测试cpu,nic的io性能。它可以支持13种不同的I/O引擎,包括:sync, mmap, libaio, posixaio, SG v3, splice, network, syslet, guasi, solarisaio, I/O priorities (针对新的Linux内核), rate I/O, forked or threaded jobs等。不同引擎的具体含义,可以参看fio的说明文档(安装后可以通过man fio查看),例如:
sync: Basic read(2) or write(2) I/O. fseek(2) is used to position the I/O location.
psync: Basic pread(2) or pwrite(2) I/O.
vsync: Basic readv(2) or writev(2) I/O. Will emulate queuing by coalescing adjacents IOs into a single submission.
libaio: Linux native asynchronous I/O.
……
fio支持的平台:Linux, FreeBSD, NetBSD, OS X, OpenSolaris, AIX, Windows,这里主要讲讲linux下地使用。
下载地址:
使用:可以根据测试者的想法进行各种混合io的测试,方法主要有两种形式:
一种是命令形式,即fio [-options];
另一种则是fio + 负载说明文件形式
[命令的形式]
1) random read
#./fio --filename=/dev/mmcblk0 --direct=1 --readonly --rw=randread --bs=4k --size=1G --numjobs=64 --runtime=100 --group_reporting --name=test-rand-read
test-rand-read: (g=0): rw=randread, bs=4K-4K/4K-4K, ioengine=sync, iodepth=1
...
test-rand-read: (g=0): rw=randread, bs=4K-4K/4K-4K, ioengine=sync, iodepth=1
fio 2.0.5
Starting 64 processes
Jobs: 64 (f=64): [rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr] [100.0% done] [8732K/0K /s] [2131 /0 iops] [eta 00m:00s]
test-rand-read: (groupid=0, jobs=64): err= 0: pid=4206
read : io=758736KB, bw=7525.9KB/s, iops=1881 , runt=100818msec
clat (usec): min=335 , max=3195.1K, avg=33832.22, stdev=151498.99
lat (usec): min=336 , max=3195.1K, avg=33833.29, stdev=151499.00
clat percentiles (usec):
| 1.00th=[ 724], 5.00th=[ 828], 10.00th=[ 892], 20.00th=[ 1032],
| 30.00th=[ 1208], 40.00th=[ 1288], 50.00th=[ 1352], 60.00th=[ 1400],
| 70.00th=[ 1464], 80.00th=[ 1544], 90.00th=[ 4448], 95.00th=[264192],
| 99.00th=[667648], 99.50th=[888832], 99.90th=[1728512]
bw (KB/s) : min= 1, max= 4016, per=1.81%, avg=135.88, stdev=267.82
lat (usec) : 500=0.07%, 750=1.53%, 1000=16.88%
lat (msec) : 2=69.02%, 4=1.75%, 10=2.81%, 20=0.06%, 50=0.17%
lat (msec) : 100=0.25%, 250=2.21%, 500=3.23%, 750=1.26%, 1000=0.35%
lat (msec) : 2000=0.29%, >=2000=0.10%
cpu : usr=0.03%, sys=0.10%, ctx=202287, majf=0, minf=0
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=189684/d=0, short=r=0/w=0/d=0
Run status group 0 (all jobs):
READ: io=758736KB, aggrb=7525KB/s, minb=7706KB/s, maxb=7706KB/s, mint=100818msec, maxt=100818msec
Disk stats (read/write):
mmcblk0: ios=189570/7, merge=0/11, ticks=6376420/67100, in_queue=7312880, util=99.98%
2) random write
#./fio --filename=/dev/mmcblk0 --direct=1 --rw=randwrite --bs=4k --size=1G --numjobs=64 --runtime=100 --group_reporting --name=test-rand-write
test-rand-write: (g=0): rw=randwrite, bs=4K-4K/4K-4K, ioengine=sync, iodepth=1
...
test-rand-write: (g=0): rw=randwrite, bs=4K-4K/4K-4K, ioengine=sync, iodepth=1
fio 2.0.5
Starting 64 processes
Jobs: 64 (f=64): [wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww] [100.0% done] [0K/3780K /s] [0 /923 iops] [eta 00m:00s]
test-rand-write: (groupid=0, jobs=64): err= 0: pid=4353
write: io=366108KB, bw=3632.1KB/s, iops=908 , runt=100776msec
clat (usec): min=896 , max=5874.6K, avg=70121.79, stdev=328571.44
lat (usec): min=897 , max=5874.6K, avg=70123.18, stdev=328571.49
clat percentiles (usec):
| 1.00th=[ 1832], 5.00th=[ 1928], 10.00th=[ 1976], 20.00th=[ 2064],
| 30.00th=[ 2800], 40.00th=[ 2896], 50.00th=[ 2960], 60.00th=[ 3024],
| 70.00th=[ 3088], 80.00th=[ 3184], 90.00th=[ 5344], 95.00th=[448512],
| 99.00th=[1646592], 99.50th=[2473984], 99.90th=[3719168]
bw (KB/s) : min= 0, max= 1888, per=2.25%, avg=81.85, stdev=216.73
lat (usec) : 1000=0.02%
lat (msec) : 2=13.07%, 4=72.24%, 10=8.21%, 20=0.15%, 50=0.11%
lat (msec) : 100=0.04%, 250=0.27%, 500=1.18%, 750=1.09%, 1000=0.89%
lat (msec) : 2000=2.04%, >=2000=0.69%
cpu : usr=0.02%, sys=0.05%, ctx=97193, majf=0, minf=0
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=0/d=0, short=r=91527/w=0/d=0
Run status group 0 (all jobs):
WRITE: io=366108KB, aggrb=3632KB/s, minb=3720KB/s, maxb=3720KB/s, mint=100776msec, maxt=100776msec
Disk stats (read/write):
mmcblk0: ios=50/91458, merge=0/55, ticks=35340/6476510, in_queue=8043440, util=99.98%
3) sequence read
#./fio --filename=/dev/mmcblk0 --direct=1 --readonly --rw=read --bs=1m --size=1G --numjobs=64 --runtime=100 --group_reporting --name=test-read
test-read: (g=0): rw=read, bs=1M-1M/1M-1M, ioengine=sync, iodepth=1
...
test-read: (g=0): rw=read, bs=1M-1M/1M-1M, ioengine=sync, iodepth=1
fio 2.0.5
Starting 64 processes
Jobs: 23 (f=23): [______R___RRR_RR__R_____R__R____R_RRRR____R___RR__R_R_R_R_R_R___] [4.1% done] [45999K/0K /s] [43 /0 iops] [eta 39m:21s]
test-read: (groupid=0, jobs=64): err= 0: pid=4716
read : io=134144KB, bw=42704KB/s, iops=41 , runt=101360msec
clat (msec): min=23 , max=5800 , avg=1523.97, stdev=1062.53
lat (msec): min=23 , max=5800 , avg=1523.97, stdev=1062.53
clat percentiles (msec):
| 1.00th=[ 47], 5.00th=[ 47], 10.00th=[ 59], 20.00th=[ 363],
| 30.00th=[ 627], 40.00th=[ 988], 50.00th=[ 1713], 60.00th=[ 2008],
| 70.00th=[ 2278], 80.00th=[ 2540], 90.00th=[ 2868], 95.00th=[ 3097],
| 99.00th=[ 3589], 99.50th=[ 3949], 99.90th=[ 5014]
bw (KB/s) : min= 176, max= 7420, per=2.13%, avg=910.26, stdev=790.62
lat (msec) : 50=9.11%, 100=1.92%, 250=0.95%, 500=14.45%, 750=11.85%
lat (msec) : 1000=1.82%, 2000=19.64%, >=2000=40.26%
cpu : usr=0.00%, sys=0.03%, ctx=6180, majf=0, minf=0
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=4227/d=0, short=r=0/w=0/d=0
Run status group 0 (all jobs):
READ: io=4227.0MB, aggrb=42703KB/s, minb=43728KB/s, maxb=43728KB/s, mint=101360msec, maxt=101360msec
Disk stats (read/write):
mmcblk0: ios=8546/113, merge=0/124, ticks=10817040/251140, in_queue=11089680, util=99.99%
4) sequence write
#./fio --filename=/dev/mmcblk0 --direct=1 --rw=write --bs=1m --size=1G --numjobs=64 --runtime=100 --group_reporting --name=test-write
test-write: (g=0): rw=write, bs=1M-1M/1M-1M, ioengine=sync, iodepth=1
...
test-write: (g=0): rw=write, bs=1M-1M/1M-1M, ioengine=sync, iodepth=1
fio 2.0.5
Starting 64 processes
Jobs: 29 (f=29): [___WW_W__W_W_W_WW_WWW___W__W__WWW__W____W_W_WWW_W__W____WW__W_WW] [2.8% done] [0K/36553K /s] [0 /34 iops] [eta 58m:19s]
test-write: (groupid=0, jobs=64): err= 0: pid=4581
write: io=2837.0MB, bw=28515KB/s, iops=27 , runt=101878msec
clat (msec): min=40 , max=19356 , avg=2273.10, stdev=2923.51
lat (msec): min=41 , max=19356 , avg=2273.31, stdev=2923.51
clat percentiles (msec):
| 1.00th=[ 70], 5.00th=[ 74], 10.00th=[ 91], 20.00th=[ 289],
| 30.00th=[ 396], 40.00th=[ 424], 50.00th=[ 449], 60.00th=[ 783],
| 70.00th=[ 3359], 80.00th=[ 5866], 90.00th=[ 6325], 95.00th=[ 6652],
| 99.00th=[13042], 99.50th=[14877], 99.90th=[16712]
bw (KB/s) : min= 52, max=10155, per=4.42%, avg=1260.61, stdev=1323.44
lat (msec) : 50=0.07%, 100=11.63%, 250=5.92%, 500=36.45%, 750=5.60%
lat (msec) : 1000=1.73%, 2000=5.25%, >=2000=33.35%
cpu : usr=0.01%, sys=0.02%, ctx=8526, majf=0, minf=0
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=0/d=0, short=r=2837/w=0/d=0
Run status group 0 (all jobs):
WRITE: io=2837.0MB, aggrb=28515KB/s, minb=29199KB/s, maxb=29199KB/s, mint=101878msec, maxt=101878msec
Disk stats (read/write):
mmcblk0: ios=107/5625, merge=0/9097, ticks=24100/9016530, in_queue=9063910, util=99.89%
[负载文件的方式]
如负载文件为fiotest.fio,内容如下:
[global]
bs=4k
ioengine=libaio
iodepth=4
size=1g
direct=1
runtime=10
directory=/data
filename=fio.test.file
[seq-read]
rw=read
[rand-read]
rw=randread
[seq-write]
rw=write
[rand-write]
rw=randwrite
执行:fio fiotest.fio,结果如下:
sh-3.2# ./fio fiotest.fio
seq-read: (g=0): rw=read, bs=4K-4K/4K-4K, ioengine=libaio, iodepth=4
rand-read: (g=0): rw=randread, bs=4K-4K/4K-4K, ioengine=libaio, iodepth=4
seq-write: (g=0): rw=write, bs=4K-4K/4K-4K, ioengine=libaio, iodepth=4
rand-write: (g=0): rw=randwrite, bs=4K-4K/4K-4K, ioengine=libaio, iodepth=4
fio 2.0.5
Starting 4 processes
seq-read: Laying out IO file(s) (1 file(s) / 1024MB)
Jobs: 4 (f=4): [RrWw] [100.0% done] [3281K/2434K /s] [801 /594 iops] [eta 00m:00s]
seq-read: (groupid=0, jobs=1): err= 0: pid=3173
read : io=6820.0KB, bw=698228 B/s, iops=170 , runt= 10002msec
slat (usec): min=16 , max=7252 , avg=31.50, stdev=211.74
clat (usec): min=417 , max=366047 , avg=23441.08, stdev=64494.80
lat (usec): min=474 , max=366065 , avg=23474.13, stdev=64495.03
clat percentiles (usec):
| 1.00th=[ 796], 5.00th=[ 1004], 10.00th=[ 1160], 20.00th=[ 1752],
| 30.00th=[ 2096], 40.00th=[ 2512], 50.00th=[ 2576], 60.00th=[ 2640],
| 70.00th=[ 2704], 80.00th=[ 2928], 90.00th=[58624], 95.00th=[209920],
| 99.00th=[259072], 99.50th=[358400], 99.90th=[366592]
bw (KB/s) : min= 56, max= 3384, per=20.88%, avg=726.38, stdev=1067.32
lat (usec) : 500=0.06%, 750=0.82%, 1000=3.99%
lat (msec) : 2=21.00%, 4=56.77%, 10=4.34%, 20=0.70%, 50=1.41%
lat (msec) : 100=1.88%, 250=6.86%, 500=2.05%
cpu : usr=0.30%, sys=0.40%, ctx=1104, majf=0, minf=0
IO depths : 1=0.1%, 2=0.1%, 4=99.8%, 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=1705/d=0, short=r=0/w=0/d=0
rand-read: (groupid=0, jobs=1): err= 0: pid=3174
read : io=28012KB, bw=2798.5KB/s, iops=699 , runt= 10010msec
slat (usec): min=21 , max=5311 , avg=28.74, stdev=105.33
clat (usec): min=393 , max=371722 , avg=5640.98, stdev=26206.20
lat (usec): min=445 , max=371746 , avg=5671.58, stdev=26207.16
clat percentiles (usec):
| 1.00th=[ 796], 5.00th=[ 964], 10.00th=[ 1224], 20.00th=[ 1368],
| 30.00th=[ 1496], 40.00th=[ 1720], 50.00th=[ 1832], 60.00th=[ 1976],
| 70.00th=[ 2224], 80.00th=[ 2512], 90.00th=[ 3312], 95.00th=[ 5024],
| 99.00th=[142336], 99.50th=[232448], 99.90th=[301056]
bw (KB/s) : min= 820, max= 5445, per=83.36%, avg=2900.06, stdev=1393.55
lat (usec) : 500=0.07%, 750=0.43%, 1000=5.35%
lat (msec) : 2=55.72%, 4=30.89%, 10=5.21%, 20=0.10%, 50=0.11%
lat (msec) : 100=0.17%, 250=1.74%, 500=0.17%
cpu : usr=0.70%, sys=2.80%, ctx=7507, majf=0, minf=0
IO depths : 1=0.1%, 2=0.1%, 4=100.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=7003/d=0, short=r=0/w=0/d=0
seq-write: (groupid=0, jobs=1): err= 0: pid=3175
write: io=6292.0KB, bw=644171 B/s, iops=157 , runt= 10002msec
slat (usec): min=19 , max=2541 , avg=31.14, stdev=87.38
clat (usec): min=930 , max=363913 , avg=25418.95, stdev=65537.73
lat (usec): min=982 , max=363937 , avg=25451.64, stdev=65539.80
clat percentiles (usec):
| 1.00th=[ 1528], 5.00th=[ 1848], 10.00th=[ 1976], 20.00th=[ 2096],
| 30.00th=[ 2512], 40.00th=[ 2576], 50.00th=[ 2640], 60.00th=[ 2672],
| 70.00th=[ 2736], 80.00th=[ 5088], 90.00th=[85504], 95.00th=[201728],
| 99.00th=[301056], 99.50th=[358400], 99.90th=[362496]
bw (KB/s) : min= 59, max= 2461, per=23.90%, avg=614.69, stdev=842.19
lat (usec) : 1000=0.25%
lat (msec) : 2=12.52%, 4=65.54%, 10=7.31%, 20=0.51%, 50=1.27%
lat (msec) : 100=2.80%, 250=8.14%, 500=1.53%
cpu : usr=0.00%, sys=0.70%, ctx=979, majf=0, minf=0
IO depths : 1=0.1%, 2=0.1%, 4=99.8%, 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=0/d=0, short=r=1573/w=0/d=0
rand-write: (groupid=0, jobs=1): err= 0: pid=3176
write: io=19448KB, bw=1943.5KB/s, iops=485 , runt= 10007msec
slat (usec): min=25 , max=11898 , avg=38.54, stdev=199.11
clat (msec): min=1 , max=528 , avg= 8.11, stdev=28.98
lat (msec): min=1 , max=529 , avg= 8.15, stdev=29.01
clat percentiles (usec):
| 1.00th=[ 1768], 5.00th=[ 1880], 10.00th=[ 1992], 20.00th=[ 2832],
| 30.00th=[ 3024], 40.00th=[ 3760], 50.00th=[ 3920], 60.00th=[ 4448],
| 70.00th=[ 4960], 80.00th=[ 5792], 90.00th=[ 7264], 95.00th=[ 9408],
| 99.00th=[132096], 99.50th=[199680], 99.90th=[333824]
bw (KB/s) : min= 304, max= 3224, per=76.42%, avg=1965.53, stdev=703.11
lat (msec) : 2=10.12%, 4=42.78%, 10=42.68%, 20=1.81%, 50=0.31%
lat (msec) : 100=0.41%, 250=1.44%, 500=0.33%, 750=0.08%
cpu : usr=0.80%, sys=2.10%, ctx=5483, majf=0, minf=0
IO depths : 1=0.1%, 2=0.1%, 4=99.9%, 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=0/d=0, short=r=4862/w=0/d=0
Run status group 0 (all jobs):
READ: io=34832KB, aggrb=3479KB/s, minb=698KB/s, maxb=2865KB/s, mint=10002msec, maxt=10010msec
WRITE: io=25740KB, aggrb=2572KB/s, minb=644KB/s, maxb=1990KB/s, mint=10002msec, maxt=10007msec
Disk stats (read/write):
mmcblk0: ios=7507/5461, merge=1026/787, ticks=50880/49690, in_queue=101230, util=99.10%