zoukankan      html  css  js  c++  java
  • Linux系统IO基准测试方法

    9tC2U.jpg

    顺序读写测试

    主要关注磁盘的吞吐量,即每秒能够读入或者写出多少数据。普通单块机械磁盘顺序写在100MB/s左右,普通单块SSD的顺序写在500MB/s左右。该指标对MQ、ES等以append方式追加数据的软件性能影响比较大

    测试方法

    • 安装软件
      默认情况下操作系统自带dd命令,不用安装

    • 运行命令:

      dd if=/dev/zero of=/home/wangzhen/ddtest/test.dbf bs=8k count=100k  conv=fdatasync
      
    • 参数含义:

      • bs=< 字节数 > 将 ibs( 输入 ) 与 obs( 输出 ) 设成指定的字节数。
      • cbs=< 字节数 > 转换时,每次只转换指定的字节数。
      • conv=< 关键字 > 指定文件转换的方式。
      • count=< 区块数 > 仅读取指定的区块数。
      • ibs=< 字节数 > 每次读取的字节数。
      • if=< 文件 > 从文件读取。
      • obs=< 字节数 > 每次输出的字节数。
      • of=< 文件 > 输出到文件。
      • seek=< 区块数 > 一开始输出时,跳过指定的区块数。
      • skip=< 区块数 > 一开始读取时,跳过指定的区块数。
      • --help 帮助。
      • --version 显示版本信息。
    • 测试结果:

      [wangzhen@hellow-pc ~]$ dd if=/dev/zero of=/home/wangzhen/ddtest/test.dbf bs=8k count=100k  conv=fdatasync
      记录了102400+0 的读入
      记录了102400+0 的写出
      838860800 bytes (839 MB, 800 MiB) copied, 1.75207 s, 479 MB/s
      

    随机读写测试

    主要关注IOPS指标,即每秒磁盘能够处理的IO请求个数。普通单块机械磁盘的IOPS在100~300左右,普通SSD的IOPS在几万左右,该指标对关系型数据库等以随机读写为主的软件性能影响比较大。

    测试方法

    • 安装fio测试软件
    yum install -y fio
    
    • 运行命令:
    fio -directory=/home/wangzhen/fiotest -name=tempfile.dat -direct=1 -rw=randrw -rwmixwrite=30 -bs=8k -size=4M -numjobs=16 -time_based -runtime=100 -group_reporting
    
    • 参数含义:

      • filename: 指定文件(设备)的名称。可以通过冒号分割同时指定多个文件,

        如filename=/dev/sda:/dev/sdb。

      • directory: 设置filename的路径前缀。在后面的基准测试中,采用这种方式来指定设备。

      • name: 指定job的名字,在命令行中表示新启动一个job。

      • direct: bool类型,如果设置成true (1),表示不使用io buffer。

      • ioengine: I/O引擎,现在fio支持19种ioengine。默认值是sync同步阻塞I/O,libaio是Linux的native异步I/O。

      • iodepth: 如果ioengine采用异步方式,该参数表示一批提交保持的io单元数。该参数可参考文章“Fio压测工具和io队列深度理解和误区”。

      • rw: I/O模式,分顺序读 -rw=read ,随机读 -rw=randread,顺序写 -rw=write,随机写-rw=randwrite ,混合随机读写模式 -rw=randrw

      • bs: I/O block大小,默认是4k。

      • size: 指定job处理的文件的大小。

      • numjobs: 指定job的克隆数(线程)。

      • time_based: 如果在runtime指定的时间还没到时文件就被读写完成,将继续重复知道runtime时间结束。

      • runtime: 指定在多少秒后停止进程。如果未指定该参数,fio将执行至指定的文件读写完全完成。

      • rwmixwrite: 在混合读写的模式下,写占比,如:
        rwmixwrite=30 #在混合读写的模式下,写占30%

      • group_reporting: 当同时指定了numjobs了时,输出结果按组显示。

    • 测试结果:

      Jobs: 16 (f=16): [m(16)][100.0%][r=285MiB/s,w=123MiB/s][r=36.4k,w=15.7k IOPS][eta 00m:00s]
      tempfile.dat: (groupid=0, jobs=16): err= 0: pid=24847: Tue Sep  8 12:37:29 2020
        read: IOPS=37.7k, BW=294MiB/s (309MB/s)(28.8GiB/100004msec)
          clat (usec): min=56, max=9583, avg=336.41, stdev=191.05
           lat (usec): min=56, max=9583, avg=336.61, stdev=191.06
          clat percentiles (usec):
           |  1.00th=[  184],  5.00th=[  229], 10.00th=[  253], 20.00th=[  273],
           | 30.00th=[  277], 40.00th=[  293], 50.00th=[  297], 60.00th=[  310],
           | 70.00th=[  326], 80.00th=[  347], 90.00th=[  437], 95.00th=[  578],
           | 99.00th=[  857], 99.50th=[ 1205], 99.90th=[ 2900], 99.95th=[ 3621],
           | 99.99th=[ 4686]
         bw (  KiB/s): min=169600, max=325127, per=100.00%, avg=301510.55, stdev=1517.27, samples=3194
         iops        : min=21200, max=40640, avg=37688.66, stdev=189.66, samples=3194
        write: IOPS=16.2k, BW=126MiB/s (133MB/s)(12.3GiB/100004msec); 0 zone resets
          clat (usec): min=30, max=8153, avg=198.82, stdev=123.40
           lat (usec): min=30, max=8153, avg=199.23, stdev=123.42
          clat percentiles (usec):
           |  1.00th=[   44],  5.00th=[   74], 10.00th=[  102], 20.00th=[  143],
           | 30.00th=[  174], 40.00th=[  190], 50.00th=[  204], 60.00th=[  210],
           | 70.00th=[  223], 80.00th=[  231], 90.00th=[  245], 95.00th=[  265],
           | 99.00th=[  502], 99.50th=[  693], 99.90th=[ 1926], 99.95th=[ 2073],
           | 99.99th=[ 3425]
         bw (  KiB/s): min=70224, max=148445, per=100.00%, avg=129465.94, stdev=730.12, samples=3194
         iops        : min= 8778, max=18555, avg=16182.78, stdev=91.26, samples=3194
        lat (usec)   : 50=0.49%, 100=2.26%, 250=31.37%, 500=60.47%, 750=4.00%
        lat (usec)   : 1000=0.84%
        lat (msec)   : 2=0.33%, 4=0.21%, 10=0.03%
        cpu          : usr=1.12%, sys=3.88%, ctx=5396973, majf=0, minf=182
        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=3769009,1618382,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):
         READ: bw=294MiB/s (309MB/s), 294MiB/s-294MiB/s (309MB/s-309MB/s), io=28.8GiB (30.9GB), run=100004-100004msec
        WRITE: bw=126MiB/s (133MB/s), 126MiB/s-126MiB/s (133MB/s-133MB/s), io=12.3GiB (13.3GB), run=100004-100004msec
      
      Disk stats (read/write):
          dm-2: ios=3763596/1616571, merge=0/0, ticks=1205457/296320, in_queue=1501777, util=99.37%, aggrios=3769528/1618669, aggrmerge=740/285, aggrticks=1206427/295628, aggrin_queue=33881, aggrutil=99.40%
        sda: ios=3769528/1618669, merge=740/285, ticks=1206427/295628, in_queue=33881, util=99.40%
      

    总结

    • 我本机8K块随机读写的IOPS=36.4k+15.7k,大约是52k,即每秒处理5万次IO请求

      Jobs: 16 (f=16): [m(16)][100.0%][r=285MiB/s,w=123MiB/s][r=36.4k,w=15.7k IOPS][eta 00m:00s]

    • 我本机8K块的顺序写速度为479MB/s

      838860800 bytes (839 MB, 800 MiB) copied, 1.75207 s, 479 MB/s

  • 相关阅读:
    记录一下最近面试的总结
    网络模块相关面试题
    JVM 之类加载器
    一段简单的关于字符串的 Java 代码竟考察了这么多东西
    LeetCode 链表题 ( Java )
    MD5 加盐加密
    SpringMVC 学习笔记
    [redis]dict和rehash
    [redis]SDS和链表
    [go]包和工程管理
  • 原文地址:https://www.cnblogs.com/wangzhen3798/p/13631848.html
Copyright © 2011-2022 走看看