Sub topic 4
Understanding IOPS, throughput and latency
This chapter assumes you can create an EBS volume and know the volume types from the previous chapter. It explains the three numbers that describe volume performance and how they limit each other.
The three measures
- IOPS is the number of read and write operations per second.
- Throughput is the amount of data moved per second, in MiB/s.
- Latency is the time one operation takes from request to completion, in milliseconds.
IOPS suits small random access, such as databases. Throughput suits large sequential access, such as log processing or backups. Latency matters when each request waits on the previous one.
How IOPS and throughput relate
Throughput equals IOPS multiplied by I/O size. A volume has a limit on each, and the lower limit wins.
A gp3 volume has a baseline of 3,000 IOPS and 125 MiB/s. Consider two workloads on that volume:
| I/O size | Throughput at 3,000 IOPS | Result |
|---|---|---|
| 16 KiB | about 47 MiB/s | IOPS is the limit |
| 256 KiB | 750 MiB/s | Capped at 125 MiB/s, so about 500 IOPS |
Large I/O therefore exhausts the throughput limit long before the IOPS limit. EBS merges adjacent sequential requests, and SSD volumes count one operation per 256 KiB or less. HDD volumes (st1, sc1) use 1 MiB units and are rated by throughput, not IOPS.
Latency and queue depth
Queue depth is the number of requests in flight at once. Little's law links it to the other two measures: IOPS = queue depth ÷ latency. If latency is 1 ms, a queue depth of 1 gives at most 1,000 IOPS. A single-threaded application cannot reach 3,000 IOPS on that volume, however much you provision. You need more parallel requests.
SSD volumes typically give single-digit millisecond latency. io2 targets sub-millisecond latency. EBS is network-attached, so even the best case is slower than local instance store.
Provisioning by volume type
- gp3 lets you set IOPS (3,000 to 16,000) and throughput (125 to 1,000 MiB/s) independently of size.
- gp2 ties IOPS to size at 3 IOPS per GiB and can burst, using credits, for small volumes.
- io2 and io1 provision IOPS for sustained, latency-sensitive workloads.
Measuring a volume
Test with fio and compare the result to the limits. This run does random 16 KiB reads at queue depth 32 against the volume mounted at /data:
sudo fio --name=randread --directory=/data --size=2G \
--rw=randread --bs=16k --iodepth=32 --ioengine=libaio \
--direct=1 --runtime=60 --time_basedWatch iostat -x 5 in a second terminal. The r/s column shows IOPS and await shows latency in milliseconds.
Common errors
- Provisioning more IOPS when the real limit is throughput, or the reverse.
- Testing with queue depth 1 and concluding the volume is slow.
- Forgetting the instance. An instance type has its own EBS IOPS and throughput caps, covered in the next chapter.
Exercise
A gp3 volume has 6,000 provisioned IOPS and 250 MiB/s throughput. An application issues 128 KiB reads. What is the highest IOPS it can reach, and which limit applies?
Show answer
At 128 KiB per I/O, 6,000 IOPS would need 750 MiB/s, so the throughput limit applies. 250 MiB/s ÷ 128 KiB is 2,000 IOPS.