FIO 存储性能压测

article/2025/10/15 22:46:28

一、 FIO简介

FIO 是一个多线程IO生成工具,可以生成多种IO模式(随机、顺序、读、写四大类),用来测试磁盘设备的性能。GFIO是FIO的图形监测工具,它提供了图形界面的参数配置,和性能监测图像。

在github上的链接为 https://github.com/axboe/fio

二、 FIO安装

1. yum安装

yum -y install fio.x86_64

2. 源码安装

  • Best Open Source Mac Software Development Software 2023 下载FIO安装包 fio-2.1.10.tar.gz
  • 安装libaio-devel依赖包(如果是先编译了fioz,发现报错才装libaio-devel的,需要先用make clean清理编译文件后再重新编译安装FIO )
yum -y install libaio* gcc wget make
  • 安装gfio:基于gdk实现,是其图形界面版(可选)
yum -y install libgtk2.0-dev
  • 解压FIO压缩包,进入FIO目录编译安装
./configure --enable-gfio #如果希望不支持gfio,只需去掉后面的--enable-gfio参数
make
make install
  • 设置环境变量
vi .bash_profilePATH=$PATH:$HOME/bin:/usr/local/binsource .bash_profile

三、 常用参数

filename=/dev/emcpowerb 支持文件系统或者裸设备,-filename=/dev/sda2或-filename=/dev/sdb
direct=1                 测试过程绕过机器自带的buffer,使测试结果更真实
rw=randwread             测试随机读的I/O
rw=randwrite             测试随机写的I/O
rw=randrw                测试随机混合写和读的I/O
rw=read                  测试顺序读的I/O
rw=write                 测试顺序写的I/O
rw=rw                    测试顺序混合写和读的I/O
bs=4k                    单次io的块文件大小为4k
bsrange=512-2048         同上,提定数据块的大小范围
size=5g                  本次的测试文件大小为5g,以每次4k的io进行测试
numjobs=30               本次的测试线程为30
runtime=1000             测试时间为1000秒,如果不写则一直将5g文件分4k每次写完为止
ioengine=psync           io引擎使用pync方式,如果要使用libaio引擎,需要yum install libaio-devel包
rwmixwrite=30            在混合读写的模式下,写占30%
group_reporting          关于显示结果的,汇总每个进程的信息
此外
lockmem=1g               只使用1g内存进行测试
zero_buffers             用0初始化系统buffer
nrfiles=8                每个进程生成文件的数量

四、 常用测试场景

1. 命令行测试

  • 100%随机,100%读,4K
fio -filename=/dev/emcpowerb -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=4k -size=1000G -numjobs=50 -runtime=180 -group_reporting -name=rand_100read_4k
  • 100%随机,100%写,4K
fio -filename=/dev/emcpowerb -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=4k -size=1000G -numjobs=50 -runtime=180 -group_reporting -name=rand_100write_4k
  • 100%顺序,100%读,4K
fio -filename=/dev/emcpowerb -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=4k -size=1000G -numjobs=50 -runtime=180 -group_reporting -name=sqe_100read_4k
  • 100%顺序,100%写,4K
fio -filename=/dev/emcpowerb -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=4k -size=1000G -numjobs=50 -runtime=180 -group_reporting -name=sqe_100write_4k
  • 100%随机,70%读,30%写 4K
fio -filename=/dev/emcpowerb -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=4k -size=1000G -numjobs=50 -runtime=180 -group_reporting -name=randrw_70read_4k

2. 参数文件测试

FIO提供了不同场景的压测参数文件,修改其中配置然后直接执行即可。https://github.com/axboe/fio/tree/master/examples

fio examples/ssd-test.fio

上面这个参数文件用于测试ssd性能,参数文件内容如下:

其中每一个[]代表一个测试分组,会为每组分别进行测试(比如下面有5组)。

# Do some important numbers on SSD drives, to gauge what kind of
# performance you might get out of them.
#
# Sequential read and write speeds are tested, these are expected to be
# high. Random reads should also be fast, random writes are where crap
# 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=10g
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

下面是一个模拟MySQL数据库的压测配置文件

# QPS: 40000(10 cores)
# Dataset: 200G
# R/W: 8/2
# ThreadPool Num: 64
#  IO ThreadNum: 32[global]
runtime=86400
time_based
group_reporting
directory=/your_dir
ioscheduler=deadline
refill_buffers[mysql-binlog]
filename=test-mysql-bin.log
bsrange=512-1024
ioengine=sync
rw=write
size=24G
sync=1
rw=write
overwrite=1
fsync=100
rate_iops=64
invalidate=1
numjobs=64[innodb-data]
filename=test-innodb.dat
bs=16K
ioengine=psync
rw=randrw
size=200G
direct=1
rwmixread=80
numjobs=32thinktime=600
thinktime_spin=200
thinktime_blocks=2[innodb-trxlog]
filename=test-innodb.log
bsrange=512-2048
ioengine=sync
rw=write
size=2G
fsync=1
overwrite=1
rate_iops=64
invalidate=1
numjobs=64

