衡量环境中的效果指标

本页详细介绍了如何衡量卷性能。

使用 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 微秒 (usec),大约为 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,这是 IOPS 为 2,000 且块大小为 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(read/write/randread/randwrite,读取/写入/随机读取/随机写入)和 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(read/write/randread/randwrite,读取/写入/随机读取/随机写入)、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(read/write/randread/randwrite,读取/写入/随机读取/随机写入)、bs(块大小)和 iodepth(并发)以适应您的工作负载。只有使用 64k 或更大的块大小和高并发,才能实现高吞吐量。

后续步骤

查看性能基准。