linux使用FIO测速硬盘的IOPS

作者:老刘 发布时间:April 25, 2018 分类:网络技术,学习笔记 阅读次数:120

为了了解硬盘的性能,我们经常需要检测硬盘的持续读写性能,包括4KB小文件的传输性能等等,结果显示可以分为两种,一种是MB/s的形式,另一种是iops形式。
linux可以使用FIO进行检测硬盘的性能

什么是FIO ?
FIO是测试IOPS的非常好的工具,用来对硬件进行压力测试和验证,支持13种不同的I/O引擎,包括:sync,mmap, libaio, posixaio, SG v3, splice, null, network, syslet, guasi, solarisaio 等等。

如何安装FIO?
centos可以直接

yum install fio -y

如果需要最新版,请到下面网站下载
https://github.com/axboe/fio

FIO测试命令例子

#随机读
fio -filename=/tmp/test_randread -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=4k -size=2G -numjobs=10 -runtime=60 -group_reporting -name=mytest
#顺序读 
fio -filename=/tmp/test_read  -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=4k -size=2G -numjobs=10 -runtime=60 -group_reporting -name=mytest
#随机写 
fio -filename=/tmp/test_randwrite -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=4k -size=2G -numjobs=10 -runtime=60 -group_reporting -name=mytest
#顺序写 
fio -filename=/tmp/test_write  -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=4k -size=2G -numjobs=10 -runtime=60 -group_reporting -name=mytest
#混合读写
fio -filename=/tmp/test_mixrw -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=4k -size=2G -numjobs=10 -runtime=60 -group_reporting -name=mytest -ioscheduler=noop

FIO报表查看
主要查看 IOPS=4290, BW=16.8MiB/s