五、 测试结果解读

测试输出结果如下

fio -ioengine=libaio -bs=4k -direct=1 -thread -rw=read -filename=/dev/sda -name="BS 4KB read test" -iodepth=16 -runtime=60#输出
BS 4KB read test: (g=0): rw=write, bs=1M-1M/1M-1M/1M-1M, ioengine=libaio, iodepth=16
fio-2.8
Starting 1 process
Jobs: 1 (f=1): [W(1)] [100.0% done] [0KB/68198KB/0KB /s] [0/66/0 iops] [eta 00m:00s]
test: (groupid=0, jobs=1): err= 0: pid=4676: Thu Apr  7 17:22:37 2016write: io=20075MB, bw=68464KB/s, iops=66, runt=300255msec           #执行多少IO,平均带宽,线程运行时间slat (usec): min=51, max=5732, avg=291.11, stdev=262.47           #提交延迟clat (usec): min=1, max=2235.8K, avg=239043.28, stdev=153384.41   #完成延迟lat (usec): min=367, max=2235.9K, avg=239337.72, stdev=153389.57 #响应时间clat percentiles (usec):|  1.00th=[  221],  5.00th=[  442], 10.00th=[ 1004], 20.00th=[108032],| 30.00th=[228352], 40.00th=[248832], 50.00th=[257024], 60.00th=[268288],| 70.00th=[280576], 80.00th=[301056], 90.00th=[342016], 95.00th=[477184],| 99.00th=[806912], 99.50th=[864256], 99.90th=[1122304], 99.95th=[1171456],| 99.99th=[1646592]bw (KB/s): min=  170, max=204800, per=100.00%, avg=68755.07, stdev=27034.84lat (usec) : 2=0.01%, 4=0.13%, 50=0.06%, 100=0.26%, 250=1.04%lat (usec) : 500=4.53%, 750=2.61%, 1000=1.33%lat (msec) : 2=1.18%, 4=0.15%, 10=0.77%, 20=0.77%, 50=1.50%lat (msec) : 100=4.43%, 250=23.48%, 500=53.23%, 750=3.09%, 1000=1.30%lat (msec) : 2000=0.19%, >=2000=0.01%cpu          : usr=0.03%, sys=2.11%, ctx=19066, majf=0, minf=7IO depths    : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=103.8%, 32=0.0%, >=64=0.0%   #io队列submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%  #单个IO提交要提交的IO数complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.1%, 32=0.0%, 64=0.0%, >=64=0.0%  issued    : total=r=0/w=20060/d=0, short=r=0/w=0/d=0, drop=r=0/w=0/d=0latency   : target=0, window=0, percentile=100.00%, depth=16    #IO完延迟的分布Run status group 0 (all jobs):WRITE: io=20075MB, aggrb=68464KB/s(group总带宽), minb=68464KB/s(最小平均带宽), maxb=68464KB/s(最大平均带宽), mint=300255msec(group中线程的最短运行时间), maxt=300255msec(group中线程的最长运行时间)Disk stats (read/write):sda: ios=23/41769(所有group总共执行的IO数), merge=0/149(总共发生的IO合并数), ticks=706/9102766(Number of ticks we kept the disk busy), in_queue=9105836(花费在队列上的总共时间), util=100.00%(磁盘利用率)

输出参数介绍(详情参考 Fio Output Explained)

  • io=执行了多少M的IO
  • bw=平均IO带宽(吞吐量)
  • iops=IOPS
  • runt=线程运行时间
  • slat=提交延迟,提交该IO请求到kernel所花的时间(不包括kernel处理的时间)
  • clat=完成延迟, 提交该IO请求到kernel后,处理所花的时间
  • lat=响应时间
  • bw=带宽
  • cpu=利用率
  • IO depths=io队列
  • IO submit=单个IO提交要提交的IO数
  • IO complete=Like the above submit number, but for completions instead.
  • IO issued=The number of read/write requests issued, and how many of them were short.
  • IO latencies=IO完延迟的分布
  • io=总共执行了多少size的IO
  • aggrb=group总带宽
  • minb=最小平均带宽
  • maxb=最大平均带宽
  • mint=group中线程的最短运行时间
  • maxt=group中线程的最长运行时间
  • ios=所有group总共执行的IO数
  • merge=总共发生的IO合并数
  • ticks=Number of ticks we kept the disk busy
  • io_queue=花费在队列上的总共时间
  • util=磁盘利用率

