Linux VM에서 영구 디스크 성능 벤치마킹


영구 디스크 성능을 벤치마킹하려면 dd와 같은 다른 디스크 벤치마킹 도구 대신 가변형 I/O 테스터(FIO)를 사용하세요. 기본적으로 dd는 매우 얕은 I/O 큐 깊이를 사용하므로 벤치마크에서 디스크 성능을 정확하게 테스트하기에 충분한 수의 I/O 및 바이트를 생성하기 어렵습니다.

또한 dd와 함께 사용되는 특수 기기는 매우 느려 영구 디스크 성능을 정확하게 반영하지 못합니다. 일반적으로 영구 디스크 성능 벤치마크에 /dev/urandom, /dev/random, /dev/zero와 같은 특수 기기를 사용하지 마세요.

실행 중인 인스턴스에서 사용되는 디스크의 IOPS와 처리량을 측정하려면 원하는 구성으로 파일 시스템을 벤치마킹합니다. 이 옵션을 사용하면 기존 디스크의 콘텐츠가 손실되는 일 없이 실제 워크로드를 테스트할 수 있습니다. 기존 디스크의 파일 시스템을 벤치마킹할 때 개발 환경에 특정한 많은 요소가 벤치마킹 결과에 영향을 미칠 수 있으며 디스크 성능 한도에 도달하지 않을 수 있습니다.

영구 디스크의 원시 성능을 측정하려면 블록 기기를 직접 벤치마킹합니다. 이 옵션을 사용하면 원시 디스크 성능을 디스크 성능 한도와 비교할 수 있습니다.

다음 명령어는 apt 패키지 관리자를 사용하는 Debian 또는 Ubuntu 운영체제에서 작동합니다.

실행 중인 인스턴스에서 디스크의 IOPS 및 처리량 벤치마킹

디스크의 콘텐츠가 손실되지 않으면서 실행 중인 인스턴스의 활성 디스크에 있는 실제 워크로드의 IOPS와 처리량을 측정하려면 기존 파일 시스템의 새 디렉터리를 기준으로 벤치마킹합니다.

  1. 인스턴스에 연결

  2. 종속 항목을 설치합니다.

    sudo apt update
    sudo apt install -y fio
    
  3. 터미널에서 VM에 연결된 디스크를 나열하고 테스트할 디스크를 찾습니다. 영구 디스크가 아직 포맷되지 않았으면 디스크를 포맷하고 마운트합니다.

    sudo lsblk
    
    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda      8:0    0   10G  0 disk
    └─sda1   8:1    0   10G  0 part /
    sdb      8:32   0  2.5T  0 disk /mnt/disks/mnt_dir
    

    이 예시에서는 기기 ID가 sdb인 2,500GB SSD 영구 디스크를 테스트합니다.

  4. 디스크에 새 디렉터리 fiotest를 만듭니다. 이 예시에서는 디스크가 /mnt/disks/mnt_dir에 마운트됩니다.

    TEST_DIR=/mnt/disks/mnt_dir/fiotest
    sudo mkdir -p $TEST_DIR
    
  5. I/O 블록 크기를 1MB로 설정하고 I/O 깊이를 64 이상으로 설정한 상태로 여러 동시 스트림(16개 이상)에 순차적 쓰기를 수행하여 쓰기 처리량을 테스트합니다.

    sudo fio --name=write_throughput --directory=$TEST_DIR --numjobs=16 \
    --size=10G --time_based --runtime=60s --ramp_time=2s --ioengine=libaio \
    --direct=1 --verify=0 --bs=1M --iodepth=64 --rw=write \
    --group_reporting=1 --iodepth_batch_submit=64 \
    --iodepth_batch_complete_max=64
    
  6. I/O 블록 크기를 4KB로 설정하고 I/O 깊이를 256 이상으로 설정한 상태로 무작위 쓰기를 수행하여 쓰기 IOPS를 테스트합니다.

     sudo fio --name=write_iops --directory=$TEST_DIR --size=10G \
    --time_based --runtime=60s --ramp_time=2s --ioengine=libaio --direct=1 \
    --verify=0 --bs=4K --iodepth=256 --rw=randwrite --group_reporting=1  \
    --iodepth_batch_submit=256  --iodepth_batch_complete_max=256
    
  7. I/O 블록 크기를 1MB로 설정하고 I/O 깊이를 최소 64 이상으로 설정한 상태로 여러 동시 스트림(16개 이상)에 순차적 읽기를 수행하여 읽기 처리량을 테스트합니다.

    sudo fio --name=read_throughput --directory=$TEST_DIR --numjobs=16 \
    --size=10G --time_based --runtime=60s --ramp_time=2s --ioengine=libaio \
    --direct=1 --verify=0 --bs=1M --iodepth=64 --rw=read \
    --group_reporting=1 \
    --iodepth_batch_submit=64 --iodepth_batch_complete_max=64
    
  8. I/O 블록 크기를 4KB로 설정하고 I/O 깊이를 256 이상으로 설정해서 무작위 읽기를 수행하여 읽기 IOPS를 테스트합니다.

    sudo fio --name=read_iops --directory=$TEST_DIR --size=10G \
    --time_based --runtime=60s --ramp_time=2s --ioengine=libaio --direct=1 \
    --verify=0 --bs=4K --iodepth=256 --rw=randread --group_reporting=1 \
    --iodepth_batch_submit=256  --iodepth_batch_complete_max=256
    
  9. 삭제:

    sudo rm $TEST_DIR/write* $TEST_DIR/read*
    

