Linux磁盘I/O性能测试

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012102588/article/details/82114573

磁盘性能评价指标

IOPS:(Input/Output Per Second)每秒的读写次数,随机读写关注指标,是随机读写频繁的应用,如OLTP(Online Transaction Processing),的关键衡量指标。
吞吐量:(Throughput)单位时间内可以成功传输的数据数量,也称作传输带宽(bandwidth),顺序读写关注指标,对于大量顺序读写的应用,如VOD(Video On Demand),则更关注吞吐量指标。
IOPS和吞吐量之间关系Throughput MB/s = IOPS * KB per IO / 1024,即吞吐量等于IOPS乘以每次IO大小,理论上磁盘可以处理不同的IO大小(如512B、4KB、8KB、16KB),所能达到的Throughput吞吐量是有区别的。简单的来说,物理层面IOPS和Throughput哪个先达到了物理磁盘的极限,就决定了这个物理磁盘的性能阀值。

测试项目

顺序读写、随机读写、混合读写

测试工具

dd(device to device)命令、fio、hdparm、IOMeter

使用举例

hdparm(比较简单)

# hdparm -tT /dev/nvme0n1
/dev/nvme0n1:
 Timing cached reads:   15696 MB in  2.00 seconds = 7866.33 MB/sec
 Timing buffered disk reads: 7506 MB in  3.00 seconds = 2501.42 MB/sec

能够看到 2 秒内读取了 15696MB缓存,而在 3 秒内从磁盘上物理读 7506MB 数据

fio(比较全面)

以IO size=4KB为例,fio安装和参数说明见:fio安装与使用Linux 磁盘IO性能测试工具:FIO
顺序读

sudo fio -ioengine=libaio -bs=4k -direct=1 -thread -rw=read -filename=/dev/sda2 -name="BS 4KB read test" -iodepth=16 -runtime=60

顺序写(写filename设置为磁盘,不是分区)

sudo fio -ioengine=libaio -bs=4k -direct=1 -thread -rw=write -filename=/dev/sdb -name="BS 4KB read test" -iodepth=16 -runtime=60

随机读

sudo fio -ioengine=libaio -bs=4k -direct=1 -thread -rw=randread -filename=/dev/sdb -name="BS 4KB read test" -iodepth=16 -runtime=60

随机写

sudo fio -ioengine=libaio -bs=4k -direct=1 -thread -rw=randwrite -filename=/dev/sdb -name="BS 4KB read test" -iodepth=16 -runtime=60

混合读写

sudo fio -ioengine=libaio -bs=4k -direct=1 -thread -rw=randrw -rwmixread=70 -filename=/dev/sdb -name="BS 4KB randrw 70 test" -iodepth=16 -runtime=60

结果分析:
fio结果分析

参考资料

  1. IOPS Wikipedia
  2. 论存储IOPS和Throughput吞吐量之间的关系
  3. fio安装与使用
  4. Linux 磁盘IO性能测试工具:FIO

猜你喜欢

转载自blog.csdn.net/u012102588/article/details/82114573