Sub topic 4
Using AWS Compute Optimizer recommendations
This chapter assumes you can run AWS CLI commands, read CloudWatch metrics, and know what an EC2 instance type is. Earlier chapters showed how to measure utilization by hand. Compute Optimizer automates that analysis and returns a ranked list of alternative instance types.
What Compute Optimizer does
AWS Compute Optimizer is a service that analyzes the configuration and utilization history of your resources and recommends changes. For EC2 it looks at CPU, memory (if available), network, and disk metrics, then compares your instance against other instance types.
It must be enabled before it returns anything. You opt in per account, or for a whole AWS Organization from the management account. After you opt in, it needs some time to collect data. By default it uses 14 days of metrics.
Each recommendation includes a finding, a set of up to three options, and a performance risk score for each option.
Memory needs the CloudWatch agent
By default EC2 does not publish memory utilization to CloudWatch. Without it, Compute Optimizer judges the instance on CPU, network, and disk only. It can then suggest a smaller instance that does not have enough RAM.
Install the CloudWatch agent so memory metrics are published. Compute Optimizer can then include them. You can also turn on enhanced infrastructure metrics, a paid option that extends the lookback period from 14 days to up to 93 days. This helps with workloads that have monthly peaks.
Requesting recommendations
Use the instance ARN to fetch a recommendation.
aws compute-optimizer get-ec2-instance-recommendations \
--instance-arns arn:aws:ec2:us-east-1:111122223333:instance/i-0123456789abcdef0If the account has not opted in, the call fails with an error saying the account is not registered. Opt in first, in the console or with aws compute-optimizer update-enrollment-status --status Active.
Reading the findings
The finding field tells you how the current instance fits its workload.
| Finding | Meaning | Typical action |
|---|---|---|
| Optimized | The instance meets the workload's needs | Leave it alone |
| Overprovisioned | At least one resource (CPU, memory, network) is larger than needed | Move to a smaller or cheaper type |
| Underprovisioned | At least one resource is too small | Move to a larger type or a different family |
| None | No recommendation available, for example the instance is too new | Wait for more data |
An instance can be marked overprovisioned and still have a limiting resource. The findingReasonCodes field names which resources are over or under. For example, CPUOverprovisioned combined with MemoryUnderprovisioned points to a move to a memory-optimized family, not just a smaller size.
Performance risk and savings
Each option has a performanceRisk value from 0 to 5. It estimates the chance that the option will not meet the workload's needs. A score of 0 means very low risk. A score of 4 or 5 means you should test carefully. Each option also reports estimated monthly savings, which is calculated from on-demand prices unless you specify other pricing preferences.
Options can include Graviton instance types. Compute Optimizer can also report the expected effect of a migration from x86 to Arm64, and it flags when the software on the instance may not run on Arm64. Treat that flag as a prompt to run the compatibility check from a later chapter. The service does not inspect your code.
Common errors
- Trusting the result without memory data. Check that the CloudWatch agent is reporting memory before acting on a downsizing suggestion.
- Short observation windows. Fourteen days can miss month-end jobs. Extend the lookback or compare against your own CloudWatch data.
- Ignoring the risk score. A cheap option with a risk of 4 is not a free saving.
- Applying changes directly in production. Recommendations are inputs to your right-sizing method, not instructions.
Cross-checking with CloudWatch
Verify a surprising recommendation against raw data.
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 MaximumIf the maximum CPU regularly reaches the high 90s, a recommendation to halve the vCPU count deserves scrutiny, even when the average is low.
Exercise
Compute Optimizer marks an instance as Overprovisioned with the reason codes CPUOverprovisioned and MemoryUnderprovisioned, and the CloudWatch agent is not installed. What should you do before acting, and why?
Show answer
Install the CloudWatch agent first so memory is measured, then wait for new data. Without agent data the memory finding may be incomplete, and a smaller instance could run out of RAM. With the reason codes pointing to low memory, consider a memory-optimized family instead of simply downsizing, and test the candidate before rollout.