六、 测试建议

  • 使用顺序IO和较大的blocksize测试吞吐量和延迟
  • 使用随机IO和较小的blocksize测试IOPS和延迟
  • 在配置numjobs和iodeph前,建议深入了解应用采用的是同步IO还是异步IO(是多进程并发IO还是一次提交一批IO请求)

备注

  • 磁盘的 IOPS,也就是在一秒内,磁盘进行多少次 I/O 读写。
  • 磁盘的吞吐量,也就是每秒磁盘 I/O 的流量,即磁盘写入加上读出的数据的大小。
  • 每秒 I/O 吞吐量= IOPS* 平均 I/O SIZE。

七、 简单自动压测脚本

#!/bin/sh
# fiotest.sh
# bs=4k,1M  size=100M,1G  type=read,randread,write,randrw,rw  各压测三次,取平均值bs_list=(4k 1M)
size_list=(100M 1G)
type_list=(read randread write randrw rw)for v_bs in {0..1} #bs_list
dofor v_size in {0..1} #size_listdofor v_type in {0..4} #type_listdofor v_runtime in {0..2} #runtimedologfile=fio_${bs_list[$v_bs]}_${size_list[$v_size]}_${type_list[$v_type]}_$v_runtime.txtecho -e "test $v_runtime started\n" > $logfileecho -e "started time `date`\n" >> $logfilefio --filename=/data/testfile1 --direct=1 --bs=${bs_list[$v_bs]} --size=${size_list[$v_size]} --rw=${type_list[$v_type]} --ioengine=libaio --iodepth=128 --numjobs=1 --time_based --group_reporting --runtime=60 --name=$logfile >> $logfileecho -e "\nfinished time `date`" >> $logfileecho -e "\ntest $v_runtime finished" >> $logfilesleep 5done #runtimesleep 60done #type_listdone #size_listdone #bs_list

八、 输出结果解析命令

我们一般记录框里的值

读IO提交延迟

cat fio_* |grep -A 3 read |grep clat > read.tmp

写IO提交延迟

cat fio_* |grep -A 3 write |grep clat > write.tmp

带宽与iops

cat fio_* |grep bw|grep iops|grep read > r_iops.tmp

cat fio_* |grep bw|grep iops|grep write > w_iops.tmp

直方图信息(记录最大比例)

cat -n fio_* | grep 'lat (' | grep -v min > histos.tmp

参考

FIO使用说明_半遮雨的博客-CSDN博客_fio util结果100%

https://github.com/axboe/fio

IO测试工具之fio详解 - raykuan - 博客园

Fio模拟Mysql服务器IO压力脚本 | 系统技术非业余研究

磁盘性能评价指标—IOPS和吞吐量_风云龙儿的博客-CSDN博客_海波龙磁盘吞吐量多少


http://chatgpt.dhexx.cn/article/USE7Aa8E.shtml

相关文章

磁盘性能测试工具-FIO的安装及使用

文章目录 FIO介绍FIO安装在线安装离线安装 磁盘测试命令行方式测试结果说明命令参数说明配置文件方式 dd命令介绍使用方法 FIO介绍 FIO是一款测试IOPS的工具,用于对磁盘进行压力测试和验证,磁盘I/O是检查磁盘性能的重要指标,可以按照负载情况…

NuGet学习笔记(1)——初识NuGet及快速安装使用

http://kb.cnblogs.com/page/143190/ 1. NuGet是什么? NuGet is a Visual Studio 2010 extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects that use the .NET Framework. This topic lists documentation t…

Nuget路径问题

VS NetGet包管理器 问题场景: 装了两遍VS2019,第一次装D盘卸载了,然后装C盘,结果生成 .netCore项目时就悲剧了,报错:error MSB4018: “ResolvePackageAssets”任务意外失败。Microsoft.PackageDependencyResolution.t…

使用nuget 打包并上传 nuget.org

使用nuget 打包并上传 nuget.org 一、准备工作二、打包你的项目三、上传 nug.org 服务器 前言:今天又玩了个新东西,那就是 使用nuget 打包并上传 nuget.org,在这里即时记录一下,废话不多说,直接上教程。 一、准备工作…

nuget 的生成、发布、使用和更新

