如要對 Google Cloud Hyperdisk 效能進行基準測試,請使用彈性 I/O 測試工具 (FIO),而非其他磁碟基準測試工具,例如 dd。根據預設,dd 使用的 I/O 佇列深度非常低,因此難以確保基準測試會產生足夠的位元組和 I/O 作業,以準確測試磁碟效能。
此外,與 dd 搭配使用的特殊裝置通常速度很慢,無法準確反映磁碟效能。一般來說,請避免在 Hyperdisk 效能基準測試中使用 /dev/urandom、/dev/random 和 /dev/zero 等特殊裝置。
如要評估執行中執行個體上使用中磁碟的 IOPS 和處理量,請使用預期設定對檔案系統進行基準測試。使用這個選項,即可測試實際工作負載,而不會遺失現有磁碟的內容。請注意,在現有磁碟上對檔案系統進行基準測試時,開發環境特有的許多因素可能會影響基準測試結果,而且您可能無法達到磁碟效能限制。
如要評估 Hyperdisk 的原始效能,請直接對區塊裝置進行基準測試。使用這個選項,比較原始磁碟效能與 Hyperdisk 效能限制。
下列指令適用於搭載 apt 套件管理工具的 Debian 或 Ubuntu 作業系統。
對執行中執行個體的磁碟 IOPS 和處理量進行基準測試
如要針對執行中 VM 執行個體上的有效磁碟,評估實際工作負載的 IOPS 和處理量,同時不遺失磁碟內容,請對現有檔案系統上的新目錄進行基準測試。
準備測試
安裝依附元件:
sudo apt update sudo apt install -y fio如果 Hyperdisk 磁碟區尚未格式化,請格式化並掛接磁碟。
在終端機中,列出連接至 VM 的磁碟,並找出要測試的磁碟。
sudo lsblk上述指令會產生類似以下的輸出內容:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT nvme0n1 259:0 0 10G 0 disk ├─nvme0n1p1 259:1 0 9.9G 0 part / ├─nvme0n1p14 259:2 0 4M 0 part └─nvme0n1p15 259:3 0 106M 0 part /boot/efi nvme0n2 259:4 0 3.4T 0 disk
在這個範例中,我們要測試 3,500 GiB 的 Hyperdisk Extreme 磁碟區,裝置名稱為
nvme0n2。在磁碟上建立新目錄
fiotest。在本範例中,磁碟掛接在/mnt/disks/mnt_dir:TEST_DIR=/mnt/disks/mnt_dir/fiotest sudo mkdir -p $TEST_DIR如果 VM 使用 NVMe 磁碟介面連接 Hyperdisk 磁碟區 (原始磁碟名稱開頭為
nvme),請按照下列步驟操作,取得 VM 可用的 NUMA 節點數量。NVMe 磁碟的基準測試策略,會因 VM 只有一個 NUMA 節點或有多個 NUMA 節點而異。使用 NVMe 磁碟介面測試 Hyperdisk 效能時,每個佇列只會分配 256 個 NVMe 佇列大小。由於可用的 NVMe 佇列大小有限,且連接至同一 VM 的其他磁碟可能發生爭用,因此這些基準測試會使用兩個 NVMe 磁碟佇列,以維持可處理 256 個 iodepth 的匯總佇列大小。
取得 NUMA 節點數量。
lscpu | grep -i 'numa node(s)' | awk '{print $NF}'如果 VM 只有 1 個 NUMA 節點,請取得 CPU 到 NVMe 佇列的對應關係。您稍後會將這項資訊用於
--cpus-allowed參數。QUEUE_1_CPUS=$(cat /sys/class/block/nvme0n2/mq/*/cpu_list | sed -n 1p | tr -d " \t") QUEUE_2_CPUS=$(cat /sys/class/block/nvme0n2/mq/*/cpu_list | sed -n 2p | tr -d " \t")
測試寫入處理量
使用多個平行串流 (16 個以上) 執行依序寫入,並使用 1 MB 的 I/O 區塊大小和至少 64 的 I/O 深度,測試寫入處理量。
如果 Hyperdisk 磁碟區使用 SCSI 介面:
sudo fio --directory=$TEST_DIR \ --numjobs=16 --size=10G --time_based \ --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=1M --iodepth=64 --rw=write \ --iodepth_batch_submit=64 --iodepth_batch_complete_max=64 \ --name=write_throughput
如果 Hyperdisk 磁碟區使用 NVMe 介面:
如果 VM 只有一個 NUMA 節點,請使用下列指令:
sudo fio --directory=$TEST_DIR --numjobs=8 \ --size=10G --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=1M --iodepth=64 --rw=write \ --iodepth_batch_submit=64 --iodepth_batch_complete_max=64 \ --cpus_allowed_policy=split \ --group_reporting \ --name=write_throughput --cpus_allowed=$QUEUE_1_CPUS \ --name=write_throughput_2 --cpus_allowed=$QUEUE_2_CPUS
如果 VM 有多個 NUMA 節點,請使用下列指令:
sudo fio --directory=$TEST_DIR --numjobs=8 \ --size=10G --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=1M --iodepth=64 --rw=write \ --iodepth_batch_submit=64 --iodepth_batch_complete_max=64 \ --group_reporting \ --name=write_throughput --numa_cpu_nodes=0 \ --name=write_throughput_2 --numa_cpu_nodes=1
測試寫入 IOPS
執行隨機寫入作業,測試寫入 IOPS,I/O 區塊大小為 4 KB,I/O 深度至少為 256。
如果 Hyperdisk 磁碟區是使用 SCSI 介面連接:
sudo fio --directory=$TEST_DIR \ --numjobs=16 --size=10G -time_based \ --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=256 --rw=randwrite \ --iodepth_batch_submit=256 --iodepth_batch_complete_max=256 \ --name=write_iops
如果 Hyperdisk 磁碟區使用 NVMe 介面:
如果 VM 只有一個 NUMA 節點,請使用下列指令:
sudo fio --directory=$TEST_DIR --numjobs=8 \ --size=10G --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=256 --rw=randwrite \ --iodepth_batch_submit=256 --iodepth_batch_complete_max=256 \ --cpus_allowed_policy=split \ --group_reporting \ --name=write_iops --cpus_allowed=$QUEUE_1_CPUS \ --name=write_iops_2 --cpus_allowed=$QUEUE_2_CPUS
如果 VM 有多個 NUMA 節點,請使用下列指令:
sudo fio --directory=$TEST_DIR --numjobs=8 --size=10G \ --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=256 --rw=randwrite \ --iodepth_batch_submit=256 --iodepth_batch_complete_max=256 \ --group_reporting \ --name=write_iops --numa_cpu_nodes=0 \ --name=write_iops_2 --numa_cpu_nodes=1
測試讀取處理量
使用多個平行串流 (16 個以上) 執行循序讀取、I/O 區塊大小為 1 MB,且 I/O 深度至少為 64,藉此測試讀取總處理量。
如果 Hyperdisk 磁碟區使用 SCSI 介面:
sudo fio --directory=$TEST_DIR \ --numjobs=16 --size=10G --time_based \ --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=1M --iodepth=64 --rw=read \ --iodepth_batch_submit=64 --iodepth_batch_complete_max=64 \ --name=read_throughput
如果 Hyperdisk 磁碟區使用 NVMe 介面:
如果 VM 只有一個 NUMA 節點,請使用下列指令:
sudo fio --directory=$TEST_DIR --numjobs=8 --size=10G \ --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=1M --iodepth=64 --rw=read \ --iodepth_batch_submit=64 --iodepth_batch_complete_max=64 \ --cpus_allowed_policy=split \ --group_reporting \ --name=read_throughput --cpus_allowed=$QUEUE_1_CPUS \ --name=read_throughput_2 --cpus_allowed=$QUEUE_2_CPUS
如果 VM 有多個 NUMA 節點,請使用下列指令:
sudo fio --directory=$TEST_DIR --numjobs=8 --size=10G \ --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=1M --iodepth=64 --rw=read \ --iodepth_batch_submit=64 --iodepth_batch_complete_max=64 \ --group_reporting \ --name=read_throughput --numa_cpu_nodes=0 \ --name=read_throughput_2 --numa_cpu_nodes=1
測試讀取 IOPS
執行隨機讀取,使用 4 KB 的 I/O 區塊大小和至少 256 的 I/O 深度,測試讀取 IOPS。
如果 Hyperdisk 磁碟區使用 SCSI 介面:
sudo fio --directory=$TEST_DIR \ --numjobs=16 --size=10G --time_based \ --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=256 --rw=randread \ --iodepth_batch_submit=256 --iodepth_batch_complete_max=256 \ --name=read_iops
如果 Hyperdisk 磁碟區使用 NVMe 介面:
如果 VM 只有一個 NUMA 節點,請使用下列指令:
sudo fio --directory=$TEST_DIR --numjobs=8 --size=10G \ --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=256 --rw=randread \ --iodepth_batch_submit=256 --iodepth_batch_complete_max=256 \ --cpus_allowed_policy=split \ --group_reporting \ --name=read_iops --cpus_allowed=$QUEUE_1_CPUS \ --name=read_iops_2 --cpus_allowed=$QUEUE_2_CPUS
如果 VM 有多個 NUMA 節點,請使用下列指令:
sudo fio --directory=$TEST_DIR --numjobs=8 --size=10G \ --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=256 --rw=randread \ --iodepth_batch_submit=256 --iodepth_batch_complete_max=256 \ --group_reporting \ --name=read_iops --numa_cpu_nodes=0 \ --name=read_iops_2 --numa_cpu_nodes=1
清除所用資源
移除測試目錄。
sudo rm $TEST_DIR/write* $TEST_DIR/read*
在 C3 VM 上對 Hyperdisk Extreme 的 IOPS 和總處理量進行基準測試
Google Cloud Hyperdisk Extreme 可在搭載 176 個 vCPU 的 C3 VM 上提供更高的效能。如要達到更高的效能上限,必須將多個 Hyperdisk Extreme 磁碟區附加至 VM。
如要評估執行中 C3 VM 上使用中磁碟的實際工作負載每秒 I/O (IOPS) 或處理量,且不遺失現有資料磁碟的內容,請對現有檔案系統上的新目錄進行基準測試,並將新的 Hyperdisk Extreme 磁碟區附加至 VM,以便執行基準測試工作。
如果磁碟是透過 NVMe 介面連結,建議將 I/O 工作負載分配到 VM 可用的所有 NVMe 佇列。這能充分發揮 Hyperdisk 磁碟區的效能。在具有 176 個 vCPU 的 C3 VM 上,有四個 NUMA 節點,一對一對應至四個 NVMe 佇列。本節的基準測試會假設採用這項對應關係。
準備測試
將新的 Hyperdisk Extreme 磁碟新增至 VM,並參閱 Hyperdisk 效能限制,瞭解如何設定磁碟以達到目標效能。
連線至執行個體:
安裝依附元件:
sudo apt update sudo apt install -y fio列出連接至 VM 的磁碟,並找出要測試的磁碟。
sudo lsblk上述指令會產生類似以下的輸出內容:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT nvme0n1 259:0 0 10G 0 disk ├─nvme0n1p1 259:1 0 9.9G 0 part / ├─nvme0n1p14 259:2 0 4M 0 part └─nvme0n1p15 259:3 0 106M 0 part /boot/efi nvme0n2 259:4 0 2.5T 0 disk nvme0n3 259:5 0 2.5T 0 disk nvme0n4 259:6 0 2.5T 0 disk
在這個範例中,我們將測試 Google Cloud Hyperdisk 的效能,使用三個 2,500 GiB Hyperdisk Extreme 磁碟區,裝置名稱分別為
nvme0n2、nvme0n3和nvme0n4。
C3 上 Hyperdisk Extreme 的基準處理量
本節說明如何對 Hyperdisk Extreme 磁碟的讀取和寫入處理量進行基準測試。
準備測試
開始對連接至 176 個 vCPU C3 VM 的 Hyperdisk Extreme 磁碟進行效能基準測試前,請先完成下列步驟。
在作業系統中建立新目錄
fiotest。在本範例中,根目錄為/mnt/disks/mnt_dir:TEST_DIR=/mnt/disks/mnt_dir/fiotest sudo mkdir -p $TEST_DIR由於 VM 需要多個磁碟才能達到最高效能等級,為求簡便,請在所有連接的 Hyperdisk 磁碟區上執行 RAID 0。這樣一來,資料就能更輕鬆地平均分配到多個 Hyperdisk 磁碟區。
在這個範例中,RAID 0 是在連接至 C3 VM 的三個 Hyperdisk Extreme 磁碟區上執行。
sudo mdadm --create /dev/md0 --level=0 --raid-devices=3 /dev/nvme0n2 /dev/nvme0n3 /dev/nvme0n4
格式化並掛接 RAID 磁碟區
/dev/md0。
測試寫入處理量
如要測試寫入處理量,請使用多個平行串流 (至少 16 個) 執行依序寫入,I/O 區塊大小為 1 MiB,每個 NVMe 佇列的總 I/O 深度至少為 32。
# Running this command causes data loss on the targeted file on the device. # We strongly recommend using a throwaway disk. sudo fio --name=global --group_reporting=1 --filesize=1024G \ --filename=$TEST_DIR/fiotestfile --numjobs=4 --size=64G \ --offset_increment=64G --time_based --runtime=5m \ --ramp_time=10s --ioengine=libaio --direct=1 --verify=0 \ --bs=1M --iodepth=8 --rw=write \ --name=write_throughput --numa_cpu_nodes=0 \ --name=write_throughput_1 --numa_cpu_nodes=1 \ --name=write_throughput_2 --numa_cpu_nodes=2 \ --name=write_throughput_3 --numa_cpu_nodes=3
測試讀取處理量
如要測試讀取處理量,請使用多個平行串流 (至少 16 個) 執行依序讀取,I/O 區塊大小為 1 MiB,每個 NVMe 佇列的總 I/O 深度至少為 32。
sudo fio --name=global --group_reporting=1 --filesize=1024G \ --filename=$TEST_DIR/fiotestfile --numjobs=4 --size=64G \ --offset_increment=64G --time_based --runtime=5m \ --ramp_time=10s --ioengine=libaio --direct=1 \ --verify=0 --bs=1M --iodepth=8 --rw=read \ --name=read_throughput --numa_cpu_nodes=0 \ --name=read_throughput_1 --numa_cpu_nodes=1 \ --name=read_throughput_2 --numa_cpu_nodes=2 \ --name=read_throughput_3 --numa_cpu_nodes=3
C3 上 Hyperdisk Extreme 的基準 IOPS
如要對每秒 I/O (IOPS) 效能進行基準測試,建議您直接對原始磁碟 (不含 RAID) 執行平行小型 I/O 作業。
測試寫入 IOPS
執行隨機寫入作業來測試寫入 IOPS,使用 4 KiB 的 I/O 區塊大小和至少 256 的 I/O 深度,並使用至少 2 個 NVMe 佇列。
# Running this command causes data loss on the targeted device. # We strongly recommend using a throwaway disk. sudo fio --name=global --group_reporting=1 \ --directory=/ --bs=4K --direct=1 \ --filesize=512G --iodepth=256 \ --iodepth_batch_complete_max=256 --iodepth_batch_submit=256 \ --ioengine=libaio --numjobs=5 --ramp_time=10s \ --randrepeat=0 --runtime=5m --rw=randwrite \ --time_based=1 --verify=0 \ --name=write_iops_test --filename=/dev/nvme0n2 --numa_cpu_nodes=0 \ --name=write_iops_test_1 --filename=/dev/nvme0n3 --numa_cpu_nodes=1 \ --name=write_iops_test_2 --filename=/dev/nvme0n4 --numa_cpu_nodes=2
測試讀取 IOPS
執行隨機讀取作業來測試讀取 IOPS,使用 4 KiB 的 I/O 區塊大小和至少 256 的 I/O 深度,並使用至少 2 個 NVMe 佇列。
sudo fio --name=global --group_reporting=1 --directory=/ \ --bs=4K --direct=1 --filesize=512G --iodepth=256 \ --iodepth_batch_complete_max=256 --iodepth_batch_submit=256 \ --ioengine=libaio --numjobs=5 --ramp_time=10s \ --randrepeat=0 --runtime=5m --rw=randread \ --time_based=1 --verify=0 \ --name=read_iops_test --filename=/dev/nvme0n2 --numa_cpu_nodes=0 \ --name=read_iops_test_1 --filename=/dev/nvme0n3 --numa_cpu_nodes=1 \ --name=read_iops_test_2 --filename=/dev/nvme0n4 --numa_cpu_nodes=2
C3 上 Hyperdisk Extreme 的基準測試延遲時間
測試 I/O 延遲時間時,VM 不得達到頻寬或 IOPS 上限。否則觀察到的延遲時間不會反映實際的 Hyperdisk I/O 延遲時間。舉例來說,如果 VM 在 I/O 深度為 30 時達到 IOPS 限制,且 fio 指令將該值加倍,則總 IOPS 保持不變,回報的 I/O 延遲時間則會加倍。
只要直接指定單一原始磁碟裝置,即可取得實際的 I/O 延遲時間。
測試寫入延遲
執行隨機寫入作業,測試寫入延遲時間,使用 4 KiB 的 I/O 區塊大小和 4 的 I/O 深度。
# Running this command causes data loss on the targeted device. # We strongly recommend using a throwaway disk. sudo fio --filename=/dev/nvme0n2 \ --filesize=512G --time_based \ --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=4 --rw=randwrite \ --iodepth_batch_submit=4 --iodepth_batch_complete_max=4 \ --name=write_latency
測試讀取延遲時間
執行隨機讀取作業,測試讀取延遲時間,I/O 區塊大小為 4 KiB,I/O 深度為 4。
sudo fio --filename=/dev/nvme0n2 \ --filesize=512G --time_based \ --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=4 --rw=randread \ --iodepth_batch_submit=4 --iodepth_batch_complete_max=4 \ --name=read_latency
清除所用資源
移除測試檔案。
sudo rm -rf $TEST_DIR/*卸載並停止 RAID 磁碟區。
sudo umount /dev/md0 sudo mdadm --stop /dev/md0卸載並刪除已連接的 Hyperdisk 磁碟區。請參閱
gcloud compute instances detach-disk和gcloud compute disks delete指令。
基準測試原始 Hyperdisk 效能
如要單獨評估 Hyperdisk 磁碟區的效能,不考慮開發環境,可以測試拋棄式磁碟和 VM 上區塊裝置的讀寫效能。
下列指令假設 VM 附加了 3,500 GiB 的 Hyperdisk Extreme 磁碟區。必須達到這個磁碟大小,才能達到 32 個 vCPU VM 的處理量限制。如果裝置大小不同,請修改下列指令中 --filesize 引數的值。如要進一步瞭解 VM 機型的效能限制,請參閱「機型支援」。
準備測試
安裝依附元件:
sudo apt-get update sudo apt-get install -y fio取得原始磁碟的路徑。將路徑儲存在變數中。下列範例使用
/dev/nvme0n2做為原始磁碟路徑:TEST_DIR=/dev/nvme0n2為磁碟填充非零資料。Hyperdisk 從空白區塊讀取資料時,延遲時間模式與包含資料的區塊不同。建議您執行任何讀取延遲基準前先填充磁碟。
# Running this command causes data loss on the second device. # We strongly recommend using a throwaway VM and disk. sudo fio --name=fill_disk \ --filename=$TEST_DIR --filesize=2500G \ --ioengine=libaio --direct=1 --verify=0 --randrepeat=0 \ --bs=128K --iodepth=64 --rw=randwrite \ --iodepth_batch_submit=64 --iodepth_batch_complete_max=64
如果 VM 使用 NVMe 磁碟介面連接 Hyperdisk (原始磁碟名稱開頭為
nvme),請按照下列步驟操作,取得 VM 可用的 NUMA 節點數量。NVMe 磁碟的基準測試策略,會因 VM 只有一個 NUMA 節點或有多個 NUMA 節點而異。使用 NVMe 磁碟介面測試 Hyperdisk 效能時,每個佇列只會分配 256 個 NVMe 佇列大小。由於可用的 NVMe 佇列大小有限,且連接至相同 VM 的其他磁碟可能發生爭用,因此這些基準測試會使用兩個 NVMe 磁碟佇列,維持可處理 256 個 iodepth 的匯總佇列大小。
取得 NUMA 節點數量。
lscpu | grep -i 'numa node(s)' | awk '{print $NF}'如果 VM 只有 1 個 NUMA 節點,請取得 CPU 到 NVMe 佇列的對應關係。您稍後會將這項資訊用於
--cpus-allowed參數。QUEUE_1_CPUS=$(cat /sys/class/block/nvme0n2/mq/*/cpu_list | sed -n 1p | tr -d " \t") QUEUE_2_CPUS=$(cat /sys/class/block/nvme0n2/mq/*/cpu_list | sed -n 2p | tr -d " \t")
測試寫入處理量
如要測試寫入處理量,請使用多個平行串流 (16 個以上) 執行依序寫入,並將 I/O 大小設為 1 MB,I/O 深度設為 64 以上。
如果 Hyperdisk 是透過 SCSI 介面連接:
# Running this command causes data loss on the second device. # We strongly recommend using a throwaway VM and disk. sudo fio --filename=$TEST_DIR \ --numjobs=16 --size=500G --time_based \ --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=1M --iodepth=64 --rw=write \ --iodepth_batch_submit=64 --iodepth_batch_complete_max=64 \ --offset_increment=20G \ --name=write_throughput
如果 Hyperdisk 磁碟區使用 NVMe 介面:
如果 VM 只有一個 NUMA 節點,請使用下列指令:
# Running this command causes data loss on the second device. # We strongly recommend using a throwaway VM and disk. sudo fio --filename=$TEST_DIR --numjobs=8 --size=500G \ --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=1M --iodepth=64 --rw=write \ --iodepth_batch_submit=64 --iodepth_batch_complete_max=64 \ --cpus_allowed_policy=split \ --offset_increment=20G --group_reporting \ --name=write_throughput --cpus_allowed=$QUEUE_1_CPUS \ --name=write_throughput_2 --cpus_allowed=$QUEUE_2_CPUS
如果 VM 有多個 NUMA 節點,請使用下列指令:
# Running this command causes data loss on the second device. # We strongly recommend using a throwaway VM and disk. sudo fio --filename=$TEST_DIR --numjobs=8 --size=500G \ --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=1M --iodepth=64 --rw=write \ --iodepth_batch_submit=64 --iodepth_batch_complete_max=64 \ --offset_increment=20G --group_reporting \ --name=write_throughput --numa_cpu_nodes=0 \ --name=write_throughput_2 --numa_cpu_nodes=1
測試寫入 IOPS
如要達到 Hyperdisk IOPS 上限,您必須維持較深的 I/O 佇列。舉例來說,如果寫入延遲時間為 1 毫秒,則 VM 每個傳輸中的 I/O 最多可達到 1,000 IOPS。如要達到 15,000 次寫入 IOPS,VM 必須維持至少 15 次執行中的 I/O 作業。如果磁碟和 VM 可達到 30,000 次寫入 IOPS,則執行中的 I/O 作業數量必須至少為 30。如果 I/O 大小超過 4 KB,VM 可能會在達到 IOPS 限制前,先達到頻寬限制。
執行隨機寫入作業,測試寫入 IOPS,I/O 區塊大小為 4 KB,I/O 深度至少為 256。
如果 Hyperdisk Extreme 磁碟區是使用 SCSI 介面連接:
# Running this command causes data loss on the second device. # We strongly recommend using a throwaway VM and disk. sudo fio --filename=$TEST_DIR \ --numjobs=16 --size=500G -time_based \ --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=256 --rw=randwrite \ --iodepth_batch_submit=256 --iodepth_batch_complete_max=256 \ --name=write_iops
如果 Hyperdisk Extreme 磁碟區是使用 NVMe 介面連接:
如果 VM 只有一個 NUMA 節點,請使用下列指令:
# Running this command causes data loss on the second device. # We strongly recommend using a throwaway VM and disk. sudo fio --filename=$TEST_DIR --numjobs=8 --size=500G \ --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=256 --rw=randwrite \ --iodepth_batch_submit=256 --iodepth_batch_complete_max=256 \ --cpus_allowed_policy=split \ --group_reporting \ --name=write_write_iops --cpus_allowed=$QUEUE_1_CPUS \ --name=write_write_iops_2 --cpus_allowed=$QUEUE_2_CPUS
如果 VM 有多個 NUMA 節點,請使用下列指令:
# Running this command causes data loss on the second device. # We strongly recommend using a throwaway VM and disk. sudo fio --filename=$TEST_DIR --numjobs=8 --size=500G \ --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=256 --rw=randwrite \ --iodepth_batch_submit=256 --iodepth_batch_complete_max=256 \ --group_reporting \ --name=write_iops --numa_cpu_nodes=0 \ --name=write_iops_2 --numa_cpu_nodes=1
測試寫入延遲
測試 I/O 延遲時間時,VM 不得達到頻寬或 IOPS 上限,否則觀察到的延遲時間不會反映實際的 Hyperdisk I/O 延遲時間。舉例來說,如果 IOPS 限制在 I/O 深度為 30 時達到,且 fio 指令已將該值加倍,則總 IOPS 保持不變,且回報的 I/O 延遲時間會加倍。
# Running this command causes data loss on the second device. # We strongly recommend using a throwaway VM and disk. sudo fio --filename=$TEST_DIR \ --filesize=500G --time_based \ --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=4 --rw=randwrite \ --iodepth_batch_submit=4 --iodepth_batch_complete_max=4 \ --name=write_latency
測試讀取頻寬
使用多個平行串流 (16 個以上) 執行循序讀取,並使用 1 MB 的 I/O 大小和至少 64 的 I/O 深度,測試讀取頻寬。
如果 Hyperdisk Extreme 磁碟區是使用 SCSI 介面連接:
sudo fio --filename=$TEST_DIR \ --numjobs=16 --size=500G --time_based \ --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=1M --iodepth=64 --rw=read \ --iodepth_batch_submit=64 --iodepth_batch_complete_max=64 \ --offset_increment=20G --name=read_bandwidth
如果 Hyperdisk Extreme 磁碟區是使用 NVMe 介面連接:
如果 VM 只有一個 NUMA 節點,請使用下列指令:
sudo fio --filename=$TEST_DIR --numjobs=8 --size=500G \ --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=1M --iodepth=64 --rw=read \ --iodepth_batch_submit=64 --iodepth_batch_complete_max=64 \ --cpus_allowed_policy=split \ --offset_increment=20G --group_reporting \ --name=read_bandwidth --cpus_allowed=$QUEUE_1_CPUS \ --name=read_bandwidth_2 --cpus_allowed=$QUEUE_2_CPUS
如果 VM 有多個 NUMA 節點,請使用下列指令:
sudo fio --filename=$TEST_DIR --numjobs=8 --size=500G \ --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=1M --iodepth=64 --rw=read \ --iodepth_batch_submit=64 --iodepth_batch_complete_max=64 \ --offset_increment=20G --group_reporting \ --name=read_bandwidth --numa_cpu_nodes=0 \ --name=read_bandwidth_2 --numa_cpu_nodes=1
測試讀取 IOPS
如要達到 Hyperdisk IOPS 上限,必須維持深度 I/O 佇列。舉例來說,如果 I/O 大小超過 4 KB,VM 可能會在達到 IOPS 限制前,就先達到頻寬限制。如要達到機型可用的最大讀取 IOPS,請為這項測試指定 --iodepth=256。
如果 Hyperdisk Extreme 磁碟區是使用 SCSI 介面連接:
sudo fio --filename=$TEST_DIR \ --numjobs=16 --size=500G --time_based \ --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=256 --rw=randread \ --iodepth_batch_submit=256 --iodepth_batch_complete_max=256 \ --name=read_iops
如果 Hyperdisk Extreme 磁碟區是使用 NVMe 介面連接:
如果 VM 只有一個 NUMA 節點,請使用下列指令:
sudo fio --filename=$TEST_DIR --numjobs=8 --size=500G \ --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=256 --rw=randread \ --iodepth_batch_submit=256 --iodepth_batch_complete_max=256 \ --cpus_allowed_policy=split \ --group_reporting \ --name=read_iops --cpus_allowed=$QUEUE_1_CPUS \ --name=read_iops_2 --cpus_allowed=$QUEUE_2_CPUS
如果 VM 有多個 NUMA 節點,請使用下列指令:
sudo fio --filename=$TEST_DIR --numjobs=8 --size=500G \ --time_based --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=256 --rw=randread \ --iodepth_batch_submit=256 --iodepth_batch_complete_max=256 \ --group_reporting \ --name=read_iops --numa_cpu_nodes=0 \ --name=read_iops_2 --numa_cpu_nodes=1
測試讀取延遲時間
請務必在磁碟中填入資料,才能取得實際的延遲時間測量結果。請務必確保 VM 在測試期間不會達到 IOPS 或處理量限制,因為 Hyperdisk 磁碟區達到飽和限制後,就會拒絕傳入的 I/O 作業。這項延後作業會反映為 I/O 延遲時間的人為增加。
sudo fio --filename=$TEST_DIR \ --filesize=500G --time_based \ --runtime=5m --ramp_time=10s --ioengine=libaio \ --direct=1 --verify=0 --bs=4K --iodepth=4 --rw=randread \ --iodepth_batch_submit=4 --iodepth_batch_complete_max=4 \ --name=read_latency
清除所用資源
如果您按照建議使用拋棄式磁碟和 VM,完成基準測試後,可以:
- 卸離並刪除磁碟。
- 刪除 VM。
後續步驟
- 瞭解 Hyperdisk 定價。