How does Amazon EBS calculate the optimal I/O size I should use for my gp2 or io1 volume to increase throughput?

Last updated: 2020-02-03

I want to maximize the throughput performance of my gp2 or io1 Amazon Elastic Block Store (Amazon EBS) volume. How does Amazon EBS calculate the optimal I/O size for my volume to increase throughput?

Short Description

Amazon EBS throughput workload can be increased with an increase in the I/O size. To understand the effect of I/O size on the volume's throughput, it's important to understand how I/O size is calculated. For gp2 and io1 EBS volumes, the performance is calculated in terms of input/output per second (IOPS). The maximum I/O size that gp2 and io1 volumes can process is 256 KiB.

Resolution

When calculating IOPS, Amazon EBS considers whether I/O operations are sequential or random. Amazon EBS attempts to merge I/O operations to maximize the I/O size before processing. 32 KiB is the minimum I/O size after which Amazon EBS will merge I/O requests. Smaller sequential I/O operations are coalesced to form a single I/O of 256 KiB by Amazon EBS.

For example, if the application is performing small I/O operations of 32 KiB:

  • For sequential (physically contiguous) operations, Amazon EBS tries to merge them to maximum size up to 256 KiB. In this scenario, only 1 IOP is counted by Amazon EBS to perform 8 I/O operations submitted by the operating system.
  • For random operations, a single I/O operation of 32 KiB is counted as 1 IOP. Therefore to perform 8 random operations, Amazon EBS counts that 8 IOPS are submitted by the OS.

If the I/O size is 500 KiB, Amazon EBS splits the operation into 2 IOPS. The first one is 256 KiB and the second one is 244 KiB. Amazon EBS always tries to optimize the I/O size to help the application use the provisioned IOPS efficiently. The size of an I/O operation determines the throughput the EBS volume can provide.

Throughput calculation

Throughput is calculated using the equation: Throughput = Number of IOPS * size per I/O operation.

The size per I/O operation varies by volume type.

  • gp2 volumes
    Max IOPS = 16,000
    Max Throughput = 250 MiB
  • io1 volumes
    Max IOPS = 64,000
    Max Throughput = 1,000 MiB

Maximum throughput is achieved at maximum IOPS.

Note: Maximum throughput of 1,000 MiB/s is guaranteed only on Nitro-based instances. Other instance families guarantee up to 500 MiB/s. An older io1 volume might not see full performance unless a ModifyVolume action is performed.

Optimal I/O size calculation

The optimal I/O size is calculated using the equation: Optimal I/O size = Throughput/Number of IOPS.

  • gp2 volume optimal I/O size: 250 MiB * 1024/16000 = 16 KiB
  • io1 volume optimal I/O size: 1000 MiB * 1024/64000 = 16 KiB

As Amazon EBS tries to merge smaller I/O operations into a larger one that uses more I/O bandwidth, the throughput limit might be reached before the maximum IOPS is achieved. To avoid this, your application's I/O operations should be random enough that Amazon EBS counts them as a single IOP of 16 KiB.

Note: Instances or kernels that don't support indirect descriptors have an average I/O size at or near 44KiB. Linux kernel 3.8 and below doesn't support indirect descriptors, therefore, you might find your I/O size capped at 44 KiB