本页介绍了如何使用 Fio 工具验证卷性能。为了优化应用,请务必为您的卷建立基准性能。
使用 Fio 衡量卷性能
使用 I/O 生成器工具 Fio 衡量基准性能。
使用 Fio
Fio 会应用您可以通过命令行界面或配置文件指定的工作负载。在运行期间,Fio 会显示一个进度指示器,其中包含当前吞吐量以及每秒输入和输出 (IOPS) 数。结束后,系统会显示详细的总结。
FIO 结果示例
以下示例展示了单线程 4k 随机写入作业运行 60 秒的情况,这是衡量基准延迟时间的有效方法。在以下命令中,--directory 参数指向装载了 NetApp Volumes 共享的文件夹:
$ FIO_COMMON_ARGS=--size=10g --fallocate=none --direct=1 --runtime=60 --time_based --ramp_time=5
$ fio $FIO_COMMON_ARGS --directory=/netapp --ioengine=libaio --rw=randwrite --bs=4k --iodepth=1 --name=nv
cvs: (g=0): rw=randwrite, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=1
fio-3.28
Starting 1 process
cvs: Laying out IO file (1 file / 10240MiB)
Jobs: 1 (f=1): [w(1)][100.0%][w=7856KiB/s][w=1964 IOPS][eta 00m:00s]
cvs: (groupid=0, jobs=1): err= 0: pid=1891: Wed Dec 21 14:56:37 2022
write: IOPS=1999, BW=7999KiB/s (8191kB/s)(469MiB/60001msec); 0 zone resets
slat (usec): min=4, max=417, avg=12.06, stdev= 5.71
clat (usec): min=366, max=27978, avg=483.59, stdev=91.34
lat (usec): min=382, max=28001, avg=495.96, stdev=91.89
clat percentiles (usec):
| 1.00th=[ 408], 5.00th=[ 429], 10.00th=[ 437], 20.00th=[ 449],
| 30.00th=[ 461], 40.00th=[ 469], 50.00th=[ 482], 60.00th=[ 490],
| 70.00th=[ 498], 80.00th=[ 515], 90.00th=[ 529], 95.00th=[ 553],
| 99.00th=[ 611], 99.50th=[ 652], 99.90th=[ 807], 99.95th=[ 873],
| 99.99th=[ 1020]
bw ( KiB/s): min= 7408, max= 8336, per=100.00%, avg=8002.05, stdev=140.09, samples=120
iops : min= 1852, max= 2084, avg=2000.45, stdev=35.06, samples=120
lat (usec) : 500=70.67%, 750=29.17%, 1000=0.15%
lat (msec) : 2=0.01%, 4=0.01%, 50=0.01%
cpu : usr=2.04%, sys=3.25%, ctx=120561, majf=0, minf=58
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 rwts: total=0,119984,0,0 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=1
Run status group 0 (all jobs):
WRITE: bw=7999KiB/s (8191kB/s), 7999KiB/s-7999KiB/s (8191kB/s-8191kB/s), io=469MiB (491MB), run=60001-60001msec
请阅读以下行,详细了解效果结果:
延迟时间:
lat (usec): min=382, max=28001, avg=495.96, stdev=91.89平均延迟时间为 495.96 微秒(大约 0.5 毫秒),这是理想的延迟时间。
IOPS:
min= 1852, max= 2084, avg=2000.45, stdev=35.06, samples=120上述示例显示平均 IOPS 为 2,000。对于延迟时间为 0.5 毫秒 (
IOPS = 1000 ms/0.5 ms = 2000) 的单线程作业,该值是预期值。吞吐量:
bw ( KiB/s): min= 7408, max=8336, per=100.00%, avg=8002.05, stdev=140.09吞吐量平均值为 8002 KiBps,这是 2,000 IOPS 和 4 KiB 块大小 (
2000 1/s * 4 KiB = 8,000 KiB/s) 的预期结果。
测量延迟时间
延迟时间是一项基本的流量效果指标。这是客户端和服务器功能、客户端与服务器之间的距离(音量)以及两者之间的设备共同作用的结果。指标的主要组成部分是距离引起的延迟。
您可以 ping 卷的 IP 地址来获取往返时间,这是对延迟时间的大致估计。
延迟时间受块大小以及您执行的是读取操作还是写入操作的影响。我们建议您使用以下参数来衡量客户端与卷之间的基准延迟时间:
Linux
fio --directory=/netapp \ --ioengine=libaio \ --rw=randwrite \ --bs=4k --iodepth=1 \ --size=10g \ --fallocate=none \ --direct=1 \ --runtime=60 \ --time_based \ --ramp_time=5 \ --name=latency
Windows
fio --directory=Z\:\ --ioengine=windowsaio --thread --rw=randwrite --bs=4k --iodepth=1 --size=10g --fallocate=none --direct=1 --runtime=60 --time_based --ramp_time=5 --name=latency
替换参数 rw(读/写/随机读/随机写)和 bs(块大小),以适应您的工作负载。较大的块大小会导致延迟时间更长,其中读取速度快于写入速度。结果位于 lat 行中。
衡量 IOPS
IOPS 是延迟时间和并发性的直接结果。根据客户端类型,使用以下标签页之一来衡量 IOPS:
Linux
fio --directory=/netapp \ --ioengine=libaio \ --rw=randread \ --bs=4k \ --iodepth=32 \ --size=10g \ --fallocate=none \ --direct=1 \ --runtime=60 \ --time_based \ --ramp_time=5 \ --name=iops
Windows
fio --directory=Z\:\ --ioengine=windowsaio --thread --rw=randread --bs=4k --iodepth=32 --size=10g --fallocate=none --direct=1 --runtime=60 --time_based --ramp_time=5 --numjobs=16 --name=iops
替换参数 rw(读/写/随机读/随机写)、bs(块大小)和 iodepth(并发),以适应您的工作负载。结果位于 iops 行中。
衡量吞吐量
吞吐量是 IOPS 与块大小的乘积。根据您的客户端类型,使用以下标签页之一来衡量吞吐量:
Linux
fio --directory=/netapp \ --ioengine=libaio \ --rw=read \ --bs=64k \ --iodepth=32 \ --size=10g \ --fallocate=none \ --direct=1 \ --runtime=60 \ --time_based \ --ramp_time=5 \ --numjobs=16 \ --name=throughput
Windows
fio --directory=Z\:\ --ioengine=windowsaio --thread --rw=read --bs=64k --iodepth=32 --size=10g --fallocate=none --direct=1 --runtime=60 --time_based --ramp_time=5 --numjobs=16 --name=throughput
替换参数 rw(读/写/随机读/随机写)、bs(块大小)和 iodepth(并发),以适应您的工作负载。只有在块大小为 64k 或更大且并发性较高的情况下,才能实现高吞吐量。
后续步骤
查看效果基准。