Skip to main content
Cloud DevOps Solutions
Get a quote Talk to an engineer
Cloud Cost 2026-11-12 16 min read

EC2 Cost Optimisation: Right-Sizing, Savings Plans, Spot, and Graviton

Saddique Khan

DevOps / SRE Engineer & CEO, Cloud DevOps Solutions

EC2 is the largest line item on most AWS bills. It is also the service where the gap between what you pay and what you need is widest. Teams provision for peak load, choose familiar instance types out of habit, and never revisit the decision. The result: fleets running at 10-20% average CPU utilisation on On-Demand pricing.

The good news is that EC2 offers more cost levers than any other AWS service. Right-sizing, commitment discounts, Spot capacity, processor architecture, and scheduling can reduce a typical EC2 bill by 40-70%. The challenge is knowing which lever to pull first, and how far to pull it.

This guide covers each optimisation in the order that delivers the most impact with the least risk.

1. Measure before you optimise

You cannot right-size what you cannot measure. Before changing anything, establish a baseline.

AWS Compute Optimizer

AWS Compute Optimizer analyses 14 days of CloudWatch metrics and recommends optimal instance types. It is free for basic recommendations and covers EC2, Auto Scaling groups, EBS volumes, and Lambda functions.

Enable it account-wide:

aws compute-optimizer update-enrollment-status \
  --status Active \
  --include-member-accounts

Compute Optimizer evaluates:

  • CPU utilisation (average, P99)
  • Memory utilisation (requires CloudWatch Agent)
  • Network bandwidth usage
  • Disk I/O throughput and IOPS

It then recommends instance types that match actual usage, including cross-family recommendations (e.g. moving from an m5.xlarge to a c6g.large if the workload is CPU-bound).

CloudWatch Agent for memory metrics

EC2 basic monitoring does not include memory utilisation. Without it, Compute Optimizer and your own analysis are blind to memory-bound workloads. Install the CloudWatch Agent on every instance:

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl \
  -a fetch-config \
  -m ec2 \
  -s \
  -c ssm:AmazonCloudWatch-linux

Store the agent configuration in SSM Parameter Store so it applies consistently across your fleet.

AWS Trusted Advisor

AWS Trusted Advisor provides complementary checks:

  • Low utilisation EC2 instances: flags instances with average CPU below 10% over 14 days
  • Idle load balancers: ALBs and NLBs with zero healthy targets
  • Unassociated Elastic IPs: $3.65/month each, easy to forget

Trusted Advisor’s cost optimisation checks are available on all support plans. The detailed recommendations (instance-level) require Business or Enterprise support.

2. Right-size your instances

Right-sizing means matching the instance type and size to the workload’s actual resource requirements, not its theoretical peak.

The right-sizing process

Step 1: Export Compute Optimizer recommendations

aws compute-optimizer get-ec2-instance-recommendations \
  --filters "name=Finding,values=OVER_PROVISIONED" \
  --output json > over-provisioned.json

Step 2: Prioritise by savings

Sort recommendations by estimated monthly savings. Focus on the top 20% of instances; they typically account for 80% of the waste.

Step 3: Validate before resizing

For each recommendation, check:

  • Does the workload have seasonal peaks that the 14-day analysis window might have missed?
  • Is memory the binding constraint? (Compute Optimizer misses this without CloudWatch Agent)
  • Does the application have minimum CPU or memory requirements documented?
  • Are there licence implications? (Some software licences are tied to vCPU count)

Step 4: Resize

For standalone instances, resize during a maintenance window:

aws ec2 stop-instances --instance-ids i-0123456789abcdef0
aws ec2 modify-instance-attribute \
  --instance-id i-0123456789abcdef0 \
  --instance-type '{"Value": "m6g.large"}'
aws ec2 start-instances --instance-ids i-0123456789abcdef0

For Auto Scaling groups, update the launch template and perform a rolling replacement:

aws ec2 create-launch-template-version \
  --launch-template-id lt-0123456789abcdef0 \
  --source-version '$Latest' \
  --launch-template-data '{"InstanceType": "m6g.large"}'

aws autoscaling start-instance-refresh \
  --auto-scaling-group-name my-asg \
  --preferences '{"MinHealthyPercentage": 90}'

Step 5: Monitor for 7 days

After resizing, watch CPU, memory, network, and application latency for one week. If any metric exceeds 80% sustained, scale back up.

Common right-sizing wins

