Linux测试磁盘IO性能(随机读写)

11,202 total views, 2 views today

我们常用dd命令测试Linux磁盘IO情况,dd只是测试顺序读写性能。对于随机读写性能测试,可采用FIO工具。

一、安装

下载并安装

 

二、FIO参数

随机读:
# fio -filename=/tmp/test_randread -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=16k -size=30G -numjobs=10 -runtime=60 -group_reporting -name=mytest

 

三、常用测试命令

随机读

# fio -filename=/tmp/test_randread -direct=1 -iodepth 1 -thread -rw=randread -ioengine=psync -bs=16k -size=30G -numjobs=10 -runtime=600 -group_reporting -name=mytest

 

随机写

# fio -filename=/tmp/test_randwrite -direct=1 -iodepth 1 -thread -rw=randwrite -ioengine=psync -bs=16k -size=30G -numjobs=10 -runtime=600 -group_reporting -name=mytest

 

顺序写

# fio -filename=/data/test_randread -direct=1 -iodepth 1 -thread -rw=write -ioengine=psync -bs=16k -size=30G -numjobs=10 -runtime=600 -group_reporting -name=mytest

 

顺序读

# fio -filename=/tmp/test_randread -direct=1 -iodepth 1 -thread -rw=read -ioengine=psync -bs=16k -size=30G -numjobs=10 -runtime=60 -group_reporting -name=mytest

 

混合随机读写

# fio -filename=/tmp/test_randread -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=16k -size=30G -numjobs=10 -runtime=600 -group_reporting -name=mytest -ioscheduler=noop

 

四、读懂结果

这里以直接写操作为例。 我们用10个线程,向磁盘写一个30G文件,块大小为16K,时长10分钟。

主要关注这部分,写速度为347058KB/s,iops为21691。更多测试结果,可以在底部的红色部分看到,包含平均写速度、最小最大速度等等。

write: io=20336MB, bw=347058KB/s, iops=21691 , runt= 60001msec

 

 

五、SSD与机械硬盘性能比对

公司的客服MySQL出现了IO性能瓶颈,想用SSD来解决,也就有了这次测试。

测试结果符合之前看的资料,SSD在随机读写性能方面完爆机械硬盘。而机械硬盘的顺序写性能远优于SSD;不过,SSD和机械硬盘的顺序度性能几乎持平。

硬盘 顺序读 顺序写 随机读 随机写 混合随机读写
SSD(4*1T RAID10) 850M 120M 617M 103M 读:159M 写:68M
机械盘(8*300G RAID10) 977M 347M 25M 24M 读:17M 写:7M
机械盘(8*300G RAID5) 985M 312M 31M 19M 读:17M 写:7M
* 测试工具:fio-2.0.7 filesize:30G thread:10

发表评论

必填项已用*标注