Sub topic 14
Monitoring volume performance
This chapter assumes you know how to create and attach volumes, and you understand IOPS, throughput and latency from the earlier chapters. You also need the AWS CLI configured with CloudWatch read access.
Where the metrics come from
Every EBS volume publishes metrics to Amazon CloudWatch in the AWS/EBS namespace. The dimension is VolumeId. There is no extra charge for these metrics. SSD volumes attached to Nitro instances report at one-minute granularity. HDD volumes (st1, sc1) report every five minutes.
| Metric | What it tells you |
|---|---|
| `VolumeReadOps`, `VolumeWriteOps` | Number of I/O operations in the period |
| `VolumeReadBytes`, `VolumeWriteBytes` | Bytes transferred in the period |
| `VolumeTotalReadTime`, `VolumeTotalWriteTime` | Total seconds spent on completed operations |
| `VolumeQueueLength` | Operations waiting to be completed |
| `VolumeIdleTime` | Seconds with no read or write requests |
| `BurstBalance` | Percent of burst credits left (gp2, st1, sc1) |
| `VolumeStalledIOCheck` | 1 if the volume failed its I/O status check |
The metrics are raw counts per period, so you derive the numbers you care about:
- IOPS = (
VolumeReadOps+VolumeWriteOps) / period in seconds - Throughput = (
VolumeReadBytes+VolumeWriteBytes) / period in seconds - Average read latency =
VolumeTotalReadTime/VolumeReadOps
Querying a metric
Use the Sum statistic with a period that matches the metric's granularity. This example gets write operations in 5-minute buckets for the last hour. It uses GNU date.
aws cloudwatch get-metric-statistics \
--namespace AWS/EBS \
--metric-name VolumeWriteOps \
--dimensions Name=VolumeId,Value=vol-0123456789abcdef0 \
--start-time "$(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ)" \
--end-time "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--period 300 \
--statistics SumDivide each Sum by 300 to get average write IOPS for that bucket. Averages hide short spikes, so use a shorter period when you suspect bursts.
Reading the signals
Compare your derived IOPS and throughput with what the volume is provisioned for. A gp3 volume at 3,000 IOPS whose graph is flat at 3,000 while VolumeQueueLength climbs is saturated. The workload wants more than the volume can deliver.
Alarms
Alarm on conditions that need action. A BurstBalance alarm warns you before a gp2 volume drops to its baseline.
aws cloudwatch put-metric-alarm \
--alarm-name data-vol-burst-low \
--namespace AWS/EBS \
--metric-name BurstBalance \
--dimensions Name=VolumeId,Value=vol-0123456789abcdef0 \
--statistic Minimum \
--period 300 \
--evaluation-periods 2 \
--threshold 20 \
--comparison-operator LessThanThresholdCommon errors
- Reading
VolumeReadOpsas a rate. It is a count per period, so divide by the period. - Using
Averageinstead ofSumfor count and byte metrics. - Expecting idle volumes to show data. Volumes with no I/O may publish no data points for a period.
- Ignoring
VolumeQueueLength. High latency with a growing queue usually means saturation, not a fault.
Exercise
Over a 300-second period, a volume reports VolumeReadOps = 120,000 and VolumeWriteOps = 60,000. What is the average IOPS, and is a gp3 volume provisioned at 3,000 IOPS saturated?
Show answer
Total operations are 180,000. Divided by 300 seconds, that is 600 IOPS on average. That is well below 3,000, so the volume is not saturated on average. Short bursts could still reach the limit, so check a shorter period and VolumeQueueLength.