FIO – IO压力测试工具 您所在的位置:网站首页 fio工具下载 FIO – IO压力测试工具

FIO – IO压力测试工具

2023-11-17 23:10| 来源: 网络整理| 查看: 265

        《存储工具系列文章》主要介绍存储相关的测试和调试工具,包括不限于dd、fio、vdbench、iozone、iometer、cosbench等性能负载工具,及strace等调试工具。

1. 概述

        IO是一个 I/O 工具,旨在用于基准测试和压力/硬件验证。它支持 19 种不同类型的I/O引擎(sync、mmap、libaio、posixaio、SG v3、splice、null、network、syslet、guasi、solarisaio 等)、I/O 优先级(适用于较新的Linux内核)、评估 I/O、分叉或线程作业等等。它可以在块设备和文件上工作。fio 接受简单易懂的文本格式的职位描述。包括几个示例作业文件。FIO显示各种 I/O 性能信息,包括完整的IO延迟和百分位数。Fio在许多地方被广泛使用,用于基准测试、QA 和验证目的。它支持 Linux、FreeBSD、NetBSD、OpenBSD、OS X、OpenSolaris、AIX、HP-UX、Android 和 Windows。

        目前主流的第三方IO测试工具有fio、iometer 和 Orion,这三种工具各有千秋,在linux 下也可以使用dd 进行简单的磁盘(文件系统)测试(文末补充)。

        Fio在Linux系统下使用比较方便,iometer在window系统下使用比较方便,Orion是oracle的IO测试软件,可在没有安装oracle数据库的情况下模拟oracle数据库场景的读写。

FIO 是一个多线程IO生成工具,可以生成多种IO模式,用来测试磁盘设备的性能(也包含文件系统:如针对网络文件系统 NFS 的IO测试)。

        FIO是一个开源的I/O压力测试工具,主要是用来测试磁盘/SSD的IO性能,也可测试cpu,nic的IO性能。它可以支持13种不同的I/O引擎,包括:sync,mmap, libaio, posixaio, SG v3, splice, network, syslet, guasi, solarisaio, I/Opriorities (针对新的Linux内核), rate I/O, forked or threaded jobs等。

        Github地址:https://github.com/axboe/fio

2. 安装部署 2.1 软件包安装

        第一步:查询fio所属软件包

[root@node1 fio]# yum provide fio Loaded plugins: fastestmirror No such command: provide. Please use /usr/bin/yum --help [root@node1 fio]# yum provides fio Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.lzu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn fio-3.7-2.el7.x86_64 : Multithreaded IO generation tool Repo : base [root@node1 fio]# yum info fio Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.lzu.edu.cn * extras: ftp.sjtu.edu.cn * updates: ftp.sjtu.edu.cn Available Packages Name : fio Arch : x86_64 Version : 3.7 Release : 2.el7 Size : 467 k Repo : base/7/x86_64 Summary : Multithreaded IO generation tool URL : http://git.kernel.dk/?p=fio.git;a=summary License : GPLv2 Description : fio is an I/O tool that will spawn a number of threads or processes doing : a particular type of io action as specified by the user. fio takes a : number of global parameters, each inherited by the thread unless : otherwise parameters given to them overriding that setting is given. : The typical use of fio is to write a job file matching the io load : one wants to simulate. [root@node1 fio]#

第二包:安装

[root@node1 fio]# yum install fio -y 2.2 源码包安装

第一步:根据实际情况安装依赖包 

[root@node1 fio]# yum -y install  libaio-devel  libaio-dev libaio* zilb*

第二部:下载源码:https://git.kernel.org/pub/scm/linux/kernel/git/axboe/fio.git/

[root@node1 fio]# wget http://git.kernel.org/pub/scm/linux/kernel/git/axboe/fio.git/snapshot/fio-3.30.tar.gz --no-check-certificate

解压源码

[root@node1 fio]# tar  -zxvf fio-3.30.tar.gz

第三步:编译安装

[root@node1 fio-3.30]# ./configure;

确保此处不报错,如果缺少依赖包,则根据情况安装。

[root@node1 fio-3.30]# make;make install;

第四步:检查是否安装成功 

[root@node1 fio-3.30]# fio -v fio-3.29 3  配置参数介绍

        Fio提供了非常多的配置参数。

参数名称

释义

filename

待测试的文件或块设备。

若为文件,则代表测试文件系统的性能;例:-filename=/work/fstest/fio.img

若为块设备,则代表测试裸设备的性能; 例:-filename=/dev/sdb1

ioengine

IO引擎

fio支持多种引擎如:cpuio、mmap、sync、psync、vsync、pvsync、pvsync2、null、net、netsplice、ftruncate、filecreate、libaio、posixaio、falloc、e4defrag、splice、rados、rbd、mtd、sg、io_uring

direct

当前测试是否采用直接IO方式进行读写,如果采用直接IO,则取值-direct=1,否则取值-direct=0。

采用直接IO写测试,会使得测试结果更加真实。

rw

读写模式。

read:顺序读测试,使用方式-rw=read

write:顺序写测试,使用方式-rw=write

