# 磁盘 IOPS 与磁盘带宽 (A)

+ 磁盘 IOPS
  + 使用 fio 工具对磁盘的 IOPS 进行压力测试
    + Block 大小 32K
  + 压力测试模式：顺序写 + 随机读  (TIKV 服务器建议: ≥ 10000 IOPS)

------------------------------------------------------------

确认磁盘 IOPS 与磁盘带宽
在生产环境推荐配置的 表格中针对不同组件对磁盘的 IOPS 和带宽有所要求。在分布式系统中，网络上的开销是远远大于单机系统的，为了弥补一部分开销我们对磁盘性能上有所要求。那么如何确定自己的服务器的磁盘性能是符合要求的呢？

- 磁盘 IOPS
使用 fio 工具来对 磁盘的 IOPS 进行压力测试
  - Block 大小 32K
  - 压力测试模式 顺序写+随机读  ;TIKV 服务器建议≥ 10000 IOPS
  - 随机读测试

```
$ fio -ioengine=psync -bs=32k -fdatasync=1 -thread -rw=randread -size=10G -filename=fio_randread_test.txt -name='fio randread test' -iodepth=4 -runtime=60 -numjobs=4 -group_reporting --output-format=json --output=fio_randread_result.json
```

  - 顺序写和随机读混合测试

```
$ fio -ioengine=psync -bs=32k -fdatasync=1 -thread -rw=randrw -percentage_random=100,0 -size=10G -filename=fio_randread_write_test.txt -name='fio mixed randread and sequential write test' -iodepth=4 -runtime=60 -numjobs=4 -group_reporting --output-format=json --output=fio_randread_write_test.json
```

注意：
`-filename`: 参数指定的文件路径位于测试磁盘