BeforeAfterMonthly saving per instance
m5.xlarge (4 vCPU, 16 GiB)m6i.large (2 vCPU, 8 GiB)~$70
r5.2xlarge (8 vCPU, 64 GiB)r6g.xlarge (4 vCPU, 32 GiB)~$140
c5.4xlarge (16 vCPU, 32 GiB)c6g.2xlarge (8 vCPU, 16 GiB)~$180
t3.2xlarge (8 vCPU, 32 GiB)t3.xlarge (4 vCPU, 16 GiB)~$60

Across a fleet of 100 instances, even conservative right-sizing saves $5,000-$15,000/month.

3. Migrate to Graviton

AWS Graviton processors (Arm-based, custom designed by AWS) deliver up to 40% better price-performance than equivalent x86 instances. They are available across most instance families: m7g, c7g, r7g, t4g, and more.

Why Graviton saves money

A Graviton instance is cheaper per hour than its x86 equivalent and often delivers equal or better performance:

x86 instanceGraviton equivalentPrice reductionPerformance
m6i.xlarge ($0.192/hr)m7g.xlarge ($0.163/hr)15%Equal or better
c6i.2xlarge ($0.340/hr)c7g.2xlarge ($0.290/hr)15%10-25% better
r6i.xlarge ($0.252/hr)r7g.xlarge ($0.214/hr)15%Equal or better

The 15% price reduction combined with the performance improvement means many workloads need a smaller Graviton instance than their current x86 instance, compounding the savings.

Migration path

Containerised workloads (ECS/EKS):

  1. Build multi-architecture container images using docker buildx:
docker buildx build \
  --platform linux/amd64,linux/arm64 \
  --tag my-app:latest \
  --push .
  1. Add a Graviton node group to your EKS cluster or update the ECS task definition
  2. Route non-critical workloads to Graviton nodes first
  3. Monitor performance for one week, then migrate remaining workloads

Managed services:

RDS, ElastiCache, and OpenSearch all support Graviton-based instance types. Switch during the next maintenance window by modifying the instance class (e.g. db.r6g.xlarge instead of db.r6i.xlarge). No application changes required.

EC2 directly:

Most Linux workloads run without modification on Graviton:

  • Java 11+ (Corretto is optimised for Graviton)
  • Python, Node.js, Go, Rust, .NET 6+
  • PHP 8+
  • Most compiled C/C++ (recompile for arm64)

Test your application on a single Graviton instance before migrating the fleet. The main compatibility issue is native binaries or libraries compiled only for x86.

4. Use Savings Plans

On-Demand pricing is the rack rate. Savings Plans commit to a consistent amount of compute usage (measured in $/hour) for one or three years, in exchange for discounts of 30-60%.

Types of Savings Plans

Compute Savings Plans:

  • Apply to any EC2 instance (any family, size, OS, region), Fargate, and Lambda
  • Most flexible option
  • 1-year: 20-35% discount
  • 3-year: 40-55% discount

EC2 Instance Savings Plans:

  • Locked to a specific instance family and region (e.g. m6i in us-east-1)
  • Deeper discount than Compute
  • 1-year: 30-45% discount
  • 3-year: 50-72% discount

How to calculate commitment

  1. Open Cost Explorer > Savings Plans > Recommendations
  2. Look at your hourly On-Demand spend over the last 30 days
  3. Identify the steady-state baseline (the flat floor, not the peaks)
  4. Commit to 70-80% of that baseline

Example: your EC2 fleet costs $20/hour steady-state and peaks to $30/hour during business hours.

  • Commit $14-16/hour as Savings Plans (70-80% of $20)
  • The remaining $4-6/hour base + $10 peak stays On-Demand
  • Savings on the committed portion: 30-55% depending on term

Savings Plans vs Reserved Instances

For EC2, Savings Plans have largely replaced Reserved Instances. The key differences:

  • Savings Plans apply across instance families; RIs are locked to a specific type
  • Savings Plans cover Fargate and Lambda; RIs do not
  • RIs offer slightly deeper discounts in some configurations
  • RIs can be sold on the Reserved Instance Marketplace if your needs change

Use RIs for: RDS, ElastiCache, OpenSearch, and Redshift, where Savings Plans do not apply.

Use Savings Plans for: EC2, EKS node groups, Fargate tasks, Lambda functions.

5. Leverage Spot instances

Spot instances use AWS spare capacity at up to 90% discount. AWS can reclaim them with 2 minutes notice, but for the right workloads, the savings are transformative.

