欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 养生 > fio磁盘测试工具使用笔记

fio磁盘测试工具使用笔记

2025/4/26 14:21:12 来源:https://blog.csdn.net/subfate/article/details/146704359  浏览:    关键词:fio磁盘测试工具使用笔记

本文介绍磁盘性能测试工具fio在某国产操作系统(内核4.19,gcc为7.3.0)上的编译和使用。

背景

某项目使用物理机安装某数据库,相关人员提到磁盘性能方面的要求,用fio测试32k的随机读写,性能要达到1万 IOPS。本文即进行此工具测试。

fio是一款强大的磁盘 I/O 性能测试工具,用于评估存储设备(如硬盘、SSD、NVMe)的 吞吐量(BW)、IOPS(每秒 I/O 操作数)和延迟(Latency)。它支持多种 I/O 引擎和工作模式,可模拟真实业务场景的压力测试。

主要特点如下:

  • 多引擎支持:libaio(Linux 异步 I/O)、io_uring(高性能)、psync(同步)、mmap(内存映射)等。
  • 灵活配置:可自定义 块大小(block size)、队列深度(iodepth)、读写比例(rwmixread) 等参数。
  • 多线程/多任务:通过 numjobs 模拟并发负载。
  • 跨平台:支持 Linux、Windows、macOS。

安装

下载:https://github.com/axboe/fio/releases 。文件:fio-3.39.tar.gz

在线安装依赖库:

sudo yum install libaio libaio-devel -y

编译:

./configure
make
sudo make install

验证 libaio 支持:

# ./fio --enghelp | grep libaiolibaio

测试

32k随机读写测试命令,使用libaio库,命令如下:

fio --name=randrw_test --ioengine=libaio --iodepth=32 --rw=randrw --rwmixread=50 --bs=32k --direct=1 --size=4G --numjobs=4 --runtime=60 --time_based --group_reporting

关键参数说明

  • –iodepth=32:设置I/O队列深度为32,这对SSD/NVMe设备很重要
  • –numjobs=4:使用4个并行线程/进程来产生负载
  • –direct=1:绕过系统缓存,直接I/O
  • –size=4G:每个线程测试4GB数据
  • –runtime=60:测试运行60秒

测试结果的主要指标如下:

IOPS=423, BW=13.2MiB/s

从结果看,测试服务器硬盘性能一般般。详细结果如下:

