阿里云ESSD PL-X云盘是一款具备超高IOPS、超高吞吐量和超低时延等多维度高性能的云盘。您可以按照本示例配置压测条件,测试云盘作为裸盘时的访问时延和IOPS。
压测条件
-
测试工具:使用FIO。
说明FIO(Flexible I/O Tester)是一个开源的、强大的I/O性能测试工具,可以用来对存储设备进行随机读写、顺序读写等负载测试。
-
实例规格:推荐使用ecs.g8ise.12xlarge。更多信息,请参见存储增强通用型实例规格族g8ise。
-
镜像:使用公共镜像中高版本的Linux镜像,本文使用Alibaba Cloud Linux 3。
说明经测试发现部分Linux发行版镜像可能无法达到预期的性能,强烈推荐您使用阿里云官方维护的Alibaba Cloud Linux 3镜像。
-
ESSD PL-X云盘:
-
测试裸盘可以获得较为真实的云盘性能,建议您直接通过FIO压测裸盘进行云盘性能测试。
-
为确保云盘性能测试的准确性,请预先准备好足够的IOPS。有关ESSD PL-X云盘规格信息,请参见ESSD PL-X云盘(邀测)。
-
压测时延时,建议至少准备40,000 IOPS。
-
压测IOPS时,建议准备3,000 GiB以上的云盘和3,000,000 IOPS。
-
重要测试裸盘可以获得较为真实的块存储性能。但如果块存储设备中含有分区、文件系统以及其他数据,直接使用FIO压测会导致文件系统异常以及数据丢失,请在测试前提前创建快照做好数据备份。具体操作,请参见手动创建单个快照。
-
测试ESSD PL-X云盘时延
远程连接ECS实例。
具体操作,请参见使用Workbench登录Linux实例。
-
运行以下命令,查询块存储的设备名称。
sudo fdisk -lu命令输出中,/dev/vda 为系统盘,/dev/vdb 和 /dev/vdc 为数据盘。
[ecs-a ]$ sudo fdisk -lu Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: F51132A7-67B1-4650-806D-FD0DE6E1210C Device Start End Sectors Size Type /dev/vda1 2048 6143 4096 2M BIOS boot /dev/vda2 6144 415743 409600 200M EFI System /dev/vda3 415744 83886046 83470303 39.8G Linux filesystem Disk /dev/vdb: 30 GiB, 32212254720 bytes, 62914560 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: C36DF120-8650-4188-8043-AEF9C85F31EF Device Start End Sectors Size Type /dev/vdb1 2048 62912511 62910464 30G Linux filesystem Disk /dev/vdc: 40 GiB, 42949672960 bytes, 83886080 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes该实例有3块块存储设备,系统盘/dev/vda、数据盘/dev/vdb、/dev/vdc。
-
运行以下命令,查询块存储设备是否存在分区和文件系统。
sudo blkid[ecs-a ]$ sudo blkid /dev/vdb1: UUID="9c32c24f-d2b8-4aa8-8xxx" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="primary" PARTUUID="4bd66635-f5f4-4dc0-9bdd-664fd5b8d2fb" /dev/vda2: SEC_TYPE="msdos" UUID="7E" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="82a50cd6-9899-41eb-91fe-7027bf257086" /dev/vda3: LABEL="root" UUID="beef9d8d-ba84-46d9-8xxx" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="e0d4fa20-912d-4e86-943e-6b06dxxxx" /dev/vda1: PARTUUID="d083a7cd-a7ea-4898-89d5-8e1510bed584"如上述命令输出所示,块存储设备/dev/vda与/dev/vdb上存在分区及文件系统,而结果中未存在/dev/vdc相关的回执信息,表明/dev/vdc没有分区及文件系统。
-
在测试ESSD PL-X云盘性能前,请确保已经对测试对象进行数据备份,避免数据丢失。ESSD PL-X云盘不支持快照,您可依照本地盘备份方式,将数据通过云备份定期备份、备份至OSS、备份至云盘或NAS来实现数据备份。具体操作可参考备份本地盘文件。
-
运行以下命令,安装libaio库和测试工具FIO。
sudo yum install libaio libaio-devel fio -y -
调整内核启动参数。
重要调整内核启动参数是在grub配置文件中添加
idle=poll参数,目的是改变Linux系统的CPU空闲循环处理方式,从而提升I/O响应速度,对I/O延时敏感的应用至关重要。调整内核启动参数过程中的误操作可能会让操作系统无法正常使用,具有一定风险,请您在测试前提前手动创建单个快照做好数据备份。-
运行以下命令,打开
/etc/default/grub。sudo vim /etc/default/grub -
运行以下命令,找到
GRUB_CMDLINE_LINUX="XXX"所在行,在最末尾添加idle=poll内容。如果内核配置中已有其他的
idle=xxx参数项,请删除。GRUB_TIMEOUT=1 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_TERMINAL_OUTPUT="console" GRUB_DISABLE_RECOVERY="true" GRUB_ENABLE_BLSCFG=true GRUB_CMDLINE_LINUX=" rhgb quiet $(cat /usr/share/alinux-base-setup/cmdline | xargs) biosdevname=0 net.ifnames=0 console=tty0 timeout=300 vring_force_dma_api idle=poll" -
运行以下命令,更新grub配置。
sudo grub2-mkconfig -o /boot/grub2/grub.cfg -
运行以下命令,重启实例使配置生效。
sudo reboot
-
-
运行以下命令,切换路径。
cd /tmp -
运行以下命令,新建test_plx_lat.sh脚本。
sudo vim test_plx_lat.sh -
在test_plx_lat.sh脚本中添加以下内容。
#!/bin/bash DEV_NODE=$1 DEV_NAME=/dev/$DEV_NODE function CheckHasFS { local device=$1 # 设备路径 # 检查设备是否存在 if [ ! -b "$device" ]; then echo "错误: 设备 $device 不存在" exit 1 fi # 使用 `blkid` 命令检查分区表和文件系统类型 local pt_type=$(sudo blkid -o value -s PTTYPE "$device") local fs_type=$(sudo blkid -o value -s TYPE "$device") if [ -n "$pt_type" ] || [ -n "$fs_type" ]; then return 1 else return 0 fi } CheckHasFS "$DEV_NAME" if [ $? -eq 1 ]; then echo "$DEV_NAME 包含分区表或文件系统,停止 fio 脚本!" exit 1 fi echo 2 > /sys/block/$DEV_NODE/queue/rq_affinity sleep 5 DEVICE=`ls -al /sys/block/$DEV_NODE/device | awk '{print $11}' | sed 's%../%%g'` INTERRUPT=`cat /proc/interrupts | grep $DEVICE | shuf -n 1 | awk '{print $1}' | sed 's/://g'` EFFECTIVE_SMP=`cat /proc/irq/$INTERRUPT/effective_affinity_list` fio --ioengine=libaio --runtime=30s --numjobs=1 --iodepth=1 --bs=4k --rw=randwrite --filename=$DEV_NAME --time_based=1 --direct=1 --name=test --group_reporting=1 --cpus_allowed_policy=split --cpus_allowed=$EFFECTIVE_SMP关于脚本内容的详细说明,请参见如下test_plx_lat.sh脚本说明。
单击展开test_plx_lat.sh脚本说明
-
测试ESSD PL-X云盘的时延性能。
sudo sh test_plx_lat.sh your_device请您根据实际情况,将your_device修改为ESSD PL-X云盘实际的设备名,例如vdc。
-
您可以在返回结果中查看
lat (usec): min=xx, max=xxxx, avg=xx.xx, stdev=x.xx内容,表示ESSD PL-X云盘的时延。root@xxx:/tmp# sudo sh test_plx_lat.sh vdc test: (g=0): rw=randwrite, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=1 fio-3.12 Starting 1 process Jobs: 1 (f=1): [w(1)][100.0%][w=144MiB/s][w=36.9k IOPS][eta 00m:00s] test: (groupid=0, jobs=1): err= 0: pid=36816: Tue Mar 8 16:20:45 2022 write: IOPS=36.9k, BW=144MiB/s (151MB/s)(4325MiB/30001msec); 0 zone resets slat (nsec): min=1445, max=39912, avg=2015.59, stdev=392.88 clat (usec): min=14, max=4937, avg=24.60, stdev= 8.77 lat (usec): min=22, max=4939, avg=26.69, stdev= 8.77 clat percentiles (usec): | 1.00th=[ 23], 5.00th=[ 23], 10.00th=[ 24], 20.00th=[ 24], | 30.00th=[ 24], 40.00th=[ 25], 50.00th=[ 25], 60.00th=[ 25], | 70.00th=[ 25], 80.00th=[ 26], 90.00th=[ 26], 95.00th=[ 27], | 99.00th=[ 30], 99.50th=[ 32], 99.90th=[ 92], 99.95th=[ 115], | 99.99th=[ 128] bw ( KiB/s): min=141048, max=148936, per=100.00%, avg=147646.34, stdev=1235.91, samples=59 iops : min=35262, max=37234, avg=36911.56, stdev=308.97, samples=59 lat (usec) : 20=0.02%, 50=99.86%, 100=0.01%, 250=0.10%, 500=0.01% lat (usec) : 1000=0.01% lat (msec) : 2=0.01%, 4=0.01%, 10=0.01% cpu : usr=5.66%, sys=10.51%, ctx=1107304, majf=0, minf=9 IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0% submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% issued rwts: total=0,1107300,0,0 short=0,0,0,0 dropped=0,0,0,0 latency : target=0, window=0, percentile=100.00%, depth=1 Run status group 0 (all jobs): WRITE: bw=144MiB/s (151MB/s), 144MiB/s-144MiB/s (151MB/s-151MB/s), io=4325MiB (4536MB), run=30001-30001msec Disk stats (read/write): vdc: ios=51/1102570, merge=0/0, ticks=3/26754, in_queue=25568, util=85.26% -
如果返回结果为如下示例所示,表示当前测试对象存在分区或文件系统,为保证数据安全,fio脚本停止执行,建议您使用新创建的空数据盘进行测试。
[[ecs-user@ecs tmp]$ sudo sh test_plx_lat.sh vdc /dev/vdc 包含分区表或文件系统,停止 fio 脚本!
-
压测ESSD PL-X云盘IOPS
远程连接ECS实例。
具体操作,请参见使用Workbench登录Linux实例。
-
运行以下命令,查询块存储的设备名称。
sudo fdisk -lu该实例有3块块存储设备,系统盘/dev/vda、数据盘/dev/vdb、/dev/vdc。
-
运行以下命令,查询块存储设备是否存在分区和文件系统。
sudo blkid块存储设备/dev/vda与/dev/vdb上存在分区及文件系统,而结果中未存在/dev/vdc相关的回执信息,表明/dev/vdc没有分区及文件系统。
-
在测试ESSD PL-X云盘性能前,请确保已经对测试对象进行数据备份,避免数据丢失。ESSD PL-X云盘不支持快照,您可依照本地盘备份方式,将数据通过云备份定期备份、备份至OSS、备份至云盘或NAS来实现数据备份。具体操作可参考备份本地盘文件。
-
运行以下命令,安装libaio库和测试工具FIO。
sudo yum install libaio libaio-devel fio -y -
运行以下命令,切换路径。
cd /tmp -
运行以下命令,新建test_plx_iops.sh脚本。
sudo vim test_plx_iops.sh -
在test_plx_iops.sh脚本中添加以下内容。
#!/bin/bash DEV_NODE=$1 DEV_NAME=/dev/$DEV_NODE function CheckHasFS { local device=$1 # 设备路径 # 检查设备是否存在 if [ ! -b "$device" ]; then echo "错误: 设备 $device 不存在" exit 1 fi # 使用 `blkid` 命令检查分区表和文件系统类型 local pt_type=$(sudo blkid -o value -s PTTYPE "$device") local fs_type=$(sudo blkid -o value -s TYPE "$device") if [ -n "$pt_type" ] || [ -n "$fs_type" ]; then return 1 else return 0 fi } CheckHasFS "$DEV_NAME" if [ $? -eq 1 ]; then echo "$DEV_NAME 包含分区表或文件系统,停止 fio 脚本!" exit 1 fi echo 0 > /sys/block/$DEV_NODE/queue/rq_affinity sleep 5 fio --ioengine=libaio --runtime=30s --numjobs=64 --iodepth=64 --bs=4k --rw=randwrite --filename=/dev/$DEV_NODE --time_based=1 --direct=1 --name=test --group_reporting=1关于脚本内容的详细说明,请参见如下test_plx_iops.sh脚本说明。
单击展开test_plx_iops.sh脚本说明
-
运行以下命令,测试ESSD PL-X云盘的IOPS性能。
sudo sh test_plx_iops.sh your_device请您根据实际情况,将
your_device修改为ESSD PL-X云盘实际的设备名,例如vdc。-
您可以在返回结果中查看
IOPS=***内容,表示ESSD PL-X云盘的IOPS。root@xxx:olvbjfw7boZ:/tmp# sudo sh test_plx_iops.sh vdc test: (g=0): rw=randwrite, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=64 ... fio-3.12 Starting 64 processes Jobs: 64 (f=64): [w(64)][100.0%][w=11.5GiB/s][w=3002k IOPS][eta 00m:00s] test: (groupid=0, jobs=64): err= 0: pid=37033: Tue Mar 8 16:23:16 2022 write: IOPS=2943k, BW=11.2GiB/s (12.1GB/s)(337GiB/30005msec); 0 zone resets slat (nsec): min=1155, max=111174k, avg=20741.77, stdev=148830.33 clat (usec): min=56, max=72869, avg=1367.51, stdev=1385.04 lat (usec): min=62, max=72871, avg=1388.33, stdev=1399.51 clat percentiles (usec): | 1.00th=[ 379], 5.00th=[ 437], 10.00th=[ 482], 20.00th=[ 545], | 30.00th=[ 594], 40.00th=[ 676], 50.00th=[ 807], 60.00th=[ 1057], | 70.00th=[ 1467], 80.00th=[ 1958], 90.00th=[ 2704], 95.00th=[ 4047], | 99.00th=[ 7046], 99.50th=[ 7701], 99.90th=[ 8979], 99.95th=[ 9765], | 99.99th=[23462] bw ( KiB/s): min=33824, max=700984, per=1.56%, avg=183556.61, stdev=93310.00, samples=3793 iops : min= 8456, max=175246, avg=45889.13, stdev=23327.49, samples=3793 lat (usec) : 100=0.01%, 250=0.09%, 500=12.26%, 750=33.70%, 1000=12.05% lat (msec) : 2=22.60%, 4=14.23%, 10=5.03%, 20=0.03%, 50=0.01% lat (msec) : 100=0.01% cpu : usr=6.36%, sys=19.32%, ctx=7351060, majf=0, minf=653 IO depths : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=0.1%, 32=0.1%, >=64=100.0% submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.1%, >=64=0.0% issued rwts: total=0,88318243,0,0 short=0,0,0,0 dropped=0,0,0,0 latency : target=0, window=0, percentile=100.00%, depth=64 Run status group 0 (all jobs): WRITE: bw=11.2GiB/s (12.1GB/s), 11.2GiB/s-11.2GiB/s (12.1GB/s-12.1GB/s), io=337GiB (362GB), run=30005-30005msec Disk stats (read/write): vdc: ios=157/88157518, merge=0/0, ticks=28/56378887, in queue=74292632, util=100.00%说明您可以根据测试出来的IOPS大小计算该云盘的吞吐量。计算公式请参见ESSD PL-X云盘(邀测)。
-
如果返回结果为如下示例所示,表示当前测试对象存在分区或文件系统,为保证数据安全,fio脚本停止执行,建议您使用新创建的空数据盘进行测试。
[[ecs-user@ecs tmp]$ sudo sh test_plx_iops.sh vdc /dev/vdc 包含分区表或文件系统,停止 fio 脚本!
-