randread:随机读测试,使用方式-rw=randread

randwrite:随机写测试,使用方式-rw=randwrite

randrw:随机读写,-rw=randrw;默认比率为5:5,通过参数-rwmixread设定读的比率,如-rw=randrw-rwmixread=70,说明读写比率为70:30。或rwmixwrite

bs

单次IO的大小;例:-bs=4k

bssplit

设备读写访问的IO大小,例:-bssplit=4k/30:8k/40:16k/30,随机读4k文件占30%、8k占40%、16k占30%

bsrange

设置IO大小的范围,例如-bsrange=512-2048

size

本次测试文件的大小;例-size=1G

iodepth

IO队列深入,即一次下发的IO的个数,例如:-iodepth=16

numjobs

测试进程的并发数,默认为,例:-numjobs=16

sync

设置同步模式,同步-sync=1,异步-sync=0

fsync

设置数据同步模式,同步-fsync=1,异步-fsync=0

runtime

设置测试运行的时间,单位秒,例:-runtime=300

group_reporting

关于显示结果的,汇总每个进程的信息

lockmem

对测试所使用的内存进行限制,如-lockmem=1g,限制1G

关于ioengine,  采用的文件读写方式

sync:采用read,write,使用fseek定位读写位置。psync:采用pread、pwrite进行文件读写操作vsync:采用readv(2) orwritev(2)进行文件读写操作,

libaio:Linux异步读写IO(Linuxnative asynchronous I/O)

posixaio: glibc POSIX 异步IO读写,使用aio_read(3)and aio_write(3)实现IO读写。

注:

       read()和write()系统调用每次在文件和进程的地址空间之间传送一块连续的数据。但是,应用有时也需要将分散在内存多处地方的数据连续写到文件中,或者反之。在这种情况下,如果要从文件中读一片连续的数据至进程的不同区域,使用read()则要么一次将它们读至一个较大的缓冲区中,然后将它们分成若干部分复制到不同的区域,要么调用read()若干次分批将它们读至不同区域。同样,如果想将程序中不同区域的数据块连续地写至文件,也必须进行类似的处理。UNIX提供了另外两个函数—readv()和writev(),它们只需一次系统调用就可以实现在文件和进程的多个缓冲区之间传送数据,免除了多次系统调用或复制数据的开销。readv()称为散布读,即将文件中若干连续的数据块读入内存分散的缓冲区中。writev()称为聚集写,即收集内存中分散的若干缓冲区中的数据写至文件的连续区域中。

4. 测试案例

测试命令如下:

[root@node0 fio-3.30]#  fio -filename=/work/fstest/fio.img  -direct=1 -rw=randread -bs=8k -size=1G-numjobs=16 -runtime=60 -group_reporting -name=fio_test

磁盘读写常用测试点:

1. Read=100% Ramdon=100% rw=randread (100%随机读)

2. Read=100% Sequence=100% rw=read (100%顺序读)

3. Write=100% Sequence=100% rw=write (100%顺序写)

4. Write=100% Ramdon=100% rw=randwrite (100%随机写)

5. Read=70% Sequence=100% rw=rw, rwmixread=70, rwmixwrite=30  (70%顺序读,30%顺序写)

6. Read=70% Ramdon=100% rw=randrw, rwmixread=70, rwmixwrite=30 (70%随机读,30%随机写)

测试过程中

fio_test: (g=0): rw=randread,bs=8K-8K/8K-8K/8K-8K, ioengine=psync, iodepth=1 ... fio-3.30 Starting 16 processes Jobs: 16 (f=16): [r(16)] [18.0% done][1840KB/0KB/0KB /s] [230/0/0 iops] [eta 00m:50s]

第一行:当前测试为随机读(randread),IO块大小,文件读写方式psync,IO队列深度为1, 第二行:fio的版本号 第三行:说明任务的并发数 第四行:任务并发数,进度,剩余测试时间。

