io系统的压力测试工具-fio

author:skate
time:2012/04/11

 

io系统的压力测试工具-fio

 

fio是一个非常灵活的io测试工具,他可以通过多线程或进程模拟各种io操作

随着块设备的发展,特别是SSD盘的出现,设备的并行度越来越高。要想利用好这些设备,有个诀窍就是提高设备的iodepth, 一次喂给设备更多的IO请求,让电梯算法和设备有机会来安排合并以及内部并行处理,提高总体效率。

应用程序使用IO通常有二种方式:同步和异步。 同步的IO一次只能发出一个IO请求,等待内核完成才返回,这样对于单个线程iodepth总是小于1,但是可以通过多个线程并发执行来解决,通常我们会用16-32个线程同时工作把iodepth塞满。 异步的话就是用类似libaio这样的linux native aio一次提交一批,然后等待一批的完成,减少交互的次数,会更有效率。

io队列深度通常对不同的设备很敏感,那么如何用fio来探测出合理的值呢?在fio的帮助文档里是如何解释iodepth相关参数的

iodepth=int
iodepth_batch=int
iodepth_batch_complete=int
iodepth_low=int
fsync=int
direct=bool

这几个参数在libaio的引擎下的作用,会用iodepth值来调用io_setup准备一个可以一次提交iodepth个IO的上下文,同时申请一个io请求队列用于保持IO。 在压测进行的时候,系统会生成特定的IO请求,往io请求队列里面扔,当队列里面的IO数量达到iodepth_batch值的时候,就调用io_submit批次提交请求,然后开始调用io_getevents开始收割已经完成的IO。 每次收割多少呢?由于收割的时候,超时时间设置为0,所以有多少已完成就算多少,最多可以收割iodepth_batch_complete值个。随着收割,IO队列里面的IO数就少了,那么需要补充新的IO。 什么时候补充呢?当IO数目降到iodepth_low值的时候,就重新填充,保证OS可以看到至少iodepth_low数目的io在电梯口排队着。

 

下载
[root@vmforDB05 tmp]# wget ftp://ftp.univie.ac.at/systems/linux/dag/redhat/el5/en/x86_64/dag/RPMS/fio-2.0.6-1.el5.rf.x86_64.rpm

安装
[root@vmforDB05 tmp]# rpm -ivh fio-2.0.6-1.el5.rf.x86_64.rpm

 

测试下
[root@vmforDB05 ~]# fio -filename=/dev/mapper/cachedev  -direct=1 -rw=randread -bs=8k -size 1G -numjobs=8 -runtime=30 -group_reporting -name=file
file: (g=0): rw=randread, bs=8K-8K/8K-8K, ioengine=sync, iodepth=1
...
file: (g=0): rw=randread, bs=8K-8K/8K-8K, ioengine=sync, iodepth=1
fio 2.0.6
Starting 8 processes
Jobs: 1 (f=1): [____r___] [13.2% done] [200K/0K /s] [24 /0  iops] [eta 03m:30s]
file: (groupid=0, jobs=8): err= 0: pid=22052
  read : io=4632.0KB, bw=156907 B/s, iops=19 , runt= 30229msec
    clat (usec): min=168 , max=1585.8K, avg=409213.69, stdev=234820.76
     lat (usec): min=169 , max=1585.8K, avg=409214.35, stdev=234820.77
    clat percentiles (msec):
     |  1.00th=[   28],  5.00th=[   61], 10.00th=[  114], 20.00th=[  200],
     | 30.00th=[  273], 40.00th=[  334], 50.00th=[  392], 60.00th=[  445],
     | 70.00th=[  510], 80.00th=[  578], 90.00th=[  717], 95.00th=[  816],
     | 99.00th=[ 1057], 99.50th=[ 1221], 99.90th=[ 1582], 99.95th=[ 1582],
     | 99.99th=[ 1582]
    bw (KB/s)  : min=    4, max=  202, per=12.72%, avg=19.46, stdev=13.99
    lat (usec) : 250=0.17%
    lat (msec) : 50=4.15%, 100=4.84%, 250=16.58%, 500=42.14%, 750=24.18%
    lat (msec) : 1000=6.56%, 2000=1.38%
  cpu          : usr=0.03%, sys=0.09%, ctx=1102, majf=0, minf=244
  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=579/w=0/d=0, short=r=0/w=0/d=0

Run status group 0 (all jobs):
   READ: io=4632KB, aggrb=153KB/s, minb=156KB/s, maxb=156KB/s, mint=30229msec, maxt=30229msec

Disk stats (read/write):
    dm-0: ios=578/0, merge=0/0, ticks=169684/0, in_queue=169733, util=98.95%, aggrios=0/0, aggrmerge=0/0, aggrticks=0/0, aggrin_queue=0, aggrutil=0.00%
  loop0: ios=0/0, merge=0/0, ticks=0/0, in_queue=0, util=0.00%
  loop1: ios=0/0, merge=0/0, ticks=0/0, in_queue=0, util=0.00%
[root@vmforDB05 ~]#

 


fio可以通过配置文件来配置压力测试的方式,可以用选项 --debug=io来检测fio是否工作

[root@vmforDB05 tmp]# cat fio_test
[global] 
bsrange=512-2048 
ioengine=libaio 
userspace_reap 
rw=randrw 
rwmixwrite=20 
time_based 
runtime=180 
direct=1 
group_reporting 
randrepeat=0 
norandommap 
ramp_time=6 
iodepth=16 
iodepth_batch=8 
iodepth_low=8 
iodepth_batch_complete=8 
exitall 
[test] 
filename=/dev/mapper/cachedev 
numjobs=1

常用参数说明
bsrange=512-2048  //数据块的大小范围,从512bytes到2048 bytes
ioengine=libaio        //指定io引擎
userspace_reap      //配合libaio,提高异步io的收割速度
rw=randrw                //混合随机对写io,默认读写比例5:5
rwmixwrite=20         //在混合读写的模式下,写占20%
time_based             //在runtime压力测试周期内,如果规定数据量测试完,要重复测试 
runtime=180            //在180秒,压力测试将终止
direct=1                    //设置非缓冲io
group_reporting      //如果设置了多任务参数numjobs,用每组报告代替每job报告
randrepeat=0         //设置产生的随机数是不可重复的
norandommap 
ramp_time=6 
iodepth=16 
iodepth_batch=8 
iodepth_low=8 
iodepth_batch_complete=8 
exitall                                                     //一个job完成,就停止所有的
filename=/dev/mapper/cachedev    //压力测试的文件名
numjobs=1                                         //job的默认数量,也就是并发数,默认是1
size=200G                                          //这job总共的io大小
refill_buffers                                      //每次提交后都重复填充io buffer
overwrite=1                                       //设置文件可覆盖
sync=1                                              //设置异步io
fsync=1                                             //一个io就同步数据
invalidate=1                                   //开始io之前就失效buffer-cache
directory=/your_dir                        // fielname参数值的前缀
thinktime=600                              //在发布io前等待600秒
thinktime_spin=200    //消费cpu的时间,thinktime的剩余时间sleep
thinktime_blocks=2    //在thinktime之前发布的block数量

bssplit=4k/30:8k/40:16k/30            //随机读4k文件占30%、8k占40%、16k占30%
rwmixread=70                                                         //读占70% 

-------end-------

 

 

  • 0
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值