Open penglongli opened 6 years ago
Linux 下的 I/O 测试一般用两种:fio、dd,前者比较强大,下边简单介绍下使用
fio 的测试 UCloud 写的挺好的,建议参考:
需要注意的是,fio 是直接通过写裸盘的方式进行测试,直接测试裸盘会损坏文件系统结构,导致数据丢失。务必要确认磁盘数据已备份,或者无重要数据。
fio 分为:顺序读写、随机读写、混合随机读写三种模式,下边直接通过用例来介绍
顺序读写:文件在硬盘上存储位置是连续的。
适用场景:大文件拷贝。此指标对于数据库性能没有参考价值。
512K 顺序读
/usr/bin/fio -filename=/dev/vda -direct=1 -iodepth 64 -thread -rw=read -ioengine=libaio -bs=512K -numjobs=1 -runtime=20 -group_reporting -name=test
512K 顺序写
/usr/bin/fio -filename=/dev/vda -direct=1 -iodepth 64 -thread -rw=write -ioengine=libaio -bs=512K -numjobs=8 -runtime=20 -group_reporting -name=test
其中 filename 可通过 fdisk -l 查看所有设备来修改
filename
fdisk -l
我们重点看这个性能测试
随机读写:在硬盘上随机位置读写数据
使用场景:操作系统运行、软件运行、数据库等
4k 随机写
/usr/bin/fio -filename=/dev/vda -direct=1 -iodepth 64 -thread -rw=randwrite -ioengine=libaio -bs=4K -numjobs=8 -runtime=20 -group_reporting -name=test
上边命令:每次请求快大小为 4k,开启 8 个线程跑 20s 的随机写
下边看一下腾讯云的普通硬盘4k 随机写性能:
4k 随机读
参考:
dd 命令并不是很科学,因为其仅仅能测大文件读写(顺序)、块级延时
root@host-2:/tmp# dd if=/dev/zero of=/root/test1.txt bs=1G count=1 oflag=dsync 1+0 records in 1+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 10.4905 s, 102 MB/s
参数:
通过上述测试,我们写入了 1G 的块,吞吐率是:102 MB/s,下边是阿里云的信息:
root@iZbp1821ze5eu8r7wvf86qZ:~# dd if=/dev/zero of=/root/test1.txt bs=1G count=1 oflag=dsync 1+0 records in 1+0 records out 1073741824 bytes (1.1 GB, 1.0 GiB) copied, 19.5192 s, 55.0 MB/s
我们能发现,腾讯云在写入大文件的情况下性能比阿里云高 2 倍
512K 写
root@host-2:/tmp# dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync 1000+0 records in 1000+0 records out 512000 bytes (512 kB, 500 KiB) copied, 13.4739 s, 38.0 kB/s
上述我们每次写入 512K 大小的块,写 1000 次,最后的吞吐率是:38.0 kB/s
对比阿里云:
root@iZbp1821ze5eu8r7wvf86qZ:~# dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync 1000+0 records in 1000+0 records out 512000 bytes (512 kB, 500 KiB) copied, 4.01572 s, 127 kB/s
腾讯云性能差阿里云 3 倍多
4K 写
root@host-2:/tmp# dd if=/dev/zero of=/tmp/test2.img bs=4 count=1000 oflag=dsync 1000+0 records in 1000+0 records out 4000 bytes (4.0 kB, 3.9 KiB) copied, 11.8862 s, 0.3 kB/s
每次写入 4K 的块,写入 1000 次,吞吐率:0.3kB/s
root@iZbp1821ze5eu8r7wvf86qZ:~# dd if=/dev/zero of=/tmp/test2.img bs=4 count=1000 oflag=dsync 1000+0 records in 1000+0 records out 4000 bytes (4.0 kB, 3.9 KiB) copied, 4.0135 s, 1.0 kB/s
性能差阿里云 3 倍多
Linux 下的 I/O 测试一般用两种:fio、dd,前者比较强大,下边简单介绍下使用
fio
fio 的测试 UCloud 写的挺好的,建议参考:
需要注意的是,fio 是直接通过写裸盘的方式进行测试,直接测试裸盘会损坏文件系统结构,导致数据丢失。务必要确认磁盘数据已备份,或者无重要数据。
fio 分为:顺序读写、随机读写、混合随机读写三种模式,下边直接通过用例来介绍
顺序读写
顺序读写:文件在硬盘上存储位置是连续的。
适用场景:大文件拷贝。此指标对于数据库性能没有参考价值。
512K 顺序读
512K 顺序写
其中
filename
可通过fdisk -l
查看所有设备来修改随机读写
随机读写:在硬盘上随机位置读写数据
使用场景:操作系统运行、软件运行、数据库等
4k 随机写
上边命令:每次请求快大小为 4k,开启 8 个线程跑 20s 的随机写
下边看一下腾讯云的普通硬盘4k 随机写性能:
4k 随机读
dd
参考:
dd 命令并不是很科学,因为其仅仅能测大文件读写(顺序)、块级延时
吞吐率
参数:
通过上述测试,我们写入了 1G 的块,吞吐率是:102 MB/s,下边是阿里云的信息:
我们能发现,腾讯云在写入大文件的情况下性能比阿里云高 2 倍
延时
512K 写
上述我们每次写入 512K 大小的块,写 1000 次,最后的吞吐率是:38.0 kB/s
对比阿里云:
腾讯云性能差阿里云 3 倍多
4K 写
每次写入 4K 的块,写入 1000 次,吞吐率:0.3kB/s
对比阿里云:
性能差阿里云 3 倍多