基準化 Hyperdisk 效能


如要基準測試 Hyperdisk 效能,請使用 Flexible I/O tester (FIO),而非其他磁碟基準測試工具,例如 dd。根據預設,dd 會使用非常低的 I/O 佇列深度,因此很難確保基準測試能產生足夠的位元組和 I/O 作業,以便準確測試磁碟效能。

此外,與 dd 搭配使用的特殊裝置通常速度非常慢,無法準確反映磁碟效能。一般來說,請避免在 Hyperdisk 效能基準測試中使用 /dev/urandom/dev/random/dev/zero 等特殊裝置。

如要評估在執行中執行個體上使用的磁碟的 IOPS 和處理量,請使用檔案系統的預期設定進行基準測試。使用這個選項可測試實際的工作負載,且不會遺失現有磁碟的內容。請注意,當您對現有磁碟上的檔案系統進行基準測試時,開發環境中可能有許多因素會影響基準測試結果,因此您可能無法達到磁碟效能限制

如要測量 Hyperdisk 的原始效能,請直接對區塊裝置進行基準測試。使用這個選項,將原始磁碟效能與磁碟效能限制進行比較。

下列指令適用於搭配 apt 套件管理工具的 Debian 或 Ubuntu 作業系統。

在執行中的執行個體上基準測試磁碟的 IOPS 和總處理量

如果您想在執行中的 VM 執行個體上,針對實際工作負載的有效磁碟測量 IOPS 和總處理量,且不想遺失磁碟內容,請根據現有檔案系統的新目錄進行基準測試。

準備測試

  1. 連線至執行個體

  2. 安裝依附元件:

    sudo apt update
    sudo apt install -y fio
    
  3. 如果 Hyperdisk 尚未格式化,請格式化並掛接磁碟

  4. 在終端機中,列出連接至 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

  5. 在磁碟上建立新目錄 fiotest。在這個範例中,磁碟會掛接在 /mnt/disks/mnt_dir 中:

    TEST_DIR=/mnt/disks/mnt_dir/fiotest
    sudo mkdir -p $TEST_DIR
    
  6. 如果 VM 使用 NVMe 磁碟介面進行 Hyperdisk 連結 (如果原始磁碟名稱前面有 nvme),請執行下列步驟,取得 VM 可用的 NUMA 節點數量。

    對於只有一個 NUMA 節點的 VM 和有多個 NUMA 節點的 VM,NVMe 磁碟的基準測試策略有所不同。使用 NVMe 磁碟介面測試 Hyperdisk 效能時,每個佇列只會分配 256 個 NVMe 佇列大小。由於可用的 NVMe 佇列大小有限,且可能會因連接至相同 VM 的其他磁碟而發生爭用情形,因此這些基準測試會使用兩個 NVMe 磁碟佇列,以維持可處理 256 個 iodepth 的匯總佇列大小。

    1. 取得 NUMA 節點數。

      lscpu | grep -i 'numa node(s)' | awk '{print $NF}'
      
    2. 如果 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。

  1. 如果 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
    
  2. 如果 Hyperdisk 使用 NVMe 介面:

    1. 如果 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
      
    2. 如果 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

使用 4 KB 的 I/O 區塊大小和至少 256 的 I/O 深度,執行隨機寫入作業,測試寫入 IOPS。

  1. 如果 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
    
  2. 如果 Hyperdisk 使用 NVMe 介面:

    1. 如果 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
      
    2. 如果 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。

  1. 如果 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
    
  2. 如果 Hyperdisk 使用 NVMe 介面:

    1. 如果 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
      
    2. 如果 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。

  1. 如果 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
    
  2. 如果 Hyperdisk 使用 NVMe 介面:

    1. 如果 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
      
    2. 如果 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 虛擬機器上為 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 節點,並以 1 比 1 的比例對應到四個 NVMe 佇列。本節的基準測試假設採用此對應。

準備測試

  1. 將新的極端超磁碟新增至 VM,並參閱 Hyperdisk 效能限制,找出符合目標效能所需的磁碟設定。

  2. 連線至執行個體:

  3. 安裝依附元件:

    sudo apt update
    sudo apt install -y fio
    
  4. 列出已連接至 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 效能,測試裝置為 nvme0n2nvme0n3nvme0n4,並使用三個 2,500 GiB Hyperdisk Extreme 磁碟區。

C3 上 Hyperdisk Extreme 的基準處理量

本節說明如何為 Hyperdisk Extreme 磁碟進行讀取和寫入吞吐量的基準測試。

測試準備

