Sub topic 2
Measuring real utilization with CloudWatch
This chapter assumes you know what EC2 instances, instance types and AMIs are, and that you can run AWS CLI commands and read a CloudWatch metric graph. The goal is to collect the utilization data that the later right-sizing chapters depend on.
What to measure
Right-sizing compares what an instance uses with what it offers. Four resources matter: CPU, memory, network and disk. A change that fixes one can break another, so look at all four.
| Resource | Metric | Namespace | Available by default? |
|---|---|---|---|
| CPU | `CPUUtilization` | `AWS/EC2` | Yes |
| Network | `NetworkIn`, `NetworkOut` | `AWS/EC2` | Yes |
| Disk (instance store) | `DiskReadOps`, `DiskWriteOps` | `AWS/EC2` | Yes |
| Disk (EBS) | `VolumeReadOps`, `VolumeWriteOps` | `AWS/EBS` | Yes |
| Memory | `mem_used_percent` | `CWAgent` | No, needs the CloudWatch agent |
EC2 runs on a hypervisor, and the hypervisor cannot see inside the guest operating system. This is why memory is missing from the default metrics. To see it, install the CloudWatch agent on the instance and configure it to publish memory data. Without it, a CPU-only review can recommend a smaller instance that then runs out of memory.
Retrieving CPU data
The get-metric-statistics command returns datapoints for one metric over a time range. This example asks for hourly average and maximum CPU for two weeks.
aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name CPUUtilization \
--dimensions Name=InstanceId,Value=i-0123456789abcdef0 \
--start-time 2026-11-01T00:00:00Z \
--end-time 2026-11-15T00:00:00Z \
--period 3600 \
--statistics Average MaximumEach datapoint covers one --period of 3600 seconds. The response is not sorted, and a single call returns at most 1,440 datapoints. Two weeks at one-hour resolution is 336 points, so this request fits. A request for one-minute data over the same range would not.
Reading the numbers
Average and maximum answer different questions.
- The average shows typical load. A low average over two weeks suggests the instance is larger than it needs to be.
- The maximum shows peaks. A low average with a maximum that regularly reaches 90% or more means the instance handles bursts and may not be a good candidate for shrinking.
A third value is often more useful than either: a high percentile such as p95 or p99. Use the --extended-statistics p95 option in place of --statistics. The two options cannot be combined in one call.
The period you choose changes what you see. An hourly average can hide a five-minute spike that saturates the CPU. Pick a period shorter than the shortest burst you care about, and keep in mind the retention limits: CloudWatch keeps one-minute data for 15 days and five-minute data for 63 days. Data older than that is only available at coarser resolution.
Choosing the time window
Collect data that covers a full business cycle. If load rises at month end or on weekdays, a window that misses those events makes the instance look idle. Two weeks is a common minimum. For workloads with monthly or seasonal patterns, use four weeks or more, and note any known events such as a sale or a batch run.
Also check that the instance was running for the whole window. An instance that was stopped for half the period produces fewer datapoints and can distort your reading.
A quick check of the data
The flow below shows how the pieces fit together.
Common errors
- Reading only CPU. A memory-bound database can show 10% CPU and still need all its RAM.
- Using too short a window. Three quiet days do not represent a month.
- Trusting averages alone. Check the maximum or p95.
- Forgetting burstable instances. On T-family instances, low CPU may reflect exhausted credits that throttle the instance, not low demand. Check
CPUCreditBalanceas well. - Mixing up units.
NetworkInis bytes per period, not bytes per second. Divide by the period length before you compare it with an instance's bandwidth.
Exercise
An instance shows 8% average CPU over 14 days, but the maximum reaches 95% several times a day. You have not installed the CloudWatch agent. Name two reasons you should not shrink it yet, and one extra step you should take.
Show answer
First, the frequent 95% peaks show the instance uses its CPU during bursts, so a smaller size may throttle those bursts. Second, you have no memory data, so a smaller instance could run out of RAM. Install the CloudWatch agent to collect memory metrics, and also check a high percentile such as p95 to see how often the peaks occur.