基準化 Hyperdisk 效能

如要進行 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 和總處理量,以模擬實際工作負載,且不遺失磁碟內容,請針對現有檔案系統中的新目錄執行基準測試。

為測試做好準備

  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 節點數量。

    NVMe 磁碟的基準化策略會因 VM 的 NUMA 節點數量而異。使用 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

測試寫入 IOPS。執行隨機寫入,且 I/O 區塊大小為 4 KB,I/O 深度則至少為 256。

  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

測試讀取 IOPS。執行隨機讀取,並使用 4 KB 的 I/O 區塊大小和至少 256 的 I/O 深度。

  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 VM 上,針對 Hyperdisk Extreme 進行 IOPS 和總處理量基準測試

Google Cloud Hyperdisk Extreme 可在 C3 VM 上提供更高的效能,並支援 176 個 vCPU。如要達到更高的效能上限,您必須將多個 Hyperdisk Extreme 磁碟區連結至 VM。

如要測量執行中 C3 VM 上作用中磁碟的每秒 I/O 數 (IOPS) 或總處理量,請針對現有檔案系統中的新目錄進行基準化,並將新的 Hyperdisk Extreme 磁碟區掛接至 VM,以執行基準化工作,這樣就能測量實際工作負載的效能,同時保留現有資料磁碟的內容。

如果是透過 NVMe 介面連結的磁碟,建議將 I/O 工作負載分配到 VM 可用的所有 NVMe 佇列。這樣可發揮 Hyperdisk 磁碟區的最大效能。在具有 176 個 vCPU 的 C3 VM 上,有四個 NUMA 節點會一對一對應至四個 NVMe 佇列。本節的基準測試會假設有這項對應。

為測試做好準備

  1. 將新的 Hyperdisk Extreme 磁碟新增至 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
    

    在本範例中,我們將測試三個 2,500 GiB Hyperdisk Extreme 磁碟區的 Google Cloud Hyperdisk 效能,裝置名稱分別為 nvme0n2nvme0n3nvme0n4

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

如要評估每秒 I/O 作業數 (IOPS) 效能,建議直接對原始磁碟 (不含 RAID) 執行平行小型 I/O 作業。

測試寫入 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

測試讀取 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 延遲時間。

測試寫入延遲

測試寫入延遲。執行隨機寫入,I/O 區塊大小為 4 KiB,I/O 深度為 4。

# 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

測試讀取延遲

測試讀取延遲。使用 4 KiB 的 I/O 區塊大小和 4 的 I/O 深度,執行隨機讀取。

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 節點數量。

    NVMe 磁碟的基準化策略會因 VM 的 NUMA 節點數量而異。使用 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 大小為 1MB,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 上限前先達到頻寬上限。

測試寫入 IOPS。執行隨機寫入,且 I/O 區塊大小為 4 KB,I/O 深度則至少為 256。

  1. 如果使用 SCSI 介面連結 Hyperdisk Extreme 磁碟區:

    # 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. 如果使用 NVMe 介面連結 Hyperdisk Extreme 磁碟區:

    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 大小為 1MB,I/O 深度則為 64 以上。

  1. 如果使用 SCSI 介面連結 Hyperdisk Extreme 磁碟區:

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

    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. 如果使用 SCSI 介面連結 Hyperdisk Extreme 磁碟區:

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

    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 的情況,會導致 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。

後續步驟