開始對連接至 C3 VM (176 個 vCPU) 的 Hyperdisk Extreme 磁碟進行效能基準測試前,請先完成下列步驟。

  1. 在作業系統中建立新目錄 fiotest。在此範例中,根目錄為 /mnt/disks/mnt_dir

    TEST_DIR=/mnt/disks/mnt_dir/fiotest
    sudo mkdir -p $TEST_DIR
    
  2. 由於 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
    
  3. 格式化並掛接 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 基準

如要基準測試每秒輸入/輸出 (IOPS) 效能,建議您直接在原始磁碟 (不含 RAID) 上或從原始磁碟執行並行的小型輸入/輸出作業。

測試寫入 IOPS

測試寫入 IOPS。使用隨機寫入,且 I/O 區塊大小為 4 KiB,I/O 深度至少為 256,並使用至少 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

使用 4 KiB 的 I/O 區塊大小和至少 256 的 I/O 深度,執行隨機讀取作業,並使用至少 2 個 NVMe 佇列,測試讀取 IOPS。

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

清除所用資源

  1. 移除測試檔案。

    sudo rm -rf $TEST_DIR/*
    
  2. 卸載並停止 RAID 磁碟區。

    sudo umount /dev/md0
    sudo mdadm --stop /dev/md0
    
  3. 卸離並刪除已連結的 Hyperdisk 磁碟區。請參閱 gcloud compute instances detach-diskgcloud compute disks delete 指令。

基準化原始 Hyperdisk 效能

如果您想在開發環境之外單獨評估 Hyperdisk 磁碟區的效能,可以在一次性磁碟和 VM 上測試區塊裝置的讀取和寫入效能。

下列指令假設您使用 3,500 GiB Hyperdisk Extreme 磁碟區,已連接至 VM。必須使用此磁碟大小才能達到 32 vCPU VM 總處理量上限。如果您的裝置大小不同,請修改下列指令中的 --filesize 引數。如要進一步瞭解 VM 機器類型的效能限制,請參閱「機器類型支援」。

準備測試

  1. 連線至執行個體

  2. 安裝依附元件:

    sudo apt-get update
    sudo apt-get install -y fio
    
  3. 取得原始磁碟的路徑。將路徑儲存在變數中。以下範例使用 /dev/nvme0n2 做為原始磁碟路徑:

    TEST_DIR=/dev/nvme0n2
    
  4. 為磁碟填充非零資料。空白區塊與含資料區塊的 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
    
  5. 如果 VM 使用 NVMe 磁碟介面進行 Hyperdisk 連接 (如果原始磁碟名稱前面有 nvme),請執行下列步驟,取得 VM 可用的 NUMA 節點數量。

    對於只有一個 NUMA 節點的 VM 和有多個 NUMA 節點的 VM,NVMe 磁碟的基準測試策略有所不同。使用 NVMe 磁碟介面測試 Hyperdisk 效能時,每個佇列只會分配 256 個 NVMe 佇列大小。由於可用的 NVMe 佇列大小有限,且其他磁碟連接至同一個 VM 時可能會發生爭用情形,因此這些基準測試會使用兩個 NVMe 磁碟佇列,以維持可處理 256 個 iodepth 的匯總佇列大小。

    1. 取得 NUMA 節點數。

      lscpu | grep -i 'numa node(s)' | awk '{print $NF}'
      
    2. 如果 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 以上。

  1. 如果 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
    
  2. 如果 Hyperdisk 使用 NVMe 介面:

    1. 如果 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
      
    2. 如果 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 毫秒,則針對每項傳輸中的 I/O,VM 最高可達到 1,000 IOPS。如要達到 15,000 IOPS,VM 必須維持至少 15 個傳輸中的 I/O 作業。如果您的磁碟和 VM 能夠達到 30,000 IOPS,則至少要有 30 個傳輸中的 I/O 作業。如果 I/O 大小超過 4 KB,VM 可能會在達到 IOPS 上限前先達到頻寬上限。

使用 4 KB 的 I/O 區塊大小和至少 256 的 I/O 深度,執行隨機寫入作業,測試寫入 IOPS。

  1. 如果 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
    
  2. 如果 Hyperdisk Extreme 磁碟區是使用 NVMe 介面連接:

    1. 如果 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
      
    2. 如果 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 延遲狀況。舉例來說,如果 I/O 深度為 30 時會達到 IOPS 上限,且 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 個以上) 使用循序讀取,且 I/O 大小為 1 MB,I/O 深度則為至少 64。

  1. 如果 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
  2. 如果 Hyperdisk Extreme 磁碟區是使用 NVMe 介面連接:

    1. 如果 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
    2. 如果 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

  1. 如果 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
    
  2. 如果 Hyperdisk Extreme 磁碟區是使用 NVMe 介面連接:

    1. 如果 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
      
    2. 如果 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。

後續步驟