操作环境
Centos 6.6
qemu-kvm-0.12.1.2
fio 2.0.13
操作说明
KVM的Disk的Cache模式有3种
- none
- writeback
- writethrough
3种cache模式的io路径如上图所示。
此次测试通过fio分别对该3种cache模式进行测试,包括顺序读(sr),顺序写(sw),随机读(rr),随机写(rw)。
测试脚本如下
#!/bin/bash
function tgt_r {
fio -filename=/dev/vdb -direct=1 -iodepth 64 -thread -rw=read -ioengine=libaio -bs=$1 -size=100G -runtime=60 -group_reporting -name=mytest &>> s_r_test
}
function tgt_w {
fio -filename=/dev/vdb -direct=1 -iodepth 64 -thread -rw=write -ioengine=libaio -bs=$1 -size=100G -runtime=60 -group_reporting -name=mytest &>> s_w_test
}
function tgt_rr {
fio -filename=/dev/vdb -direct=1 -iodepth 64 -thread -rw=randread -ioengine=libaio -bs=$1 -size=100G -runtime=60 -group_reporting -name=mytest &>> r_r_test
}
function tgt_rw {
fio -filename=/dev/vdb -direct=1 -iodepth 64 -thread -rw=randwrite -ioengine=libaio -bs=$1 -size=100G -runtime=60 -group_reporting -name=mytest &>> r_w_test
}
tgt_r 512K
tgt_w 512K
tgt_rr 512K
tgt_rw 512K
fio 参数说明
ioengine: 负载引擎,使用libaio,发起异步IO请求。
bs: IO大小
direct: 直写,绕过操作系统Cache。
rw: 读写模式,有顺序写write、顺序读read、随机写randwrite、随机读randread等。
size: 寻址空间,IO会落在 [0, size)这个区间的硬盘空间上,一般设置为硬盘的大小。
filename: 测试对象
iodepth: 队列深度
runtime: 测试时长
bs: IO大小
direct: 直写,绕过操作系统Cache。
rw: 读写模式,有顺序写write、顺序读read、随机写randwrite、随机读randread等。
size: 寻址空间,IO会落在 [0, size)这个区间的硬盘空间上,一般设置为硬盘的大小。
filename: 测试对象
iodepth: 队列深度
runtime: 测试时长
测试结果
MBPS(KB/s)
IOPS
latency(ms)
通过上述测试可得知,cache mode为none的时候读的性能最佳,cache mode为writeback时候写性能最佳