# fio --name=randrw_test --ioengine=libaio --iodepth=32 --rw=randrw --rwmixread=50 --bs=32k --direct=1 --size=4G --numjobs=4 --runtime=60 --time_based --group_reporting
randrw_test: (g=0): rw=randrw, bs=(R) 32.0KiB-32.0KiB, (W) 32.0KiB-32.0KiB, (T) 32.0KiB-32.0KiB, ioengine=libaio, iodepth=32
...
fio-3.39
Starting 4 processes
randrw_test: Laying out IO file (1 file / 4096MiB)
randrw_test: Laying out IO file (1 file / 4096MiB)
randrw_test: Laying out IO file (1 file / 4096MiB)
randrw_test: Laying out IO file (1 file / 4096MiB)
Jobs: 4 (f=4): [m(4)][5.0%][r=18.0MiB/s,w=18.8MiB/s][r=576,w=603 IOPS][eta 00m:5Jobs: 4 (f=4): [m(4)][6.7%][r=17.8MiB/s,w=19.2MiB/s][r=571,w=614 IOPS][eta 00m:5Jobs: 4 (f=4): [m(4)][8.3%][r=17.1MiB/s,w=16.9MiB/s][r=547,w=542 IOPS][eta 00m:5Jobs: 4 
。。。
(f=4): [m(4)][100.0%][r=6048KiB/s,w=6688KiB/s][r=189,w=209 IOPS][eta 00mJobs: 4 (f=4): [m(4)][9.6%][r=7776KiB/s,w=5760KiB/s][r=243,w=180 IOPS][eta 09m:3Jobs: 2 (f=2): [m(2),_(2)][34.4%][r=1069KiB/s,w=855KiB/s][r=33,w=26 IOPS][eta 01m:58s]
randrw_test: (groupid=0, jobs=4): err= 0: pid=1048845: Thu Mar 27 16:53:20 2025read: IOPS=423, BW=13.2MiB/s (13.9MB/s)(821MiB/62024msec)slat (nsec): min=4456, max=96903, avg=14923.19, stdev=5994.18clat (usec): min=30, max=3032.4k, avg=230270.66, stdev=238818.59lat (usec): min=37, max=3032.4k, avg=230285.58, stdev=238818.97clat percentiles (msec):|  1.00th=[    3],  5.00th=[   12], 10.00th=[   26], 20.00th=[   58],| 30.00th=[   96], 40.00th=[  134], 50.00th=[  169], 60.00th=[  209],| 70.00th=[  266], 80.00th=[  347], 90.00th=[  498], 95.00th=[  659],| 99.00th=[ 1150], 99.50th=[ 1469], 99.90th=[ 2106], 99.95th=[ 2165],| 99.99th=[ 2601]bw (  KiB/s): min= 1856, max=46208, per=100.00%, avg=13948.19, stdev=2178.00, samples=481iops        : min=   58, max= 1444, avg=435.88, stdev=68.06, samples=481write: IOPS=429, BW=13.4MiB/s (14.1MB/s)(832MiB/62024msec); 0 zone resetsslat (usec): min=4, max=110, avg=15.08, stdev= 7.04clat (usec): min=30, max=2336.7k, avg=66911.12, stdev=126808.10lat (usec): min=37, max=2336.8k, avg=66926.21, stdev=126809.08clat percentiles (usec):|  1.00th=[     35],  5.00th=[     38], 10.00th=[     40],| 20.00th=[     42], 30.00th=[     45], 40.00th=[     48],| 50.00th=[     63], 60.00th=[  41157], 70.00th=[  79168],| 80.00th=[ 121111], 90.00th=[ 183501], 95.00th=[ 270533],| 99.00th=[ 522191], 99.50th=[ 633340], 99.90th=[1736442],| 99.95th=[1920992], 99.99th=[2231370]bw (  KiB/s): min= 1344, max=48128, per=100.00%, avg=14177.60, stdev=2354.39, samples=480iops        : min=   42, max= 1504, avg=443.05, stdev=73.57, samples=480lat (usec)   : 50=22.30%, 100=4.20%, 250=0.19%, 500=0.13%, 750=0.11%lat (usec)   : 1000=0.07%lat (msec)   : 2=0.18%, 4=0.49%, 10=1.89%, 20=2.60%, 50=7.73%lat (msec)   : 100=13.39%, 250=27.73%, 500=13.43%, 750=3.72%, 1000=1.02%lat (msec)   : 2000=0.72%, >=2000=0.11%cpu          : usr=0.10%, sys=0.35%, ctx=50323, majf=0, minf=54IO depths    : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=0.1%, 32=99.8%, >=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.1%, 64=0.0%, >=64=0.0%issued rwts: total=26277,26637,0,0 short=0,0,0,0 dropped=0,0,0,0latency   : target=0, window=0, percentile=100.00%, depth=32Run status group 0 (all jobs):READ: bw=13.2MiB/s (13.9MB/s), 13.2MiB/s-13.2MiB/s (13.9MB/s-13.9MB/s), io=821MiB (861MB), run=62024-62024msecWRITE: bw=13.4MiB/s (14.1MB/s), 13.4MiB/s-13.4MiB/s (14.1MB/s-14.1MB/s), io=832MiB (873MB), run=62024-62024msecDisk stats (read/write):dm-0: ios=26277/27963, sectors=1681728/1722759, merge=0/0, ticks=5988971/1844511, in_queue=0, util=98.92%, aggrios=26277/27885, aggsectors=1681728/1722759, aggrmerge=0/78, aggrticks=5991165/1774213, aggrin_queue=7745112, aggrutil=99.33%sda: ios=26277/27885, sectors=1681728/1722759, merge=0/78, ticks=5991165/1774213, in_queue=7745112, util=99.33%

其它说明

可以进行以下几种类型的测试:

  • 随机读写:–rw=randrw
  • 随机读:–rw=randread
  • 随机写:–rw=randwrite

其它事项:

  • 对于NVMe SSD,可以使用--ioengine=io_uring以获得更好性能。
  • 如果系统核数较多,则可以增加线程数numjobs,发挥最大性能。

小结

目前还没有服务器测试,后续找机会再试试。

在centos7无法编译信息

fio新版本对GCC有要求,如版本过低,则无法编译,如下:

# ./configure 
Operating system              Linux
CPU                           x86_64
Big endian                    no
Compiler                      gcc
Cross compile                 noStatic build                  noYour compiler doesn't support C11 atomics. gcc 4.9/clang 3.6 are the
minimum versions with it - perhaps your compiler is too old?
C11 atomics support not found
Configure failed, check config.log and/or the above output

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词