원시 영구 디스크 성능 벤치마킹

개발 환경 밖에서 영구 디스크의 성능만 측정하려면 폐기 영구 디스크와 VM에서 블록 기기의 읽기 및 쓰기 성능을 테스트합니다.

다음 명령어는 2,500GB SSD 영구 디스크가 VM에 연결되어 있다고 가정합니다. 기기 크기가 이와 다르면 --filesize 인수 값을 수정합니다. 이 디스크 크기는 vCPU가 32개인 VM의 처리량 한도를 달성하는 데 필요합니다. 자세한 내용은 블록 스토리지 성능을 참조하세요.

  1. 인스턴스에 연결

  2. 종속 항목을 설치합니다.

    sudo apt-get update
    sudo apt-get install -y fio
    
  3. 디스크를 0이 아닌 데이터로 채웁니다. 빈 블록에서의 영구 디스크 읽기는 데이터를 포함하는 블록에서의 읽기와 지연 시간 프로필이 다릅니다. 모든 읽기 지연 시간 벤치마크를 실행하기 전에 디스크를 채우는 것이 좋습니다.

    # 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=/dev/sdb --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
    
  4. I/O 크기를 1MB로 설정하고 I/O 깊이를 64 이상으로 설정하여 여러 동시 스트림(16개 이상)에 순차적 쓰기를 수행하여 쓰기 대역폭을 테스트합니다.

    # Running this command causes data loss on the second device.
    # We strongly recommend using a throwaway VM and disk.
    sudo fio --name=write_bandwidth_test \
      --filename=/dev/sdb --filesize=2500G \
      --time_based --ramp_time=2s --runtime=1m \
      --ioengine=libaio --direct=1 --verify=0 --randrepeat=0 \
      --bs=1M --iodepth=64  --iodepth_batch_submit=64  --iodepth_batch_complete_max=64 \
      --rw=write --numjobs=16 --offset_increment=100G
    
  5. 쓰기 IOPS를 테스트합니다. 최대 PD IOPS를 달성하기 위해서는 깊은 I/O 큐를 유지해야 합니다. 예를 들어 쓰기 지연 시간이 1밀리초인 경우 VM이 처리 중인 각 I/O에 대해 최대 1,000의 IOPS를 달성할 수 있습니다. 15,000 쓰기 IOPS를 달성하기 위해서는 VM이 처리 중인 I/O를 최소한 15 이상으로 유지해야 합니다. 디스크 및 VM이 30,000 쓰기 IOPS를 달성할 수 있는 경우 처리되는 I/O 수는 최소 30 이상이어야 합니다. I/O 크기가 4KB보다 큰 경우에는 IOPS 한도에 도달하기 전에 VM이 대역폭 제한에 걸릴 수 있습니다.

    # Running this command causes data loss on the second device.
    # We strongly recommend using a throwaway VM and disk.
    sudo fio --name=write_iops_test \
      --filename=/dev/sdb --filesize=2500G \
      --time_based --ramp_time=2s --runtime=1m \
      --ioengine=libaio --direct=1 --verify=0 --randrepeat=0 \
      --bs=4K --iodepth=256 --rw=randwrite \
      --iodepth_batch_submit=256  --iodepth_batch_complete_max=256
    
  6. 쓰기 지연 시간을 테스트합니다. I/O 지연 시간을 테스트할 때는 VM이 최대 대역폭 또는 IOPS에 도달하지 않아야 합니다. 그렇지 않으면 관찰된 지연 시간에 실제 영구 디스크 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 --name=write_latency_test \
      --filename=/dev/sdb --filesize=2500G \
      --time_based --ramp_time=2s --runtime=1m \
      --ioengine=libaio --direct=1 --verify=0 --randrepeat=0 \
      --bs=4K --iodepth=4 --rw=randwrite --iodepth_batch_submit=4  \
      --iodepth_batch_complete_max=4
    
  7. I/O 크기를 1MB로 설정하고 I/O 깊이를 64 이상으로 설정하여 여러 동시 스트림(16개 이상)에 순차적 읽기를 수행하여 읽기 대역폭을 테스트합니다.

    sudo fio --name=read_bandwidth_test \
      --filename=/dev/sdb --filesize=2500G \
      --time_based --ramp_time=2s --runtime=1m \
      --ioengine=libaio --direct=1 --verify=0 --randrepeat=0 \
      --bs=1M --iodepth=64 --rw=read --numjobs=16 --offset_increment=100G \
      --iodepth_batch_submit=64  --iodepth_batch_complete_max=64
    
  8. 읽기 IOPS를 테스트합니다. 최대 PD IOPS를 달성하기 위해서는 깊은 I/O 큐를 유지해야 합니다. 예를 들어 I/O 크기가 4KB보다 큰 경우에는 IOPS 한도에 도달하기 전에 VM이 대역폭 제한에 걸릴 수 있습니다. 최대 100,000의 읽기 IOPS를 달성하려면 테스트에 --iodepth=256을 지정합니다.

    sudo fio --name=read_iops_test \
      --filename=/dev/sdb --filesize=2500G \
      --time_based --ramp_time=2s --runtime=1m \
      --ioengine=libaio --direct=1 --verify=0 --randrepeat=0 \
      --bs=4K --iodepth=256 --rw=randread \
      --iodepth_batch_submit=256  --iodepth_batch_complete_max=256
    
  9. 읽기 지연 시간을 테스트합니다. 실질적으로 지연 시간을 측정하기 위해서는 디스크에 데이터를 채우는 것이 중요합니다. 영구 디스크가 포화 한도에 도달하면 수신 I/O가 푸시백되고 이로 인해 I/O 지연 시간이 인위적으로 증가하므로 이 테스트 중에는 VM이 IOPS 또는 처리량 한도에 도달하지 않도록 하는 것이 중요합니다.

    sudo fio --name=read_latency_test \
      --filename=/dev/sdb --filesize=2500G \
      --time_based --ramp_time=2s --runtime=1m \
      --ioengine=libaio --direct=1 --verify=0 --randrepeat=0 \
      --bs=4K --iodepth=4 --rw=randread \
      --iodepth_batch_submit=4  --iodepth_batch_complete_max=4
    
  10. 순차적 읽기 대역폭을 테스트합니다.

    sudo fio --name=read_bandwidth_test \
      --filename=/dev/sdb --filesize=2500G \
      --time_based --ramp_time=2s --runtime=1m \
      --ioengine=libaio --direct=1 --verify=0 --randrepeat=0 \
      --numjobs=4 --thread --offset_increment=500G \
      --bs=1M --iodepth=64 --rw=read \
      --iodepth_batch_submit=64  --iodepth_batch_complete_max=64
    
  11. 순차적 쓰기 대역폭을 테스트합니다.

    sudo fio --name=write_bandwidth_test \
      --filename=/dev/sdb --filesize=2500G \
      --time_based --ramp_time=2s --runtime=1m \
      --ioengine=libaio --direct=1 --verify=0 --randrepeat=0 \
      --numjobs=4 --thread --offset_increment=500G \
      --bs=1M --iodepth=64 --rw=write \
      --iodepth_batch_submit=64  --iodepth_batch_complete_max=64
    

다음 단계