Starting 10 threads
mytest: Laying out IO file (1 file / 2048MiB)
Jobs: 10 (f=10): [m(10)][4.9%][r=39.1MiB/s,w=16.9MiB/s][r=10.0k,w=4318 IOPS][etaJobs: 10 (f=10): [m(10)][6.6%][r=39.1MiB/s,w=17.0MiB/s][r=10.0k,w=4352 IOPS][etaJobs: 10 (f=10): [m(10)][8.2%][r=39.1MiB/s,w=16.0MiB/s][r=10.0k,w=4339 IOPS][etaJobs: 10 (f=10): [m(10)][9.8%][r=39.1MiB/s,w=16.7MiB/s][r=10.0k,w=4274 IOPS][etaJobs: 10 (f=10): [m(10)][11.5%][r=39.1MiB/s,w=17.0MiB/s][r=10.0k,w=4358 IOPS][etJobs: 10 (f=10): [m(10)][13.1%][r=39.1MiB/s,w=16.7MiB/s][r=10.0k,w=4287 IOPS][etJobs: 10 (f=10): [m(10)][14.8%][r=39.1MiB/s,w=16.9MiB/s][r=10.0k,w=4314 IOPS][etJobs: 10 (f=10): [m(10)][16.4%][r=39.1MiB/s,w=16.3MiB/s][r=10.0k,w=4170 IOPS][etJobs: 10 (f=10): [m(10)][18.0%][r=39.1MiB/s,w=16.6MiB/s][r=10.0k,w=4246 IOPS][etJobs: 10 (f=10): [m(10)][19.7%][r=39.1MiB/s,w=16.6MiB/s][r=10.0k,w=4240 IOPS][etJobs: 10 (f=10): [m(10)][21.3%][r=39.1MiB/s,w=16.2MiB/s][r=10.0k,w=4135 IOPS][etJobs: 10 (f=10): [m(10)][23.0%][r=39.1MiB/s,w=16.8MiB/s][r=10.0k,w=4297 IOPS][etJobs: 10 (f=10): [m(10)][24.6%][r=39.1MiB/s,w=16.9MiB/s][r=10.0k,w=4339 IOPS][etJobs: 10 (f=10): [m(10)][26.2%][r=39.1MiB/s,w=17.2MiB/s][r=9997,w=4408 IOPS][etaJobs: 10 (f=10): [m(10)][27.9%][r=39.1MiB/s,w=16.8MiB/s][r=10.0k,w=4297 IOPS][etJobs: 10 (f=10): [m(10)][29.5%][r=39.1MiB/s,w=16.8MiB/s][r=10.0k,w=4288 IOPS][etJobs: 10 (f=10): [m(10)][31.1%][r=39.1MiB/s,w=16.8MiB/s][r=10.0k,w=4302 IOPS][etJobs: 10 (f=10): [m(10)][32.8%][r=39.1MiB/s,w=16.6MiB/s][r=10.0k,w=4253 IOPS][etJobs: 10 (f=10): [m(10)][34.4%][r=39.1MiB/s,w=16.7MiB/s][r=10.0k,w=4283 IOPS][etJobs: 10 (f=10): [m(10)][36.1%][r=39.1MiB/s,w=16.9MiB/s][r=10.0k,w=4315 IOPS][etJobs: 10 (f=10): [m(10)][37.7%][r=39.1MiB/s,w=16.8MiB/s][r=10.0k,w=4291 IOPS][etJobs: 10 (f=10): [m(10)][39.3%][r=39.1MiB/s,w=16.7MiB/s][r=10.0k,w=4276 IOPS][etJobs: 10 (f=10): [m(10)][41.0%][r=39.1MiB/s,w=17.1MiB/s][r=10.0k,w=4378 IOPS][etJobs: 10 (f=10): [m(10)][42.6%][r=39.1MiB/s,w=16.0MiB/s][r=10.0k,w=4346 IOPS][etJobs: 10 (f=10): [m(10)][44.3%][r=39.1MiB/s,w=16.7MiB/s][r=10.0k,w=4282 IOPS][etJobs: 10 (f=10): [m(10)][45.9%][r=39.1MiB/s,w=16.5MiB/s][r=10.0k,w=4229 IOPS][etJobs: 10 (f=10): [m(10)][47.5%][r=39.1MiB/s,w=16.5MiB/s][r=10.0k,w=4228 IOPS][etJobs: 10 (f=10): [m(10)][49.2%][r=39.1MiB/s,w=16.6MiB/s][r=10.0k,w=4246 IOPS][etJobs: 10 (f=10): [m(10)][50.8%][r=39.1MiB/s,w=16.9MiB/s][r=10.0k,w=4316 IOPS][etJobs: 10 (f=10): [m(10)][52.5%][r=39.1MiB/s,w=17.3MiB/s][r=10.0k,w=4428 IOPS][etJobs: 10 (f=10): [m(10)][54.1%][r=39.1MiB/s,w=16.8MiB/s][r=10.0k,w=4289 IOPS][etJobs: 10 (f=10): [m(10)][55.7%][r=39.1MiB/s,w=16.7MiB/s][r=10.0k,w=4267 IOPS][etJobs: 10 (f=10): [m(10)][57.4%][r=39.1MiB/s,w=16.0MiB/s][r=10.0k,w=4345 IOPS][etJobs: 10 (f=10): [m(10)][59.0%][r=39.1MiB/s,w=16.9MiB/s][r=10.0k,w=4320 IOPS][etJobs: 10 (f=10): [m(10)][60.7%][r=39.1MiB/s,w=16.3MiB/s][r=10.0k,w=4180 IOPS][etJobs: 10 (f=10): [m(10)][62.3%][r=39.1MiB/s,w=16.0MiB/s][r=10.0k,w=4342 IOPS][etJobs: 10 (f=10): [m(10)][63.9%][r=39.1MiB/s,w=16.7MiB/s][r=10.0k,w=4275 IOPS][etJobs: 10 (f=10): [m(10)][65.6%][r=39.1MiB/s,w=16.1MiB/s][r=10.0k,w=4120 IOPS][etJobs: 10 (f=10): [m(10)][67.2%][r=39.1MiB/s,w=16.9MiB/s][r=10.0k,w=4331 IOPS][etJobs: 10 (f=10): [m(10)][68.9%][r=39.1MiB/s,w=16.6MiB/s][r=10.0k,w=4253 IOPS][etJobs: 10 (f=10): [m(10)][70.5%][r=39.1MiB/s,w=16.0MiB/s][r=10.0k,w=4342 IOPS][etJobs: 10 (f=10): [m(10)][72.1%][r=39.1MiB/s,w=16.8MiB/s][r=10.0k,w=4299 IOPS][etJobs: 10 (f=10): [m(10)][73.8%][r=39.1MiB/s,w=16.5MiB/s][r=10.0k,w=4230 IOPS][etJobs: 10 (f=10): [m(10)][75.4%][r=39.1MiB/s,w=16.8MiB/s][r=10.0k,w=4302 IOPS][etJobs: 10 (f=10): [m(10)][77.0%][r=38.0MiB/s,w=16.5MiB/s][r=9979,w=4225 IOPS][etaJobs: 10 (f=10): [m(10)][78.7%][r=39.2MiB/s,w=16.6MiB/s][r=10.0k,w=4242 IOPS][etJobs: 10 (f=10): [m(10)][80.3%][r=39.1MiB/s,w=16.7MiB/s][r=10.0k,w=4286 IOPS][etJobs: 10 (f=10): [m(10)][82.0%][r=39.1MiB/s,w=17.3MiB/s][r=10.0k,w=4441 IOPS][etJobs: 10 (f=10): [m(10)][83.6%][r=39.1MiB/s,w=17.2MiB/s][r=10.0k,w=4409 IOPS][etJobs: 10 (f=10): [m(10)][85.2%][r=39.1MiB/s,w=16.6MiB/s][r=10.0k,w=4240 IOPS][etJobs: 10 (f=10): [m(10)][86.9%][r=39.1MiB/s,w=16.2MiB/s][r=10.0k,w=4158 IOPS][etJobs: 10 (f=10): [m(10)][88.5%][r=39.1MiB/s,w=16.4MiB/s][r=10.0k,w=4211 IOPS][etJobs: 10 (f=10): [m(10)][90.2%][r=39.1MiB/s,w=16.0MiB/s][r=10.0k,w=4346 IOPS][etJobs: 10 (f=10): [m(10)][91.8%][r=39.1MiB/s,w=16.7MiB/s][r=10.0k,w=4263 IOPS][etJobs: 10 (f=10): [m(10)][93.4%][r=39.1MiB/s,w=16.5MiB/s][r=10.0k,w=4217 IOPS][etJobs: 10 (f=10): [m(10)][95.1%][r=39.1MiB/s,w=16.3MiB/s][r=10.0k,w=4163 IOPS][etJobs: 10 (f=10): [m(10)][96.7%][r=39.1MiB/s,w=16.4MiB/s][r=10.0k,w=4209 IOPS][etJobs: 10 (f=10): [m(10)][98.4%][r=39.1MiB/s,w=16.3MiB/s][r=10.0k,w=4185 IOPS][etJobs: 10 (f=10): [m(10)][100.0%][r=39.1MiB/s,w=16.9MiB/s][r=10.0k,w=4324 IOPS][eta 00m:00s]
mytest: (groupid=0, jobs=10): err= 0: pid=3662: Wed Apr 25 14:04:47 2018
read:IOPS=10.0k, BW=39.1MiB/s(41.0MB/s)(2348MiB/60002msec)
clat (usec): min=116, max=16613, avg=938.52, stdev=305.31
lat (usec): min=116, max=16613, avg=938.90, stdev=305.30
clat percentiles (usec):
| 1.00th=[ 210], 5.00th=[ 660], 10.00th=[ 783], 20.00th=[ 848],
| 30.00th=[ 889], 40.00th=[ 914], 50.00th=[ 938], 60.00th=[ 963],
| 70.00th=[ 988], 80.00th=[ 1020], 90.00th=[ 1057], 95.00th=[ 1106],
| 99.00th=[ 1876], 99.50th=[ 2376], 99.90th=[ 4293], 99.95th=[ 5473],
| 99.99th=[ 9372]
bw ( KiB/s): min= 3480, max= 4920, per=10.01%, avg=4009.44, stdev=96.97, samples=1197
iops : min= 870, max= 1230, avg=1002.25, stdev=24.31, samples=1197
write:IOPS=4290, BW=16.8MiB/s(17.6MB/s)(1006MiB/60002msec)
clat (usec): min=53, max=15199, avg=127.86, stdev=183.66
lat (usec): min=53, max=15200, avg=128.37, stdev=183.68
clat percentiles (usec):
| 1.00th=[ 75], 5.00th=[ 83], 10.00th=[ 89], 20.00th=[ 95],
| 30.00th=[ 99], 40.00th=[ 104], 50.00th=[ 110], 60.00th=[ 116],
| 70.00th=[ 123], 80.00th=[ 135], 90.00th=[ 157], 95.00th=[ 186],
| 99.00th=[ 343], 99.50th=[ 619], 99.90th=[ 3195], 99.95th=[ 3785],
| 99.99th=[ 6456]
bw ( KiB/s): min= 1240, max= 2264, per=10.01%, avg=1716.97, stdev=138.59, samples=1197
iops : min= 310, max= 566, avg=428.99, stdev=34.65, samples=1197
lat (usec) : 100=9.78%, 250=20.94%, 500=1.67%, 750=2.95%, 1000=46.40%
lat (msec) : 2=17.63%, 4=0.53%, 10=0.10%, 20=0.01%
cpu : usr=0.68%, sys=2.74%, ctx=861693, 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 rwt: total=601017,257412,0, short=0,0,0, dropped=0,0,0
latency : target=0, window=0, percentile=100.00%, depth=1

Run status group 0 (all jobs):
READ: bw=39.1MiB/s (41.0MB/s), 39.1MiB/s-39.1MiB/s (41.0MB/s-41.0MB/s), io=2348MiB (2462MB), run=60002-60002msec
WRITE: bw=16.8MiB/s (17.6MB/s), 16.8MiB/s-16.8MiB/s (17.6MB/s-17.6MB/s), io=1006MiB (1054MB), run=60002-60002msec

Disk stats (read/write):
sda: ios=600470/257168, merge=0/0, ticks=552440/26837, in_queue=579518, util=99.86%

标签: 压力测试, FIO, 硬盘

前一篇:解决使用WebRTC导致的真实IP泄漏

后一篇:PHP使用cURL替代file_get_contents函数

添加新评论 »