Benchmarking Local SSD performance


Local SSD performance limits provided in the Choose a storage option section were achieved by using specific settings on the Local SSD instance. If your virtual machine (VM) instance is having trouble reaching these performance limits and you have already configured the instance using the recommended local SSD settings, you can compare your performance limits against the published limits by replicating the settings used by the Compute Engine team.

These instructions assume that you are using a Linux operating system with the apt package manager installed.

Create a VM with one Local SSD device

The number of Local SSD that a VM can have is based on the machine type you use to create the VM. For more information, see Choosing a valid number of Local SSDs.

  1. Create a Local SSD instance that has four or eight vCPUs for each device, depending on your workload.

    For third generation VMs (except M3), choose the -lssd machine type to create your VM. This machine type configures a predetermined number of Local SSD automatically when the VM is created.

    The following command creates a C3 VM with 4 vCPUs and 1 Local SSD.

    gcloud compute instances create c3-ssd-test-instance \
        --machine-type "c3-standard-4-lssd" \
    

    For second generation and earlier machine types, you specify the number of Local SSD to attach to the VM using the --local-ssd flag. The following command creates an N2 VM with 8 vCPUs and 1 Local SSD:

    gcloud compute instances create ssd-test-instance \
        --machine-type "n2-standard-8" \
        --local-ssd interface=nvme
    
  2. Run the following script on your VM. The script replicates the settings used to achieve the SSD performance figures provided in the performance section. Note that the --bs parameter defines the block size, which affects the results for different types of read and write operations.

    # install tools
    sudo apt-get -y update
    sudo apt-get install -y fio util-linux
    
    # discard Local SSD sectors
    sudo blkdiscard /dev/disk/by-id/google-local-nvme-ssd-0
    
    # full write pass - measures write bandwidth with 1M blocksize
    sudo fio --name=writefile --size=100G --filesize=100G \
    --filename=/dev/disk/by-id/google-local-nvme-ssd-0 --bs=1M --nrfiles=1 \
    --direct=1 --sync=0 --randrepeat=0 --rw=write --refill_buffers --end_fsync=1 \
    --iodepth=200 --ioengine=libaio
    
    # rand read - measures max read IOPS with 4k blocks
    sudo fio --time_based --name=benchmark --size=100G --runtime=30 \
    --filename=/dev/disk/by-id/google-local-nvme-ssd-0 --ioengine=libaio --randrepeat=0 \
    --iodepth=128 --direct=1 --invalidate=1 --verify=0 --verify_fatal=0 \
    --numjobs=4 --rw=randread --blocksize=4k --group_reporting
    
    # rand write - measures max write IOPS with 4k blocks
    sudo fio --time_based --name=benchmark --size=100G --runtime=30 \
    --filename=/dev/disk/by-id/google-local-nvme-ssd-0 --ioengine=libaio --randrepeat=0 \
    --iodepth=128 --direct=1 --invalidate=1 --verify=0 --verify_fatal=0 \
    --numjobs=4 --rw=randwrite --blocksize=4k --group_reporting
    

