1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| # 安装fio yum install fio
# 准备好测试路径或硬盘 # 这里采用指向目录的方式测试 # 如需直接测试硬盘,则指向硬盘即可 # -name=本次测试的名称,自定义即可 # -size=本次测试的文件大小,建议大于内存的2倍,避免某些文件系统使用内存缓存 # 鉴于CentOS 7.9.2009的xfs和参数设置了direct=1,所以size不用大于内存 # -runtime=运行时间,单位支持秒s、分m、时h、天d # -time_base 即使写入了指定大小的文件,依旧继续重复写入,直到runtime时间结束 # -direct=1设置不使用系统缓存,直写 # -ioengine=libaio直接使用Linux的异步IO引擎 # -randrepeat=0设置每次IO的随机性都不同,模拟真实业务场景 # -numjobs=8设置8个进程,模拟真实业务场景 # -group_reporting多进程的运行结果汇总汇报 # -bs=4k 块大小4k # -rw=randrw随机读写 # -rwmixwrite=30设置30%写70%读,模拟真实业务场景 # -filename=/root/fio 在/root目录下创建一个名为fio的文件进行测试 # -directory=/dir/上方的filename也可替换为该命令指向目录,会在目录下根据numjobs的数量生成多个文件测试 # 注意下你的目录容量,别装不下size*numjobs的文件 # -iodepth= IO队列深度
# 运行5分钟,采用路径模式8进程写入,模拟最真实的业务场景 fio -name=disk_benchmark -size=10G -runtime=5m -time_base -direct=1 -ioengine=libaio -randrepeat=0 -numjobs=8 -group_reporting -bs=4k -rw=randrw -rwmixwrite=30 -filename=/home/fio -iodepth=1
# 1m顺序混合30%写70%读范例 fio -name=disk_benchmark -size=5G -runtime=15s -time_base -direct=1 -ioengine=libaio -numjobs=8 -group_reporting -bs=1m -rw=rw -rwmixwrite=30 -filename=/home/fio/a -iodepth=1
# 运行结果如下 # 其中第38行则是读取性能的测试结果,55行是写入的性能测试结果,附带了注释说明 disk_benchmark: (g=0): rw=randrw, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=32 ... fio-3.7 Starting 8 processes disk_benchmark: Laying out IO file (1 file / 5120MiB) Jobs: 8 (f=8): [m(8)][100.0%][r=339MiB/s,w=144MiB/s][r=86.8k,w=36.0k IOPS][eta 00m:00s] disk_benchmark: (groupid=0, jobs=8): err= 0: pid=64509: Tue Sep 16 15:11:50 2025 # 读取性能的测试结果在此,记录IOPS,和MB单位的353MB/s即可 read: IOPS=86.2k, BW=337MiB/s (353MB/s)(5053MiB/15002msec) slat (nsec): min=1110, max=34081k, avg=51710.15, stdev=245614.51 clat (usec): min=229, max=36569, avg=2081.87, stdev=914.48 # 读取延迟取lat(total latency)总延迟的值即可,统一用微秒单位 # Windows按住Alt然后直接按小数字键盘0181即可输出µ # Linux则是Ctrl+Shift+U输入00b5 # MACOS则是Option+m输出µ lat (usec): min=237, max=37825, avg=2133.63, stdev=947.08 clat percentiles (usec): | 1.00th=[ 545], 5.00th=[ 816], 10.00th=[ 1106], 20.00th=[ 1401], | 30.00th=[ 1614], 40.00th=[ 1795], 50.00th=[ 1958], 60.00th=[ 2147], | 70.00th=[ 2376], 80.00th=[ 2737], 90.00th=[ 3261], 95.00th=[ 3621], | 99.00th=[ 4490], 99.50th=[ 4817], 99.90th=[ 5538], 99.95th=[ 5866], | 99.99th=[21103] bw ( KiB/s): min=39944, max=45384, per=12.50%, avg=43106.80, stdev=948.51, samples=240 iops : min= 9986, max=11346, avg=10776.67, stdev=237.13, samples=240 # 写入性能的测试结果在此,记录IOPS,和MB单位的353MB/s即可 write: IOPS=37.0k, BW=145MiB/s (152MB/s)(2171MiB/15002msec) slat (nsec): min=1470, max=17704k, avg=54444.01, stdev=241994.82 clat (usec): min=150, max=37077, avg=1887.95, stdev=964.94 # 写入延迟取lat(total latency)总延迟的值即可,统一用微秒单位 # Windows按住Alt然后直接按小数字键盘0181即可输出µ # Linux则是Ctrl+Shift+U输入00b5 # MACOS则是Option+m输出µ lat (usec): min=153, max=37080, avg=1942.46, stdev=994.98 clat percentiles (usec): | 1.00th=[ 400], 5.00th=[ 537], 10.00th=[ 676], 20.00th=[ 1156], | 30.00th=[ 1418], 40.00th=[ 1614], 50.00th=[ 1795], 60.00th=[ 1991], | 70.00th=[ 2212], 80.00th=[ 2540], 90.00th=[ 3130], 95.00th=[ 3556], | 99.00th=[ 4490], 99.50th=[ 4817], 99.90th=[ 5604], 99.95th=[ 5997], | 99.99th=[18744] bw ( KiB/s): min=16736, max=19920, per=12.50%, avg=18519.40, stdev=504.91, samples=240 iops : min= 4184, max= 4980, avg=4629.82, stdev=126.23, samples=240 lat (usec) : 250=0.01%, 500=1.54%, 750=4.81%, 1000=4.07% lat (msec) : 2=44.46%, 4=42.71%, 10=2.39%, 20=0.01%, 50=0.01% cpu : usr=1.15%, sys=8.65%, ctx=508859, majf=0, minf=268 IO depths : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=0.1%, 32=100.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.1%, 64=0.0%, >=64=0.0% issued rwts: total=1293511,555725,0,0 short=0,0,0,0 dropped=0,0,0,0 latency : target=0, window=0, percentile=100.00%, depth=32
Run status group 0 (all jobs): READ: bw=337MiB/s (353MB/s), 337MiB/s-337MiB/s (353MB/s-353MB/s), io=5053MiB (5298MB), run=15002-15002msec WRITE: bw=145MiB/s (152MB/s), 145MiB/s-145MiB/s (152MB/s-152MB/s), io=2171MiB (2276MB), run=15002-15002msec
Disk stats (read/write): dm-2: ios=1288781/553752, merge=0/0, ticks=1713741/644122, in_queue=2391609, util=100.00%, aggrios=1293378/555710, aggrmerge=132/23, aggrticks=1658421/619009, aggrin_queue=2289296, aggrutil=99.74% sda: ios=1293378/555710, merge=132/23, ticks=1658421/619009, in_queue=2289296, util=99.74% # 这里的util是硬盘负载,100%负载才说明榨干了硬盘性能
|