AWS Compute Blog
Optimize EC2 costs with AWS Compute Optimizer right sizing
One of the most impactful ways to improve the ROI on your Amazon Elastic Compute Cloud (Amazon EC2) investment is rightsizing — when you match your instance types and sizes to the actual resource demands of your workloads. However, doing this manually across hundreds or thousands of instances is time-consuming and error-prone. AWS Compute Optimizer analyzes your AWS resources’ configuration and utilization metrics to provide rightsizing recommendations designed to help you identify opportunities to reduce cost while helping to maintain performance and capacity requirements.
In this post, we walk you through how to evaluate AWS Compute Optimizer’s EC2 rightsizing recommendations, configure recommendation preferences that align with your organization’s priorities, enrich recommendations with memory utilization data, and assess Graviton-based alternatives — all to help you make more informed, data-driven rightsizing decisions.
Prerequisites
To follow along with the best practices in this post, you need:
- An AWS account with access to AWS Compute Optimizer
- At least one running EC2 instance with 30+ hours of Amazon CloudWatch metric data in the past 14 days
Optional (for enhanced recommendations):
- AWS Cost Optimization Hub enabled for after-discount savings visibility (see best practice 1)
The challenge: balancing cost and performance at scale
Most organizations don’t have clear insights into the best performance-cost ratio for their EC2 instances — leading to overprovisioning and wasted spend on one side, or undersized instances and degraded user experience on the other. The key questions engineering and FinOps teams face are:
- Which instances are oversized? Where are we paying for capacity we don’t use?
- Which instances are undersized? Where are we risking performance degradation?
- What’s the right trade-off? How do we optimize cost without introducing performance risk?
AWS Compute Optimizer analyzes up to 93 days of utilization data from Amazon CloudWatch and delivers recommendations classified by savings opportunity and performance risk to help you address these questions.
How Compute Optimizer evaluates EC2 instances
Compute Optimizer analyzes the following CloudWatch metrics for your EC2 instances, with recommendations refreshed daily:
- CPU utilization — the percentage of allocated EC2 compute units in use on the instance. Metric:
CPUUtilization - Memory utilization — the percentage of memory in use during the sample period (when enabled — see below). Metric:
MemoryUtilization - Network I/O — the volume of incoming/outgoing traffic and packets on all network interfaces. Metrics:
NetworkIn,NetworkOut,NetworkPacketsIn,NetworkPacketsOut - Disk I/O — read/write operations and throughput for instance store volumes. Metrics:
DiskReadOps,DiskWriteOps,DiskReadBytes,DiskWriteBytes - EBS throughput and IOPS — read/write throughput and operations for attached EBS volumes. Metrics:
VolumeReadBytes,VolumeWriteBytes,VolumeReadOps,VolumeWriteOps - GPU utilization — the percentage of allocated GPUs in use, GPU memory usage, and active encoder sessions (when enabled via the CloudWatch Agent with NVIDIA GPU metrics). Metrics:
GPUUtilization,GPUMemoryUtilization,GPUEncoderStatsSessionCount
Based on these metrics, Compute Optimizer classifies each instance as:
| Finding | Meaning |
| Over-provisioned | Instance resources exceed workload needs — downsize opportunity |
| Under-provisioned | Workload demands exceed instance capacity — performance risk |
| Optimized | Current instance is well-matched to workload requirements |
| Idle | Instance has very low utilization — candidate for termination or consolidation (shown on a dedicated Idle Resource Recommendations page; criteria: peak CPU below 5% and network I/O under 5 MB/day over the 14-day lookback period; GPU instances (G/P families) have additional GPU-specific idle criteria) |
When AWS Cost Optimization Hub is enabled, Compute Optimizer factors in your existing pricing commitments (AWS Savings Plans, Reserved Instances and other specific pricing discounts) when generating savings estimates — see Best practice 1 below for details.
For each finding, Compute Optimizer lists up to three optimization recommendations for a specific instance, ranked by estimated savings, performance risk, and migration effort.
Note: While this post focuses on EC2 instance rightsizing, Compute Optimizer also generates recommendations for Amazon EC2 Auto Scaling groups (including mixed instance types and scaling policies), Amazon Elastic Block Store (Amazon EBS) volumes, AWS Lambda functions, Amazon Elastic Container Service (Amazon ECS) services on AWS Fargate, commercial software licenses, and Amazon Aurora/Amazon Relational Database Service (Amazon RDS) databases. Idle resource detection extends further — covering EC2 instances, Auto Scaling groups, EBS volumes, ECS on Fargate, Aurora/RDS, and NAT Gateways. For the full list of supported resources, see Supported resources.
Evaluating recommendations in the console
In the Compute Optimizer console, navigate to EC2 Instances and select any instance to view its detail page. From here you can:
- Compare utilization metrics — View side-by-side graphs showing how your current instance’s CPU, memory, network, and disk metrics map to the recommended instance’s capacity.
- Review estimated savings — See projected monthly cost savings for each recommended option. With AWS Cost Optimization Hub enabled, savings reflect your actual pricing discounts rather than On-Demand rates (see Best practice 1).
- Assess performance risk — Understand the likelihood that switching to the recommended instance may result in resource contention.
- Evaluate migration effort — Compute Optimizer rates each recommendation from Very low to High based on CPU architecture compatibility and inferred workload type. Same architecture is Very low effort; AWS Graviton (ARM64) recommendation with a known compatible workload (for example, Amazon EMR) is Low; Graviton with an unidentified workload is Medium; and a different architecture with no known compatible version is High effort.
- Toggle CPU architecture preferences — Use the architecture drop-down to compare x86-based recommendations against AWS Graviton (ARM64) alternatives for additional price-performance improvements.
Best practice 1: Enable Cost Optimization Hub for after-discount savings
Why this matters: Enabling Cost Optimization Hub gives Compute Optimizer visibility into your Savings Plans, Reserved Instances, and other pricing discounts — so every recommendation reflects what you would actually save given your existing commitments. This is especially valuable for organizations with significant discount coverage, where On-Demand savings estimates may be significantly higher than what you would actually realize after accounting for existing commitments.
When you enable Cost Optimization Hub, Compute Optimizer automatically switches to AfterDiscounts mode and uses your organization-specific pricing discounts to generate recommendations. The console then displays two savings columns — Estimated monthly savings (after discounts) and Estimated monthly savings (On-Demand) — giving you both views side by side. To enable Cost Optimization Hub for your organization, see Getting started with Cost Optimization Hub. The savings estimation mode preference allows Compute Optimizer to analyze specific pricing discounts when generating the estimated cost savings of rightsizing recommendations. You can verify or override the savings estimation mode under Preferences > Savings estimation mode in the Compute Optimizer console. See Savings estimation mode for details.
Best practice 2: Enable memory metrics for accurate recommendations
Why this matters: Memory utilization is not collected by default in CloudWatch. By enabling it, you give Compute Optimizer a complete picture of your workload — CPU, network, disk, and memory together. This is especially valuable for memory-intensive workloads (databases, caching layers, JVM-based applications), where memory is often the critical sizing factor. With full visibility, Compute Optimizer can factor memory needs into every recommendation, resulting in higher-confidence suggestions that your teams can implement with greater assurance.
Option A: CloudWatch Agent
Deploy the unified CloudWatch Agent on your instances to publish memory utilization metrics. Compute Optimizer automatically incorporates these metrics once they’re available in CloudWatch.
Note: Collecting memory metrics with the CloudWatch Agent incurs charges. See Amazon CloudWatch Pricing.
Key steps:
- Install the CloudWatch Agent via AWS Systems Manager or manually.
- Configure the agent to collect memory metrics.
- Verify metrics appear in CloudWatch.
- Allow up to 24 hours for Compute Optimizer to incorporate the new data.
Option B: External metrics ingestion
If your organization uses a third-party observability platform, Compute Optimizer supports ingesting EC2 memory utilization metrics from:
- Datadog
- Dynatrace
- Instana
- New Relic
When external metrics ingestion is enabled, Compute Optimizer analyzes external memory data alongside native CloudWatch metrics to generate enhanced recommendations.
Learn more: Configuring external metrics ingestion
Best practice 3: Configure rightsizing preferences to match your strategy
Why this matters: Compute Optimizer’s defaults — P99.5 threshold (sizes instances to handle 99.5% of observed CPU peaks), 20% headroom (adds a 20% capacity buffer above those peaks for future growth), and 14-day lookback — work well for many workloads. Customizing these preferences lets you go further — extending the lookback to 32 or 93 days captures monthly or seasonal patterns for even more accurate recommendations, while adjusting headroom and threshold lets you fine-tune the balance between savings and performance for each environment. The result: recommendations tailored to your actual risk tolerance and workload patterns, producing suggestions your teams will trust and confidently implement.
Compute Optimizer supports configurable rightsizing preferences that tailor recommendations to your workload requirements. Preferences can be set at the organization level (applies to all member accounts in your AWS Organizations), account level (applies to a specific account — useful when production and dev/test accounts need different settings), or regional level (applies within a specific region — useful when workloads differ across regions). This hierarchy lets you set conservative defaults org-wide and override for specific accounts or regions that need different treatment.
Key preference options include:
| Preference | Description | When to use |
| CPU utilization threshold | Before generating recommendations, Compute Optimizer filters your CPU data through this percentile. Think of it as a noise filter: P99.5 (default) keeps 99.5% of your data and only discards the rarest 0.5% of spikes — so the recommendation is sized to handle almost every peak you’ve ever seen. P90 discards the top 10% of spikes, treating them as anomalies, and produces smaller (cheaper) recommendations. Options: P90, P95, P99.5 | Use P99.5 for production where you can’t afford to miss peaks; P90 for dev/test where occasional spikes from deployments or one-off events are acceptable to ignore |
| CPU utilization headroom | After Compute Optimizer determines the right instance size based on your historical peaks, it adds this percentage as a safety cushion for future growth. For example: if your analyzed peak needs 60% of an instance’s CPU, a 20% headroom means the recommended instance will still have 20 percentage points of spare capacity above that peak — room to grow without needing another resize. Options: 30%, 20% (default), 0% | Use 30% for workloads with unpredictable or growing traffic; 20% for typical production; 0% for steady-state workloads where you want maximum savings and accept a tight fit |
| Memory utilization headroom | Added memory capacity buffer (30%, 20%, or 10%) above analyzed usage to accommodate future increases. Default is 20% | Use 30% for memory-sensitive workloads; 10% for steady-state where you want maximum savings |
| Lookback period | Choose 14 days (default, no additional charge), 32 days (no additional charge), or 93 days (requires Enhanced Infrastructure Metrics (EIM), a paid feature). You can enable EIM at the organization, account, or individual resource level — useful for activating it only on production workloads where the cost is justified | Use 32 days for monthly patterns; 93 days for seasonal or quarterly workloads |
| Preferred instance types | Restrict recommendations to specific instance families or types. For example, if you have purchased Savings Plans and Reserved Instances, you can specify instances only covered by those pricing models. Or, if you want to use only instances equipped with certain processors or non-burstable instances because of your application design, you can specify those instances for your recommendation output | When organizational standards, procurement commitments (RIs/SPs), or application design require approved instance families |
Learn more: How to take advantage of rightsizing recommendation preferences
Best practice 4: Evaluate Graviton recommendations carefully
Why this matters: Compute Optimizer can recommend migrating x86 workloads to AWS Graviton instances, which deliver up to 40% better price-performance. However, unlike same-architecture rightsizing (which is a configuration change), Graviton involves a CPU architecture shift from x86 to ARM64 — so a structured evaluation process helps you validate compatibility and capture the full savings with confidence.
Before migrating to Graviton:
- Assess architecture compatibility — Verify that your application binaries, libraries, and dependencies support ARM64. Container-based workloads (using multi-arch images) typically require less modification to migrate.
- Check software dependencies — Confirm third-party agents, drivers, and monitoring tools are available for ARM64.
- Test in non-production first — Deploy the recommended Graviton instance in a staging environment.
- Run load tests — Validate performance parity with the current instance.
- Use the Graviton Transition Guide — Follow the AWS Graviton Getting Started guide for a structured migration approach.
- How to identify a good target workload — A good candidate for Graviton adoption is a workload running on Linux or BSD, built either using open-source components or source code that you control. Having full access to the source code of every component allows you to make any necessary changes quickly and easily as part of this adoption plan. If you use third-party software, many ISVs already support the Arm64 architecture implemented by AWS Graviton processors.
When to defer Graviton recommendations:
- Legacy applications compiled for x86 without source code access.
- Workloads with licensing tied to specific CPU architectures.
- Applications with untested third-party binary dependencies.
Learn more: AWS Compute Optimizer Graviton migration guidance
Best practice 5: Implement a rightsizing workflow
Why this matters: A structured workflow turns Compute Optimizer’s recommendations into sustained, measurable cost savings. By establishing a regular cadence — reviewing, validating with stakeholders, and tracking results — your organization builds a continuous optimization loop that adapts as workloads evolve, compounds savings over time, and gives finance teams clear visibility into realized cost reductions.
To operationalize Compute Optimizer recommendations across your organization:
- Establish a regular review cadence — Schedule weekly or bi-weekly rightsizing reviews with your FinOps or cloud operations team.
- Prioritize by savings and confidence — Focus first on Over-provisioned instances with high estimated savings and low performance risk.
- Validate with application owners — Share recommendations with workload owners for context on usage patterns that metrics alone may not reveal (for example, seasonal traffic, scheduled batch jobs).
- Track implementation — Use AWS Cost Explorer to measure realized savings after rightsizing changes.
Note: Tag instances for effective rightsizing at scale. Compute Optimizer recommendations become more actionable when your instances carry consistent tags. At minimum, tag with Environment (prod/staging/dev) to drive review priority, and Application/Workload and Owner/Team to route recommendations to the right team. Compute Optimizer’s console, exports, and API all support tag-based filtering (tag:key and tag-key filters).
Taking it further — automate your workflow: For organizations ready to move beyond manual reviews, Compute Optimizer offers built-in automation that allows you to create automation rules that continuously clean up unattached volumes and upgrade volume types based on Compute Optimizer’s data-driven recommendations. For EC2 instance rightsizing, AWS provides a reference architecture for automating Compute Optimizer recommendations using AWS Step Functions, Amazon EventBridge, and AWS Lambda. See: Optimize costs by automating AWS Compute Optimizer recommendations
Clean up
If you installed the CloudWatch Agent as part of best practice 2 and no longer need memory metrics, stop and remove the agent to avoid ongoing custom metric charges.
Conclusion
AWS Compute Optimizer provides data-driven recommendations to help you make more informed EC2 rightsizing decisions. By enabling memory metrics, configuring recommendation preferences aligned to your workload needs, carefully evaluating Graviton alternatives, and establishing a systematic review process, you can identify opportunities to help optimize your EC2 fleet and help reduce costs while considering the performance your applications require.