简介: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下地使用。
下载地址:http://freecode.com/projects/fio
依赖包:libaio-dev
安装:下载解压后具体安装过程详见README,其实只要make, make install即可;
安装过程如果报错请安装依赖包:sudo apt-get install libaio-dev。
使用:这个工具的可定制性非常强,可以根据测试者的想法进行各种混合io的测试。使用方法主要有两种形式,一种是命令形式,即fio [-options];另一种则是fio + 负载说明文件形式,下面我们来具体看两个例子。
1. 命令形式
fio –filename=/dev/sda1 –direct=1 –rw=randread –bs=4k –size=60G –numjobs=64 –runtime=10 –group_reporting –name=test
各参数含义可通过man fio查询得到,这里只简单说明几个:
filename:待测试的设备名或挂载文件名
direct:绕过OS的文件系统缓冲区测试
rw:指定读写模式,这里是测随机读性能
bs:每次请求的IO大小
size:测试的目标区域大小
name:本次测试任务的名字,随便取
2.负载说明文件形式:先生成一个负载说明文件,再通过fio 负载文件名方式执行
安装后,安装目录下有个examples文件夹,下面已有现成的一些例子,这里举个测试SSD“四项全能”性能的例子:
[文件名:SSD-test]
# drives are usually separated from the good drives.
#
# This uses a queue depth of 4. New SATA SSD's will support up to 32
# in flight commands, so it may also be interesting to increase the queue
# depth and compare. Note that most real-life usage will not see that
# large of a queue depth, so 4 is more representative of normal use.
#
[global]
bs=4k
ioengine=libaio
iodepth=4
size=1g
direct=1
runtime=60
directory=/mount-point-of-ssd
filename=ssd.test.file
[seq-read]
rw=read
stonewall
[rand-read]
rw=randread
stonewall
[seq-write]
rw=write
stonewall
[rand-write]
rw=randwrite
stonewall
测试结果如下:
seq-read: (g=0): rw=read, bs=1M-1M/1M-1M/1M-1M, ioengine=libaio, iodepth=4
rand-read: (g=1): rw=randread, bs=1M-1M/1M-1M/1M-1M, ioengine=libaio, iodepth=4
seq-write: (g=2): rw=write, bs=1M-1M/1M-1M/1M-1M, ioengine=libaio, iodepth=4
rand-write: (g=3): rw=randwrite, bs=1M-1M/1M-1M/1M-1M, ioengine=libaio, iodepth=4
fio-2.0.10
Starting 4 processes
seq-read: Laying out IO file(s) (1 file(s) / 1024MB)
seq-read(顺序读性能): (groupid=0, jobs=1): err= 0: pid=2460: Thu Nov 1 21:15:52 2012
read : io(测试了1G的数据)=1024.0MB, bw(带宽)=139643KB/s, iops(每秒钟的IO数)=136 , runt(总运行时间)= 7509msec
slat (usec): min=71 , max=814 , avg=95.42, stdev=42.51
clat (msec): min=8 , max=43 , avg=29.20, stdev= 1.16
lat (msec): min=9 , max=43 , avg=29.30, stdev= 1.14
clat percentiles (usec):
| 1.00th=[28288], 5.00th=[29056], 10.00th=[29056], 20.00th=[29056],
| 30.00th=[29056], 40.00th=[29312], 50.00th=[29312], 60.00th=[29312],
| 70.00th=[29312], 80.00th=[29312], 90.00th=[29312], 95.00th=[29312],
| 99.00th=[31872], 99.50th=[36608], 99.90th=[36608], 99.95th=[43776],
| 99.99th=[43776]
bw (KB/s) : min=137885, max=139912, per=100.00%, avg=139767.21, stdev=541.74
lat (msec) : 10=0.10%, 20=0.10%, 50=99.80%
cpu : usr=0.11%, sys=1.55%, ctx=1050, majf=0, minf=0
IO depths : 1=0.1%, 2=0.2%, 4=99.7%, 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=1024/w=0/d=0, short=r=0/w=0/d=0
rand-read(随机读性能): (groupid=1, jobs=1): err= 0: pid=2461: Thu Nov 1 21:15:52 2012
read : io=1024.0MB, bw=139624KB/s, iops=136 , runt= 7510msec
slat (usec): min=69 , max=750 , avg=87.59, stdev=41.23
clat (msec): min=8 , max=43 , avg=29.21, stdev= 1.19
lat (msec): min=9 , max=43 , avg=29.30, stdev= 1.17
clat percentiles (usec):
| 1.00th=[25728], 5.00th=[29056], 10.00th=[29056], 20.00th=[29056],
| 30.00th=[29056], 40.00th=[29312], 50.00th=[29312], 60.00th=[29312],
| 70.00th=[29312], 80.00th=[29312], 90.00th=[29312], 95.00th=[29312],
| 99.00th=[33024], 99.50th=[36608], 99.90th=[37120], 99.95th=[43776],
| 99.99th=[43776]
bw (KB/s) : min=137612, max=139912, per=100.00%, avg=139747.71, stdev=614.70
lat (msec) : 10=0.10%, 20=0.10%, 50=99.80%
cpu : usr=0.21%, sys=1.39%, ctx=1042, majf=0, minf=0
IO depths : 1=0.1%, 2=0.2%, 4=99.7%, 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=1024/w=0/d=0, short=r=0/w=0/d=0
seq-write(顺序写性能): (groupid=2, jobs=1): err= 0: pid=2462: Thu Nov 1 21:15:52 2012
write: io=1024.0MB, bw=124593KB/s, iops=121 , runt= 8416msec
slat (usec): min=91 , max=218 , avg=121.47, stdev=16.35
clat (msec): min=9 , max=123 , avg=32.73, stdev= 7.10
lat (msec): min=9 , max=123 , avg=32.85, stdev= 7.10
clat percentiles (msec):
| 1.00th=[ 29], 5.00th=[ 30], 10.00th=[ 30], 20.00th=[ 30],
| 30.00th=[ 30], 40.00th=[ 30], 50.00th=[ 31], 60.00th=[ 31],
| 70.00th=[ 33], 80.00th=[ 36], 90.00th=[ 41], 95.00th=[ 42],
| 99.00th=[ 45], 99.50th=[ 47], 99.90th=[ 124], 99.95th=[ 124],
| 99.99th=[ 124]
bw (KB/s) : min=102400, max=136669, per=99.68%, avg=124194.63, stdev=14056.58
lat (msec) : 10=0.10%, 20=0.10%, 50=99.41%, 250=0.39%
cpu : usr=0.57%, sys=1.24%, ctx=1066, majf=0, minf=0
IO depths : 1=0.1%, 2=0.2%, 4=99.7%, 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=1024, short=r=0/w=0/d=0
rand-write(随机写性能): (groupid=3, jobs=1): err= 0: pid=2463: Thu Nov 1 21:15:52 2012
write: io=1024.0MB, bw=101351KB/s, iops=98 , runt= 10346msec
slat (usec): min=90 , max=217 , avg=121.88, stdev=11.10
clat (msec): min=7 , max=152 , avg=40.26, stdev=12.33
lat (msec): min=7 , max=152 , avg=40.38, stdev=12.33
clat percentiles (msec):
| 1.00th=[ 29], 5.00th=[ 33], 10.00th=[ 34], 20.00th=[ 36],
| 30.00th=[ 38], 40.00th=[ 39], 50.00th=[ 40], 60.00th=[ 40],
| 70.00th=[ 41], 80.00th=[ 42], 90.00th=[ 44], 95.00th=[ 48],
| 99.00th=[ 128], 99.50th=[ 133], 99.90th=[ 139], 99.95th=[ 153],
| 99.99th=[ 153]
bw (KB/s) : min=64887, max=108544, per=99.84%, avg=101187.60, stdev=9916.67
lat (msec) : 10=0.10%, 20=0.10%, 50=96.48%, 100=1.76%, 250=1.56%
cpu : usr=0.70%, sys=0.81%, ctx=1058, majf=0, minf=0
IO depths : 1=0.1%, 2=0.2%, 4=99.7%, 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=1024, short=r=0/w=0/d=0
Run status group 0 (all jobs):
READ: io=1024.0MB, aggrb=139642KB/s, minb=139642KB/s, maxb=139642KB/s, mint=7509msec, maxt=7509msec
Run status group 1 (all jobs):
READ: io=1024.0MB, aggrb=139623KB/s, minb=139623KB/s, maxb=139623KB/s, mint=7510msec, maxt=7510msec
Run status group 2 (all jobs):
WRITE: io=1024.0MB, aggrb=124593KB/s, minb=124593KB/s, maxb=124593KB/s, mint=8416msec, maxt=8416msec
Run status group 3 (all jobs):
WRITE: io=1024.0MB, aggrb=101350KB/s, minb=101350KB/s, maxb=101350KB/s, mint=10346msec, maxt=10346msec
Disk stats (read/write):
sdb: ios=4640/4587, merge=5110/5070, ticks=124524/153520, in_queue=278152, util=97.17%
原文地址:http://blog.sina.com.cn/s/blog_4485748101019r72.html