Create a VM with the maximum number of Local SSD

  1. If you want to attach 24 or more Local SSD devices to an instance, use a machine type with 32 or more vCPUs.

    The following commands create a VM with the maximum allowed number of Local SSD disks using the NVMe interface:

    Attach Local SSD to VM

    gcloud compute instances create ssd-test-instance \
        --machine-type "n1-standard-32" \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme \
        --local-ssd interface=nvme
    

    Use -lssd machine types

    Newer machine series offer -lssd machine types that come with a predetermined number of Local SSD disks. For example, to benchmark a VM with 32 Local SSD (12 TiB capacity), use the following command:

    gcloud compute instances create ssd-test-instance \
        --machine-type "c3-standard-176-lssd"
    
  2. Install the mdadm tool. The install process for mdadm includes a user prompt that halts scripts, so run the process manually:

    Debian and Ubuntu

    sudo apt update && sudo apt install mdadm --no-install-recommends
    

    CentOS and RHEL

    sudo yum install mdadm -y
    

    SLES and openSUSE

    sudo zypper install -y mdadm
    
  3. Use the find command to identify all of the Local SSDs that you want to mount together:

    find /dev/ | grep google-local-nvme-ssd
    

    The output looks similar to the following:

    /dev/disk/by-id/google-local-nvme-ssd-23
    /dev/disk/by-id/google-local-nvme-ssd-22
    /dev/disk/by-id/google-local-nvme-ssd-21
    /dev/disk/by-id/google-local-nvme-ssd-20
    /dev/disk/by-id/google-local-nvme-ssd-19
    /dev/disk/by-id/google-local-nvme-ssd-18
    /dev/disk/by-id/google-local-nvme-ssd-17
    /dev/disk/by-id/google-local-nvme-ssd-16
    /dev/disk/by-id/google-local-nvme-ssd-15
    /dev/disk/by-id/google-local-nvme-ssd-14
    /dev/disk/by-id/google-local-nvme-ssd-13
    /dev/disk/by-id/google-local-nvme-ssd-12
    /dev/disk/by-id/google-local-nvme-ssd-11
    /dev/disk/by-id/google-local-nvme-ssd-10
    /dev/disk/by-id/google-local-nvme-ssd-9
    /dev/disk/by-id/google-local-nvme-ssd-8
    /dev/disk/by-id/google-local-nvme-ssd-7
    /dev/disk/by-id/google-local-nvme-ssd-6
    /dev/disk/by-id/google-local-nvme-ssd-5
    /dev/disk/by-id/google-local-nvme-ssd-4
    /dev/disk/by-id/google-local-nvme-ssd-3
    /dev/disk/by-id/google-local-nvme-ssd-2
    /dev/disk/by-id/google-local-nvme-ssd-1
    /dev/disk/by-id/google-local-nvme-ssd-0
    

    find does not guarantee an ordering. It's alright if the devices are listed in a different order as long as number of output lines match the expected number of SSD partitions.

    If using SCSI devices, use the following find command:

    find /dev/ | grep google-local-ssd
    

    NVMe devices should all be of form google-local-nvme-ssd-# and SCSI devices should all be of form google-local-ssd-#.

  4. Use the mdadm tool to combine multiple Local SSD devices into a single array named /dev/md0. The following example merges twenty four Local SSD devices that use the NVMe interface. For Local SSD devices that use SCSI, use the device names returned from the find command in step 3.

    sudo mdadm --create /dev/md0 --level=0 --raid-devices=24 \
    /dev/disk/by-id/google-local-nvme-ssd-0 \
    /dev/disk/by-id/google-local-nvme-ssd-1 \
    /dev/disk/by-id/google-local-nvme-ssd-2 \
    /dev/disk/by-id/google-local-nvme-ssd-3 \
    /dev/disk/by-id/google-local-nvme-ssd-4 \
    /dev/disk/by-id/google-local-nvme-ssd-5 \
    /dev/disk/by-id/google-local-nvme-ssd-6 \
    /dev/disk/by-id/google-local-nvme-ssd-7 \
    /dev/disk/by-id/google-local-nvme-ssd-8 \
    /dev/disk/by-id/google-local-nvme-ssd-9 \
    /dev/disk/by-id/google-local-nvme-ssd-10 \
    /dev/disk/by-id/google-local-nvme-ssd-11 \
    /dev/disk/by-id/google-local-nvme-ssd-12 \
    /dev/disk/by-id/google-local-nvme-ssd-13 \
    /dev/disk/by-id/google-local-nvme-ssd-14 \
    /dev/disk/by-id/google-local-nvme-ssd-15 \
    /dev/disk/by-id/google-local-nvme-ssd-16 \
    /dev/disk/by-id/google-local-nvme-ssd-17 \
    /dev/disk/by-id/google-local-nvme-ssd-18 \
    /dev/disk/by-id/google-local-nvme-ssd-19 \
    /dev/disk/by-id/google-local-nvme-ssd-20 \
    /dev/disk/by-id/google-local-nvme-ssd-21 \
    /dev/disk/by-id/google-local-nvme-ssd-22 \
    /dev/disk/by-id/google-local-nvme-ssd-23
    

    The response is similar to the following:

    mdadm: Defaulting to version 1.2 metadata
    mdadm: array /dev/md0 started.
    

    You can confirm the details of the array with mdadm --detail. Adding the --prefer=by-id flag will list the devices using the /dev/disk/by-id paths.

     sudo mdadm --detail --prefer=by-id /dev/md0
    

    The output should look similar to the following for each device in the array.

     ...
     Number   Major   Minor   RaidDevice State
     0     259        0        0      active sync   /dev/disk/by-id/google-local-nvme-ssd-0
     ...
    
  5. Run the following script on your VM. The script replicates the settings used to achieve the SSD performance figures provided in the performance section. that the --bs parameter defines the block size, which affects the results for different types of read and write operations.

    # install tools
    sudo apt-get -y update
    sudo apt-get install -y fio util-linux
    
    # full write pass - measures write bandwidth with 1M blocksize
    sudo fio --name=writefile --size=100G --filesize=100G \
    --filename=/dev/md0 --bs=1M --nrfiles=1 \
    --direct=1 --sync=0 --randrepeat=0 --rw=write --refill_buffers --end_fsync=1 \
    --iodepth=200 --numjobs=32 --ioengine=libaio
    
    # rand read - measures max read IOPS with 4k blocks
    sudo fio --time_based --name=benchmark --size=100G --runtime=30 \
    --filename=/dev/md0 --ioengine=libaio --randrepeat=0 \
    --iodepth=128 --direct=1 --invalidate=1 --verify=0 --verify_fatal=0 \
    --numjobs=32 --rw=randread --blocksize=4k --group_reporting --norandommap
    
    # rand write - measures max write IOPS with 4k blocks
    sudo fio --time_based --name=benchmark --size=100G --runtime=30 \
    --filename=/dev/md0 --ioengine=libaio --randrepeat=0 \
    --iodepth=128 --direct=1 --invalidate=1 --verify=0 --verify_fatal=0 \
    --numjobs=32 --rw=randwrite --blocksize=4k --group_reporting --norandommap
    

What's next