nuget 的生成、发布、使用和更新 一、nuget 的生成1.生成.dll1.1创建.net项目(类库)1.2 打包生成 .dll 2.打包成.nupkg文件2.1安装 [NuGetPackageExplorer.exe](https://github.com/NuGetPackageExplorer/NuGetPackageExplorer)程序2.2打开软件,完成打包…

修改NuGet包默认存放位置

默认情况下,NuGet下载的包存放在系统盘(C盘中),这样一来,时间长了下载的包越多,C盘占用的空间也就越多。 1、问题描述 默认情况下,NuGet下载的包存放在系统盘(C盘中,一般在路径C:\Users\用户\.nuget\packag…

Nuget使用简介

1.什么是Nuget Nuget是 ASP .NET Gallery 的一员。NuGet 是免费、开源的包管理开发工具,专注于在 .NET 应用开发过程中,简单地合并第三方的组件库。 当需要分享开发的工具或是库,需要建立一个Nuget package,然后把这个package放到…

Nuget的使用说明

在做项目的时候,经常需要添加一些第三方引用,Visual Studio 2019环境下,最推荐的是Nuget安装方式,好处就是可以将所有依赖的包全部打包下载安装。 1.nuget.org,搜索需要的nuget包,复制相应的安装命令&…

NuGet的了解

目录 1..NuGet 的使用目的 2..Net 的工具 NuGet 1.NuGet 包的下载 2.NuGet 包的分析 3.NuGet 的使用 1.通过命令行使用 2.在 visual studio 里通过图形化界面进行添加。 3.在添加包的时候 4.特点 1..NuGet 的使用目的 在引入第三方程序集(dll)的…

初识NuGet - 概念, 安装和使用

1. NuGet是什么? NuGet is a Visual Studio 2010 extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects that use the .NET Framework. This topic lists documentation that will help you use NuGet packages…

NuGet的介绍及使用

介绍 NuGet是什么? NuGet是.NET的软件包管理器。NuGet客户端工具提供了生成和使用软件包的功能。NuGet 是所有软件包作者和使用者都使用的中央软件包存储库。 下面是百度百科的介绍 在我看来NuGet类似于Java的Maven和Javascript的npm。 使用 1、通过图形化客户端安…

NuGet包介绍

前言 什么是NuGet? NuGet是.NET的软件包管理器。NuGet客户端工具提供了生成和使用软件包的功能。NuGet Gallery是所有软件包作者和使用者都使用的中央软件包存储库。 包的安装和卸载 (以Newtonsoft.Json举例) 1.控制台 安装:Install-Package Newtonsoft…

NuGet使用

1.创建类库方法 2.双击项目配置 <Project Sdk"Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>net6.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable><!--以下是…

NuGet学习

NuGet学习 文章目录 NuGet学习1.简介2.Visual Studio安装3.安装包3.1 打开NuGet3.2 搜索安装包 4.使用包 1.简介 NuGet包是一个zip文件&#xff0c;其中包含程序集&#xff08;或多个程序集&#xff09;、配置信息和PowerShell脚本。NuGet包可以从微软找到&#xff0c;也可以从…

什么是nuget?nuget包是如何管理

做windows开发的&#xff0c;迟早会接触到nuget这个东西&#xff0c;那么今天我们就来研究一下什么是nuget&#xff1f; 我们先从另外一些大家熟悉的概念入手&#xff0c;做linux的大家应该应该听说过apt-get&#xff0c;yum&#xff0c;deb等等&#xff0c;是的这些都是包管理…

NuGet包管理器

在.NET应用程序编程开发中&#xff0c;开发者通常使用类库来管理、维护属于同一分类的程序代码&#xff0c;以便代码的重用。一般情况下&#xff0c;处于同一类库的所有类都位于同一程序集。 这些类库被编译器编译后会生成扩展名为.dll的动态链接库文件&#xff0c;你可以在其…

VS Nuget的使用

目录 VS Nuget的使用 一、引言 二、认识Nuget 三、如何使用Nuget 1.常规使用 2.安装类库的历史版本 3.常见问题 4.离线安装nuget包 VS Nuget的使用 一、引言 最古老的时候我们想引用一个第三方类库&#xff0c;方法就是先下载第三方的dll文件&#xff0c;然后放置到我…

nuget使用教程

1.打开文件夹 E:\工具\PackageExplorer.4.4.72 双击 NyGetPackageExplorer.exe 文件。 2.点击Open a package from online feed 得到右图&#xff0c;输入自己的package source&#xff1b;选中自己要升级的nuget包&#xff0c;双击。 √ > File > Publish

NuGet安装使用

一.NuGet 1.介绍 在.NET应用程序编程开发中&#xff0c;开发者通常使用类库来管理、维护属于同一分类的程序代码&#xff0c;以便代码的重用。一般情况下&#xff0c;处于同一类库的所有类都位于同一程序集。 这些类库被编译器编译后会生成扩展名为.dll的动态链接库文件&…

NuGet的使用

什么是NuGet&#xff1f; NuGet&#xff08;读作New Get&#xff09;是用于微软.NET开发平台的软件包管理器&#xff08;相当于NPM&#xff09;&#xff0c;是一个Visual Studio的扩展。在使用Visual Studio开发基于.NET Framework的应用时&#xff0c;NuGet能够令你在项目中添…