Best candidates for Spot

  • CI/CD build agents: a build interrupted by a Spot reclamation simply retries
  • Batch processing: EMR, AWS Batch, data pipelines with checkpointing
  • EKS worker nodes: stateless pods with multiple replicas handle interruptions gracefully
  • Dev and test environments: combined with scheduling for maximum savings
  • Training workloads: ML training with checkpoint-resume
  • Rendering and transcoding: embarrassingly parallel, easily retried

Spot best practices

Diversify instance types. Request capacity across multiple instance families and sizes. A Spot request for only c5.2xlarge competes with everyone else requesting that exact type. A request that accepts c5, c5a, c5n, c6i, c6g, m5, and m6i across multiple sizes draws from a much larger capacity pool.

For EKS, Karpenter handles this automatically, selecting from dozens of instance types and falling back to On-Demand when Spot is unavailable.

Use capacity-optimised allocation:

aws ec2 run-instances \
  --instance-market-options '{"MarketType": "spot", "SpotOptions": {"SpotInstanceType": "persistent", "InstanceInterruptionBehavior": "stop"}}' \
  --instance-type m6i.xlarge

For Auto Scaling groups, use capacity-optimized allocation strategy:

{
  "MixedInstancesPolicy": {
    "InstancesDistribution": {
      "OnDemandBaseCapacity": 2,
      "OnDemandPercentageAboveBaseCapacity": 30,
      "SpotAllocationStrategy": "capacity-optimized"
    },
    "LaunchTemplate": {
      "Overrides": [
        {"InstanceType": "m6i.xlarge"},
        {"InstanceType": "m6g.xlarge"},
        {"InstanceType": "m5.xlarge"},
        {"InstanceType": "c6i.xlarge"},
        {"InstanceType": "c6g.xlarge"}
      ]
    }
  }
}

This configuration keeps 2 On-Demand instances as a base, runs 30% of additional capacity as On-Demand (for stability), and fills the remaining 70% with Spot from the cheapest available type.

Handle interruptions. Use the EC2 metadata service to detect the 2-minute interruption warning and drain gracefully. For EKS, the AWS Node Termination Handler automates this.

Spot savings example

A fleet of 20 m6i.xlarge instances On-Demand: ~$2,880/month.

With 70% Spot (14 instances at ~$0.058/hr) and 30% On-Demand (6 instances at $0.192/hr):

  • Spot cost: 14 x $0.058 x 730 = ~$593
  • On-Demand cost: 6 x $0.192 x 730 = ~$841
  • Total: ~$1,434/month (50% saving)

6. Schedule non-production instances

Development, staging, and QA environments that run 24/7 but are used only during business hours waste 70% of their compute budget.

AWS Instance Scheduler

AWS provides the Instance Scheduler solution, a CloudFormation template that deploys Lambda functions to start and stop instances on a schedule:

  1. Deploy the AWS Instance Scheduler CloudFormation stack
  2. Tag instances with Schedule: office-hours
  3. Define the schedule in a DynamoDB table

Simple approach with EventBridge and Lambda

For a lighter solution, use EventBridge rules to trigger Lambda functions:

import boto3

def stop_dev_instances(event, context):
    ec2 = boto3.client('ec2')
    filters = [
        {'Name': 'tag:Environment', 'Values': ['dev', 'staging']},
        {'Name': 'instance-state-name', 'Values': ['running']}
    ]
    instances = ec2.describe_instances(Filters=filters)
    ids = [
        i['InstanceId']
        for r in instances['Reservations']
        for i in r['Instances']
    ]
    if ids:
        ec2.stop_instances(InstanceIds=ids)
        return f"Stopped {len(ids)} instances"
    return "No instances to stop"

Schedule this Lambda with EventBridge:

  • Stop: weekdays at 19:00 UTC
  • Start: weekdays at 07:00 UTC

Auto Scaling to zero

For environments behind Auto Scaling groups, schedule the desired capacity to zero outside hours:

aws autoscaling put-scheduled-action \
  --auto-scaling-group-name dev-asg \
  --scheduled-action-name scale-down-evening \
  --recurrence "0 19 * * MON-FRI" \
  --desired-capacity 0 \
  --min-size 0

aws autoscaling put-scheduled-action \
  --auto-scaling-group-name dev-asg \
  --scheduled-action-name scale-up-morning \
  --recurrence "0 7 * * MON-FRI" \
  --desired-capacity 3 \
  --min-size 1