5 . 测试结果解析 [root@node0 fio-3.30]# fio -filename=/dev/sdb -direct=1 -ioengine=libaio -bs=4k -size=5G -numjobs=10 -iodepth=16 -runtime=60 -thread -rw=randrw -rwmixread=70 -group_reporting -name="local_randrw_test" local_randrw_test: (g=0): rw=randrw, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=16 ... fio-3.10 Starting 10 threads Jobs: 10 (f=10): [m(10)][100.0%][r=19.4MiB/s,w=8456KiB/s][r=4969,w=2114 IOPS][eta 00m:00s] local_randrw_test: (groupid=0, jobs=10): err= 0: pid=11189: Mon Oct 25 11:01:46 2021    read: IOPS=5230, BW=20.4MiB/s (21.4MB/s)(1226MiB/60031msec)     slat (usec): min=2, max=342637, avg=1266.82, stdev=7241.29     clat (usec): min=4, max=459544, avg=20056.81, stdev=24888.90      lat (usec): min=134, max=459586, avg=21329.16, stdev=25378.16     clat percentiles (usec):      |  1.00th=[  1467],  5.00th=[  1844], 10.00th=[  2147], 20.00th=[  2606],      | 30.00th=[  3032], 40.00th=[  3556], 50.00th=[  4359], 60.00th=[  6063],      | 70.00th=[ 36439], 80.00th=[ 46924], 90.00th=[ 51643], 95.00th=[ 59507],      | 99.00th=[105382], 99.50th=[117965], 99.90th=[137364], 99.95th=[152044],      | 99.99th=[219153]    bw (  KiB/s): min=  795, max= 4494, per=9.91%, avg=2072.23, stdev=744.04, samples=1195    iops        : min=  198, max= 1123, avg=517.74, stdev=186.00, samples=1195   write: IOPS=2243, BW=8972KiB/s (9188kB/s)(526MiB/60031msec)     slat (usec): min=2, max=311932, avg=1272.76, stdev=7272.09     clat (usec): min=6, max=458031, avg=20206.30, stdev=24897.71      lat (usec): min=974, max=459755, avg=21484.12, stdev=25400.41     clat percentiles (usec):      |  1.00th=[  1500],  5.00th=[  1860], 10.00th=[  2147], 20.00th=[  2606],      | 30.00th=[  3064], 40.00th=[  3621], 50.00th=[  4424], 60.00th=[  6194],      | 70.00th=[ 36439], 80.00th=[ 46924], 90.00th=[ 51643], 95.00th=[ 59507],      | 99.00th=[105382], 99.50th=[117965], 99.90th=[137364], 99.95th=[149947],      | 99.99th=[200279]    bw (  KiB/s): min=  357, max= 1944, per=9.90%, avg=888.57, stdev=325.49, samples=1195    iops        : min=   89, max=  486, avg=221.80, stdev=81.37, samples=1195   lat (usec)   : 10=0.01%, 50=0.01%, 100=0.01%, 250=0.02%, 500=0.01%   lat (usec)   : 750=0.01%, 1000=0.01%   lat (msec)   : 2=7.45%, 4=38.36%, 10=18.10%, 20=1.09%, 50=22.31%   lat (msec)   : 100=11.42%, 250=1.24%, 500=0.01%   cpu          : usr=0.26%, sys=19.41%, ctx=12026, majf=0, minf=18   IO depths    : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=100.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.1%, 32=0.0%, 64=0.0%, >=64=0.0%      issued rwts: total=313975,134655,0,0 short=0,0,0,0 dropped=0,0,0,0      latency   : target=0, window=0, percentile=100.00%, depth=16 Run status group 0 (all jobs):    READ: bw=20.4MiB/s (21.4MB/s), 20.4MiB/s-20.4MiB/s (21.4MB/s-21.4MB/s), io=1226MiB (1286MB), run=60031-60031msec   WRITE: bw=8972KiB/s (9188kB/s), 8972KiB/s-8972KiB/s (9188kB/s-9188kB/s), io=526MiB (552MB), run=60031-60031msec Disk stats (read/write):   sdb: ios=314008/134653, merge=0/0, ticks=189470/89778, in_queue=279286, util=99.75%

        下面是每个执行的数据方向的I/O统计数据信息的代表值含义

        read/write: 读/写的IO操作(还有一个trim没用过)

    salt: 提交延迟,这是提交I/O所花费的时间(min:最小值,max:最大值,avg:平均值,stdev:标准偏差)     chat: 完成延迟,表示从提交到完成I/O部分的时间     lat: 相应时间,表示从fio创建I/O单元到完成I/O操作的时间     bw: 带宽统计     iops: IOPS统计

lat(nsec/usec/msec): 

        I/O完成延迟的分布。这是从I/O离开fio到它完成的时间。与上面单独的读/写/修剪部分不同,这里和其余部分的数据适用于报告组的所有I/ o。10=0.01%意味着0.01%的I/O在250us以下完成。250=0.02%意味着0.02%的I/O需要10到250us才能完成。

cpu: cpu使用率

IO depths: I/O深度在作业生命周期中的分布

    IO submit: 在一个提交调用中提交了多少个I/O。每一个分录表示该数额及其以下,直到上一分录为止——例如,4=100%意味着我们每次提交0到4个I/O调用     IO complete: 和上边的submit一样,不过这个是完成了多少个     IO issued rwt: 发出的read/write/trim请求的数量,以及其中有多少请求被缩短或删除     IO latency: 满足指定延迟目标所需的I/O深度

下面是Run status group 0 (all jobs) 全部任务汇总信息的代表值含义:

bw: 总带宽以及最小和最大带宽

io: 该组中所有线程执行的累计I/O

run: 这组线程中最小和最长的运行时。

最后是Linux中特有的磁盘状态统计信息的代表值含义:

ios: 所有组的I/ o个数

merge: I/O调度器执行的总合并数

ticks: 使磁盘繁忙的滴答数(仅供参考,原文是Number of ticks we kept the disk busy)

in_queue: 在磁盘队列中花费的总时间

util: 磁盘利用率。值为100%意味着我们保留了磁盘,如果一直很忙,那么50%的时间磁盘就会闲置一半的时间

6. 参考资料

[01]https://juejin.cn/post/7090839375033925646  



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有