Sub topic 4
Understanding IOPS, throughput and latency
This chapter assumes you can create and mount an EBS volume (earlier chapters) and run commands in a Linux shell. It explains the three numbers that describe volume performance. It also shows how they relate, which one limits a given workload, and how to measure them.
The three measures
- IOPS (I/O operations per second) counts how many read or write requests the volume completes each second. It matters for small, random access, such as databases and metadata-heavy workloads.
- Throughput is the data moved per second, measured in MiB/s. It matters for large, sequential access, such as log processing, backups and analytics scans.
- Latency is the time one request takes from submission to completion, measured in milliseconds. It matters when each operation waits on the previous one.
A volume can be limited by IOPS, by throughput, or by latency combined with how much work your application keeps in flight. Fixing the wrong one wastes money.
How IOPS and throughput are linked
For a steady workload:
throughput = IOPS x I/O sizeFor SSD-backed volumes (gp3, gp2, io1, io2), EBS counts one operation for each I/O up to 256 KiB. It merges contiguous small I/Os into a single operation when it can. HDD-backed volumes (st1, sc1) count in 1 MiB units, which is why they suit large sequential reads and perform poorly on small random ones.
Every volume has both an IOPS limit and a throughput limit, and you hit whichever comes first. A gp3 volume includes 3,000 IOPS and 125 MiB/s at any size. The table shows what that volume can deliver at different I/O sizes:
| I/O size | IOPS x size at 3,000 IOPS | Limit reached first | Achievable result |
|---|---|---|---|
| 4 KiB | 11.7 MiB/s | IOPS | 3,000 IOPS, 11.7 MiB/s |
| 16 KiB | 46.9 MiB/s | IOPS | 3,000 IOPS, 46.9 MiB/s |
| 64 KiB | 187.5 MiB/s | Throughput | 2,000 IOPS, 125 MiB/s |
| 256 KiB | 750 MiB/s | Throughput | 500 IOPS, 125 MiB/s |
At 256 KiB, buying more IOPS does nothing, because throughput is the bottleneck. At 4 KiB, buying more throughput does nothing. gp3 lets you provision the two independently, so you can raise only the one you need.
Latency and queue depth
Latency and IOPS are connected through the number of requests in flight, called the queue depth. Little's law gives the relationship:
IOPS = queue depth / latencySuppose a volume answers each request in 1 ms. An application that issues one request at a time and waits for it (queue depth 1) reaches only about 1,000 IOPS. That is true even if the volume is provisioned for 16,000. To reach 3,000 IOPS you need about three requests in flight.
This has two practical consequences:
- A single-threaded program that does synchronous I/O cannot use a fast volume. The limit is in the application, not in EBS.
- Once you hit the volume's limits, extra requests wait in a queue. Latency rises while IOPS and throughput stay flat. A growing queue with flat IOPS is the signature of a saturated volume.
Typical latencies differ by type. gp3 and gp2 are in the single-digit millisecond range. io2 targets lower and more consistent latency, with sub-millisecond latency on Block Express-capable instances. HDD volumes have the highest. Treat these as guidance and measure your own workload.
Where the limits sit
A request passes through several layers, and any of them can be the cap.
- Application and OS. Queue depth and I/O size are decided here.
- Instance. Each instance type has a maximum EBS bandwidth and IOPS, shared by all attached volumes. The next chapter covers this. If you attach several fast volumes to a small instance, the instance limit can be lower than the sum of the volumes.
- Volume. Provisioned or baseline IOPS and throughput apply per volume.
Effective performance is the minimum across these layers.
Burst behavior
Not every limit is constant:
- gp2 earns IOPS in proportion to size, at 3 IOPS per GiB with a floor of 100. Volumes below 1 TiB can burst to 3,000 IOPS using credits from a bucket. When the bucket empties, performance drops to the baseline. A small gp2 volume that looks fast in a short test can slow down under sustained load.
- st1 and sc1 scale throughput with volume size and burst using a credit bucket in a similar way.
- Some smaller instance types reach their maximum EBS performance only for short bursts, then fall back to a baseline.
- gp3 has no credit bucket. Its baseline and provisioned values are sustained.
Measuring with fio
fio is the standard tool for generating controlled I/O. The commands below assume a volume mounted at /data. Use direct=1 to bypass the page cache. Without it you measure memory, not EBS.
sudo dnf install -y fio
# Random 16 KiB reads: stresses IOPS and latency
sudo fio --name=randread --directory=/data --size=4G \
--rw=randread --bs=16k --iodepth=32 --ioengine=libaio \
--direct=1 --runtime=300 --time_based --group_reporting
# Sequential 1 MiB reads: stresses throughput
sudo fio --name=seqread --directory=/data --size=4G \
--rw=read --bs=1m --iodepth=16 --ioengine=libaio \
--direct=1 --runtime=300 --time_based --group_reportingOn Ubuntu, use sudo apt install -y fio instead of dnf. In the output, read three lines: IOPS= and BW= show whether you reached the limit you expected, and the clat percentiles (such as 99th) show latency. Use percentiles, not the average, because occasional slow requests hurt applications more than the mean suggests.
Run the random test with --iodepth=1 as well. Comparing that result with the --iodepth=32 run separates the volume's latency from its capacity to handle parallel work.
Reading CloudWatch to find the bottleneck
CloudWatch records per-volume metrics. Four are most useful here:
| Metric | What it tells you |
|---|---|
| `VolumeReadOps`, `VolumeWriteOps` | Operation counts. Divide the sum by the period in seconds to get IOPS. |
| `VolumeReadBytes`, `VolumeWriteBytes` | Bytes moved. Divide by the period and by 1,048,576 to get MiB/s. |
| `VolumeQueueLength` | Requests waiting or in progress. A sustained high value means saturation or a slow volume. |
| `VolumeTotalReadTime`, `VolumeTotalWriteTime` | Total time spent on completed operations. Divide by the operation count to get average latency. |
The diagnosis follows from comparing these to the limits you provisioned:
- IOPS near the limit, throughput well below its limit: you are IOPS-bound. Raise IOPS or issue larger I/Os.
- Throughput near the limit, IOPS below its limit: you are throughput-bound. Raise throughput.
- Both below their limits, queue length near 0 or 1, latency high: the application is not issuing enough parallel requests, or the volume is slow for another reason.
- Queue length high, IOPS or throughput flat at a limit: the volume or instance is saturated.
Also compare against the instance's EBS limit. If the volume's metrics look fine but the application is slow, the instance may be the cap.
Common errors
- Sizing by IOPS alone. A 3,000 IOPS volume cannot sustain 3,000 IOPS of 256 KiB requests, because 125 MiB/s caps it near 500.
- Ignoring the file system. A database page size of 8 KiB or 16 KiB, the file system block size and read-ahead settings all change the effective I/O size.
- Testing a freshly restored volume. Volumes created from snapshots load blocks lazily from S3, so first reads have much higher latency than steady state. See the chapter on restoring and initializing volumes.
- Trusting a cached test. Without
direct=1, repeated reads hit the page cache and show impossible numbers.
Exercise
A gp3 volume has the baseline 3,000 IOPS and 125 MiB/s. Your application reads in 128 KiB operations and CloudWatch shows about 1,000 IOPS with VolumeQueueLength near 20. Is the volume saturated, and which setting would you raise first?
Show answer
Yes. At 128 KiB, 1,000 IOPS is 125 MiB/s (1,000 x 128 KiB = 125,000 KiB, about 122 MiB/s), which is the volume's throughput limit. IOPS is well below 3,000, so the volume is throughput-bound, and the high queue length confirms requests are waiting. Raise the provisioned throughput, for example with modify-volume --throughput. Raising IOPS would not help.
Exercise
A volume responds to each request in 2 ms. A single-threaded program issues one synchronous read at a time. About how many IOPS can it reach, and how many requests must be in flight to reach 3,000 IOPS?
Show answer
With queue depth 1, IOPS = 1 / 0.002 s = 500. To reach 3,000 IOPS you need a queue depth of 3,000 x 0.002 = 6 requests in flight.