Savings impact

A 10-instance dev environment at $1,500/month running only during business hours (50 hours/week vs 168): approximately $450/month, a 70% saving.

7. Clean up waste

EC2 waste accumulates silently. These resources cost money every hour whether they are used or not.

Unattached EBS volumes

When an instance is terminated, its EBS volumes can persist. Find and clean them:

aws ec2 describe-volumes \
  --filters "Name=status,Values=available" \
  --query "Volumes[*].{ID:VolumeId,Size:Size,Type:VolumeType,Created:CreateTime}" \
  --output table

For each unattached volume: snapshot it (for safety), then delete it. A 500 GiB gp3 volume costs $40/month whether attached or not.

Old snapshots

EBS snapshots accumulate over months and years. A single daily snapshot of a 1 TiB volume generates $50+/month in snapshot storage after a year.

# Find snapshots older than 90 days
aws ec2 describe-snapshots \
  --owner-ids self \
  --query "Snapshots[?StartTime<='$(date -v-90d +%Y-%m-%d)'].{ID:SnapshotId,Size:VolumeSize,Date:StartTime}" \
  --output table

Implement a retention policy: keep daily snapshots for 7 days, weekly for 30 days, monthly for 1 year. Use AWS Backup or a Lambda function to automate this.

Stopped instances

Instances that have been stopped for 30+ days are almost certainly forgotten. The instance itself does not incur compute charges while stopped, but its EBS volumes, Elastic IPs, and attached ENIs still cost money.

aws ec2 describe-instances \
  --filters "Name=instance-state-name,Values=stopped" \
  --query "Reservations[*].Instances[*].{ID:InstanceId,Type:InstanceType,StopTime:StateTransitionReason}" \
  --output table

Review with the owning team, then terminate and clean up associated resources.

Unused Elastic IPs

Each unassociated Elastic IP costs $0.005/hour ($3.65/month). They are easy to forget:

aws ec2 describe-addresses \
  --query "Addresses[?AssociationId==null].{IP:PublicIp,AllocationId:AllocationId}" \
  --output table

Old AMIs

Custom AMIs accumulate as teams build new versions but never deregister old ones. Each AMI’s backing snapshots cost money:

aws ec2 describe-images \
  --owners self \
  --query "Images[*].{ID:ImageId,Name:Name,Created:CreationDate}" \
  --output table

Keep the 3 most recent AMIs per application for rollback capability. Deregister the rest and delete their backing snapshots.

8. Optimise EBS volumes

EBS volumes often run on more expensive types than needed.

gp3 vs gp2

gp3 is cheaper than gp2 in nearly every scenario:

  • gp3 baseline: 3,000 IOPS and 125 MiB/s throughput, included in the price
  • gp2 baseline: 3 IOPS per GiB (a 100 GiB volume gets 300 IOPS)
  • gp3 costs $0.08/GiB; gp2 costs $0.10/GiB

A 500 GiB gp2 volume costs $50/month with 1,500 IOPS. A 500 GiB gp3 volume costs $40/month with 3,000 IOPS (double the performance at 20% less cost).

Migrate all gp2 volumes to gp3:

aws ec2 modify-volume \
  --volume-id vol-0123456789abcdef0 \
  --volume-type gp3

This is a live operation; no downtime required. The migration happens in the background.

Right-size provisioned IOPS

io2 and io1 volumes with provisioned IOPS are expensive. Check actual IOPS usage in CloudWatch (VolumeReadOps + VolumeWriteOps). If average IOPS is well below provisioned, reduce the IOPS setting or switch to gp3 with provisioned IOPS (cheaper per IOPS than io2).

9. Use Auto Scaling effectively

Auto Scaling prevents both over-provisioning (too many instances running idle) and under-provisioning (not enough capacity for demand).

Target tracking vs step scaling

Target tracking is simpler and works well for most workloads:

aws autoscaling put-scaling-policy \
  --auto-scaling-group-name production-asg \
  --policy-name cpu-target-70 \
  --policy-type TargetTrackingScaling \
  --target-tracking-configuration '{
    "PredefinedMetricSpecification": {
      "PredefinedMetricType": "ASGAverageCPUUtilization"
    },
    "TargetValue": 70.0
  }'

This maintains average CPU at 70% by adding or removing instances. The 70% target leaves headroom for traffic spikes while keeping utilisation high enough to be cost-efficient.

