Right-Sizing and Compute Optimizer
Use AWS Compute Optimizer recommendations to downsize over-provisioned EC2 instances, Lambda functions, and EBS volumes to lower costs.
Right-Sizing and Compute Optimizer is a free AWS Solutions Architect lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Solutions Architect learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The Over-Provisioning Problem
One of the most common and costly mistakes in cloud architecture is over-provisioning — allocating more resources than the workload actually needs. IT teams often over-provision due to on-premises habits (buying capacity for peak load), fear of performance degradation, or simply never reviewing initial sizing decisions. In AWS, over-provisioned EC2 instances, EBS volumes, and Lambda functions waste money every minute they run. Right-sizing is the systematic process of identifying and eliminating this waste.
# Common over-provisioning symptoms:
# EC2: average CPU < 10%, memory < 20%
# RDS: storage auto-grow never triggered
# Lambda: allocated memory rarely exceeds 40%
# EBS: provisioned IOPS consistently unused
# Cost impact example:
# Over-provisioned r5.8xlarge at $1.92/hr: $1,382/month
# Correct size r5.xlarge at $0.252/hr: $181/month
# Savings: $1,201/month per instanceAWS Compute Optimizer Overview
AWS Compute Optimizer analyses historical utilisation metrics from CloudWatch and uses machine learning to recommend optimal AWS compute resources. It covers EC2 instances, EC2 Auto Scaling Groups, EBS volumes, Lambda functions, and Amazon ECS on Fargate. Compute Optimizer requires at least 30 days of metric history to generate confident recommendations. It is free to enable and provides recommendations with estimated monthly savings and a risk rating for changing.
# Opt in to Compute Optimizer
aws compute-optimizer update-enrollment-status \
--status Active
# Get EC2 recommendations
aws compute-optimizer get-ec2-instance-recommendations \
--query 'instanceRecommendations[].{Instance:currentInstanceType,Recommended:recommendationOptions[0].instanceType,Savings:recommendationOptions[0].estimatedMonthlySavings.value,Risk:recommendationOptions[0].performanceRisk}'
# Get Lambda recommendations
aws compute-optimizer get-lambda-function-recommendationsEC2 Right-Sizing with Compute Optimizer
Compute Optimizer analyses EC2 CPU utilisation, memory utilisation (via CloudWatch agent), network throughput, and EBS IOPS over the past 3, 14, or 30+ days. It then recommends one of four findings: Optimized (current size is appropriate), Over-provisioned (can downsize), Under-provisioned (should upsize), or Not optimized (insufficient data). Always review performance risk — Compute Optimizer assigns VeryLow, Low, Medium, High risk to each recommendation.
# EC2 recommendation findings:
# Finding: OVER_PROVISIONED
# CurrentInstanceType: m5.4xlarge
# RecommendedInstanceType: m5.xlarge
# CPU utilisation: P99 = 22%, P50 = 4%
# Memory utilisation: P99 = 18%, P50 = 8%
# EstimatedMonthlySavings: $380
# PerformanceRisk: VeryLow
# Always check:
# - Does current instance have burstable credits? (T3)
# - Are there workload spikes not captured in averages?
# - Is there seasonality to consider?Lambda Right-Sizing
Lambda functions are billed per millisecond of execution time multiplied by memory allocated. Allocating more memory than needed wastes money, but more memory also means more CPU — so the right balance is the memory setting where cost per invocation is minimised. Compute Optimizer analyses Lambda invocation duration, error rate, and timeout metrics to recommend the optimal memory setting. The open-source Lambda Power Tuning tool can also invoke your function at different memory settings to find the cost-optimal configuration empirically.
# Compute Optimizer Lambda recommendations
aws compute-optimizer get-lambda-function-recommendations \
--function-arns arn:aws:lambda:us-east-1:123:function:my-function
# Response shows:
# currentMemorySize: 1024 MB
# recommendedMemorySize: 256 MB
# utilizationMetrics:
# - type: MEMORY_MAXIMUM, value: 89 (MB)
# estimatedMonthlySavings: $45
# 89 MB actual vs 1024 MB allocated = 935 MB wastedEBS Volume Right-Sizing
EBS volumes are often over-provisioned on both size (unused disk space) and IOPS (provisioned IOPS that are never consumed). Compute Optimizer analyses VolumeReadOps, VolumeWriteOps, VolumeReadBytes, VolumeWriteBytes metrics. Common recommendation: migrate from gp2 to gp3 (which separates size from IOPS) — you can right-size IOPS independently, often saving 20%. Also identify unattached EBS volumes (instances terminated but volumes left behind) and snapshot or delete them.
# Get EBS volume recommendations
aws compute-optimizer get-ebs-volume-recommendations \
--volume-arns arn:aws:ec2:us-east-1:123:volume/vol-12345
# Common finding: gp2 -> gp3 migration
# gp2: 500 GB = 500 GB * $0.10 = $50/month
# IOPS: 1,500 (3 IOPS/GB, not configurable)
# gp3: 500 GB = $40/month + 3,000 IOPS free
# Save $10/month plus get MORE baseline IOPS
# Find unattached EBS volumes
aws ec2 describe-volumes \
--filters Name=status,Values=available \
--query 'Volumes[].{VolumeId:VolumeId,Size:Size,Created:CreateTime}'Auto Scaling Group Recommendations
Compute Optimizer analyses ASG utilisation across the entire group's instances and recommends launch template changes for the instance type. If all instances in an ASG are consistently over-provisioned, switching to a smaller instance type reduces cost at scale. For example, if an ASG averages 10 instances of m5.large, switching to m5.medium saves 50% per instance. Compute Optimizer also recommends Graviton-based instances when your software is compatible, providing both performance improvement and cost reduction.
# Get ASG recommendations
aws compute-optimizer get-auto-scaling-group-recommendations \
--auto-scaling-group-arns arn:aws:autoscaling:us-east-1:123:autoScalingGroup:abc:autoScalingGroupName/my-asg
# If recommendation is to switch to Graviton:
# Current: m5.large (x86, $0.096/hr)
# Recommended: m6g.large (Graviton2, $0.077/hr)
# Savings: 20% per instance
# ASG at 10 instances average = $220/month savingsTrusted Advisor for Cost Insights
AWS Trusted Advisor is another tool that provides cost optimisation insights alongside security, performance, fault tolerance, and service limit checks. Key cost checks: Low Utilization EC2 Instances (less than 10% CPU for 4+ days), Unassociated Elastic IP Addresses (charged when not attached), Underutilized EBS Volumes, Idle Load Balancers (no healthy targets), and Unused Reserved Instances. Trusted Advisor basic checks are free; the full set requires Business or Enterprise Support.
# Trusted Advisor: get cost optimisation checks
aws support describe-trusted-advisor-checks \
--language en \
--query 'checks[?category==`cost_optimizing`].{Name:name,Id:id}'
# Key checks:
# Qkj5MU5fNp: Low utilisation EC2 instances
# Z4AUBRNSmh: Unassociated Elastic IP addresses
# DAvU99Dc4C: Underutilized EBS volumes
# hjLMh88uM8: Idle load balancers
# 1e93e4c0b5: Unused reserved instancesInstance Generation Upgrades
AWS regularly releases new, more efficient EC2 instance generations that offer better performance at lower or equal cost. Moving from 5th gen (m5, c5, r5) to 7th gen (m7g, c7g, r7g) can provide 40% better compute performance at similar or lower cost. Compute Optimizer specifically flags opportunities to upgrade to newer generations, including Graviton-based instances. Instance upgrades are often the simplest right-sizing action — same configuration, newer hardware, better performance, lower cost.
# EC2 instance generation comparison (same price tier):
# m5.large: 2 vCPU, 8 GB, $0.096/hr (2019)
# m6i.large: 2 vCPU, 8 GB, $0.096/hr (2021, ~10% faster)
# m7i.large: 2 vCPU, 8 GB, $0.1008/hr (2023, ~15% faster)
# m7g.large: 2 vCPU, 8 GB, $0.0808/hr (2023, Graviton3, cheapest)
# Upgrade path for Linux workloads:
# m5 -> m7g (Graviton): best price/performance
# m5 -> m7i: same architecture, no code changesRDS Instance Right-Sizing
RDS instances are expensive and often over-provisioned. Use CloudWatch metrics to evaluate RDS utilisation: CPUUtilization, FreeableMemory, ReadIOPS, and WriteIOPS. If CPU stays below 20% and memory remains consistently high, consider downsizing. For production databases with Multi-AZ, right-sizing doubles the savings since both primary and standby change. Also consider switching from RDS MySQL/PostgreSQL to Aurora, which often provides better performance at similar cost and is more cost-efficient at scale.
# Monitor RDS utilisation for right-sizing
aws cloudwatch get-metric-statistics \
--namespace AWS/RDS \
--metric-name CPUUtilization \
--dimensions Name=DBInstanceIdentifier,Value=mydb \
--start-time 2026-05-21T00:00:00Z \
--end-time 2026-06-21T00:00:00Z \
--period 86400 \
--statistics Maximum Average
# If 30-day P99 CPU < 30%, consider downsizing
# If P99 CPU > 80%, consider upsizingOperationalising Right-Sizing
Right-sizing should be an ongoing process, not a one-time exercise. Establish a monthly or quarterly review cadence: pull Compute Optimizer recommendations, evaluate which are safe to apply, implement changes in a maintenance window, and measure the savings. Automate the easy wins: unattached EBS volume cleanup, unused Elastic IP release, and idle load balancer removal can be scripted. Create a Cost Optimisation Dashboard in CloudWatch that tracks monthly spend by service and highlights unusual increases.
# Script to release unassociated Elastic IPs
aws ec2 describe-addresses \
--query 'Addresses[?!AssociationId].AllocationId' \
--output text | xargs -I {} \
aws ec2 release-address --allocation-id {}
# Script to delete unattached EBS volumes (careful!)
# First check if snapshots exist before deleting
aws ec2 describe-volumes \
--filters Name=status,Values=available \
--query 'Volumes[].VolumeId' \
--output textRight-Sizing vs Architecture Changes
Right-sizing addresses over-provisioning within existing architectures, but sometimes the architecture itself is the problem. A single large EC2 instance running multiple applications might need architectural decomposition (microservices on Fargate) rather than just a smaller instance. A monolithic database might need sharding or caching rather than just an instance downsize. Right-sizing is the first, quickest step. Architecture optimisation (serverless, containers, caching) provides the deeper, more sustained savings but requires more effort. The Cost Optimisation pillar recommends pursuing both.
# Cost optimisation hierarchy:
# Level 1: Right-sizing (quick wins, days)
# - Compute Optimizer recommendations
# - Delete unused resources
# - Elastic IP, EBS cleanup
# Level 2: Purchasing model (weeks)
# - Reserved Instances / Savings Plans
# - Spot for eligible workloads
# Level 3: Architecture (months)
# - Serverless migration
# - Container consolidation
# - Caching layer addition
# - Database optimisationQuick Check
Test your understanding of AWS Solutions Architect (SAA-C03) concepts from this lesson.
Lesson Recap
In this lesson you learned: AWS Compute Optimizer uses machine learning on CloudWatch metrics to recommend right-sized compute resources, right-sizing applies to EC2, Lambda, EBS, ASGs, and ECS on Fargate, and upgrading to newer instance generations (especially Graviton) provides both cost and performance improvements. Make right-sizing a recurring practice, not a one-time event. Next up we explore Reserved Instances, Savings Plans, and Spot purchasing models.
Frequently asked questions
Is the “Right-Sizing and Compute Optimizer” lesson free?
Yes — the full text of “Right-Sizing and Compute Optimizer” is free to read here on the web, and the AWS Solutions Architect course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Solutions Architect course, upgrade to CoddyKit PRO.
What will I learn in “Right-Sizing and Compute Optimizer”?
Use AWS Compute Optimizer recommendations to downsize over-provisioned EC2 instances, Lambda functions, and EBS volumes to lower costs. You practise AWS Solutions Architect with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start AWS Solutions Architect?
No prior experience is required. AWS Solutions Architect on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Right-Sizing and Compute Optimizer” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this AWS Solutions Architect lesson?
Yes. Every AWS Solutions Architect lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Right-Sizing and Compute Optimizer
- Reserved Instances, Savings Plans, and Spot
- Cost Explorer, Budgets, and Cost Allocation Tags
- S3 and Data Transfer Cost Optimisation