Sub topic 7
Rightsizing over-provisioned resources
This chapter assumes you can read CloudWatch metrics, know the EC2 instance families, and have followed the earlier chapters on seeing spend and finding idle resources.
What rightsizing is
Rightsizing means matching a resource's size to the load it actually carries. An idle resource has no load, so you delete it. An over-provisioned resource does real work but is larger than it needs to be, so you resize it. Cutting one EC2 size step, for example from m5.2xlarge to m5.xlarge, usually halves the hourly price for that instance.
Rightsizing comes before commitment discounts. If you buy a Savings Plan for an oversized fleet, you lock in payment for capacity you don't need.
Measure before you change
Judge size by peak behavior over a representative window, not by the average. A server that averages 8 percent CPU but reaches 85 percent every night during a batch job is not oversized. Use at least two weeks of data, and include month-end if your workload has one.
Check more than CPU:
- Memory is not reported to CloudWatch by default. Install the CloudWatch agent to get it.
- Network throughput and EBS IOPS limits differ by instance size.
- Burstable instances (T family) depend on CPU credit balance, not only CPU percentage.
This command returns daily average and maximum CPU for one instance over 14 days:
aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name CPUUtilization \
--dimensions Name=InstanceId,Value=i-0123456789abcdef0 \
--start-time 2026-11-12T00:00:00Z \
--end-time 2026-11-26T00:00:00Z \
--period 86400 \
--statistics Average Maximum \
--output tableReplace the instance ID with your own. If every daily maximum stays below about 40 percent, the instance is a candidate for a smaller size.
Use recommendations as a starting point
AWS Compute Optimizer analyzes utilization and suggests sizes. It needs to be enabled for the account first.
aws compute-optimizer get-ec2-instance-recommendations \
--query 'instanceRecommendations[].{Id:instanceArn,Finding:finding,Current:currentInstanceType,Suggested:recommendationOptions[0].instanceType}' \
--output tableThe Finding column reports values such as OVER_PROVISIONED, OPTIMIZED or UNDER_PROVISIONED. Treat the suggestion as a hypothesis. Compute Optimizer can't know about a quarterly traffic spike outside its look-back window.
The rightsizing loop
Common errors
- Sizing on average CPU alone, which hides peaks.
- Ignoring memory, so a database becomes starved after a downsize.
- Resizing without a rollback plan. Changing an EC2 instance type requires a stop and start, so schedule a maintenance window.
- Resizing once and never again. Workloads drift, so repeat the review on a schedule.
- Forgetting other resource types. RDS instances, EBS volumes (for example, provisioned IOPS you don't use), and container CPU and memory reservations can all be oversized.
Choosing an action
| Observation | Action |
|---|---|
| No traffic or connections for weeks | Delete or snapshot, then delete |
| Peak CPU and memory well under 40 percent | Move down one size |
| Low average, high short peaks | Keep size, or consider a burstable or autoscaled design |
| Older instance generation | Move to a newer generation, often cheaper per unit of work |
Exercise
An instance averages 6 percent CPU over 14 days, but its daily maximum reaches 90 percent for ten minutes each night. Memory use is steady at 30 percent. Should you downsize it by two steps? Explain.
Show answer
No. The 90 percent nightly peak shows the CPU is needed during the batch window, so a two-step cut risks slow jobs. Investigate what runs at night. If it is short and not time-critical, one step down may be acceptable after testing. Otherwise keep the size, or move the batch work to a scheduled or autoscaled resource. Never decide from the 6 percent average alone.