Predictive scaling

For workloads with predictable daily patterns (e.g. an e-commerce site that peaks at lunchtime), enable predictive scaling:

aws autoscaling put-scaling-policy \
  --auto-scaling-group-name production-asg \
  --policy-name predictive \
  --policy-type PredictiveScaling \
  --predictive-scaling-configuration '{
    "MetricSpecifications": [{
      "TargetValue": 70.0,
      "PredefinedMetricPairSpecification": {
        "PredefinedMetricType": "ASGCPUUtilization"
      }
    }],
    "Mode": "ForecastAndScale"
  }'

Predictive scaling analyses 14 days of metrics and pre-provisions capacity before the expected demand, avoiding the lag of reactive scaling.

10. Tagging and governance

Cost optimisation erodes without governance. Every EC2 instance should carry tags that enable cost tracking and automation.

Required tags

TagPurposeExample
TeamCost allocationplatform, checkout
EnvironmentScheduling automationproduction, dev, staging
ServiceApplication mappingapi-gateway, payment-service
CostCentreFinance allocationeng-001, data-002

Enforcement

Use AWS Service Control Policies to deny EC2 launches without required tags:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Deny",
      "Action": "ec2:RunInstances",
      "Resource": "arn:aws:ec2:*:*:instance/*",
      "Condition": {
        "Null": {
          "aws:RequestTag/Team": "true",
          "aws:RequestTag/Environment": "true"
        }
      }
    }
  ]
}

Use AWS Config rules to detect instances that lose their tags over time and flag them for remediation.

Building a continuous optimisation process

EC2 cost optimisation is not a one-time project. Workloads change, new instances launch, and savings erode without ongoing attention.

Monthly review cadence

  1. Review Compute Optimizer recommendations for new over-provisioned instances
  2. Check Savings Plan utilisation in Cost Explorer. If utilisation is below 90%, you are paying for unused commitments. If it is at 100%, you may benefit from additional coverage.
  3. Run the waste cleanup scripts for unattached volumes, old snapshots, stopped instances, and unused EIPs
  4. Review Spot vs On-Demand ratio for workloads that could shift to Spot
  5. Check for new Graviton-compatible instance types as AWS regularly releases new generations

Automation

Automate what you can:

  • Waste cleanup: Lambda functions on a weekly schedule to snapshot and delete unattached volumes, release unused EIPs, and alert on stopped instances
  • Scheduling: EventBridge rules for non-production start/stop
  • Right-sizing alerts: CloudWatch alarms for instances consistently below 10% CPU
  • Tag compliance: AWS Config rules with auto-remediation

For a broader view of AWS cost optimisation beyond EC2, our complete guide to reducing AWS costs covers S3, data transfer, RDS, Lambda, and governance. And for teams that want to compare cost tools across providers, see our cloud cost optimisation tools comparison.

Our cloud cost optimisation service combines EC2 right-sizing with architectural review, commitment strategy, and ongoing governance. Whether you are optimising a 10-instance environment or a 1,000-instance fleet, we bring the patterns that deliver measurable savings.

Key takeaways

  • Measure before you optimise: enable Compute Optimizer and install the CloudWatch Agent for memory metrics on every instance
  • Right-sizing delivers the quickest wins: most EC2 fleets run at 10-20% utilisation, and downsizing the worst offenders saves thousands per month
  • Graviton instances offer 15% lower prices with equal or better performance; most Linux workloads run without modification
  • Savings Plans at 70-80% of your steady-state hourly spend save 30-55% on committed compute
  • Spot instances save up to 90% for fault-tolerant workloads; diversify instance types and use capacity-optimised allocation
  • Scheduling non-production environments to stop outside business hours saves up to 70% on those resources
  • EBS waste (unattached volumes, old snapshots, gp2 volumes) accumulates silently; automate cleanup
  • Migrate all gp2 volumes to gp3 for 20% lower cost and double the baseline IOPS
  • Tagging and governance prevent optimisation gains from eroding as new resources launch

Spending more than you should on EC2? Book a free consultation and we will identify your top savings opportunities together.

#aws #ec2 #cost-optimization #savings-plans #spot-instances #graviton

Related service

Need hands-on help? Our certified engineers deliver this as a managed service.

Cloud Cost Optimisation
Found this useful? Share it with your team or link to it from your documentation.

Need help implementing this?

Our certified engineers can handle the setup, migration, or ongoing operations for you.