Advanced Cloud Cost Optimization Strategy Teams Overlook
Why a Strategic, Data‑Driven Approach Beats Ad‑Hoc Savings
Most teams treat cloud cost optimization as a checklist: delete unused volumes, right‑size instances, enable Spot where possible. Those actions deliver quick wins but leave a larger, systematic inefficiency untouched – the mismatch between actual workload demand and the static purchasing model of each resource. A strategic tactic that many overlook is dynamic workload placement: continuously matching each compute request to the cheapest viable instance type, purchasing option, and region using AWS Compute Optimizer, EC2 Fleet, and Spot Capacity Rebalancing. When implemented end‑to‑end, this approach can shave 20‑40 % off the compute bill without sacrificing performance.
1. Profile Your Workloads Before You Move Anything
Before you let a service decide where to run, you need a clear picture of its resource profile.
1.1 Gather CPU, memory, and network metrics
aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name CPUUtilization \
--dimensions Name=InstanceId,Value=i-0123456789abcdef0 \
--statistics Average \
--period 300 \
--start-time $(date -u -d '-30 days' +%Y-%m-%dT%H:%M:%SZ) \
--end-time $(date -u +%Y-%m-%dT%H:%M:%SZ)
Export the CSV and calculate the 95th‑percentile CPU and memory usage. Repeat for each autoscaling group or ECS service.
1.2 Identify burst patterns
Look for daily or weekly spikes. If a workload peaks for only a few hours, Spot or burstable instances may be cheaper than a continuously‑running On‑Demand instance.
1.3 Tag consistently for later automation
aws ec2 create-tags \
--resources i-0123456789abcdef0 \
--tags Key=CostProfile,Value=web‑frontend
Consistent tags let the automation script query only the relevant resources.
2. Let AWS Compute Optimizer Generate Concrete Recommendations
Compute Optimizer analyzes historical CloudWatch data and suggests instance types, sizes, and purchasing options that meet your performance targets at lower cost.
2.1 Enable the service (if not already on)
aws compute-optimizer update-enrollment-status \
--status Active
It may take up to 48 hours for the first set of recommendations to appear.
2.2 Pull recommendations via CLI
aws compute-optimizer get-recommendation-summaries \
--service-types EC2
The output includes recommendedInstanceType, estimatedMonthlySavings, and recommendedPurchaseOption (On‑Demand, Savings Plans, or Spot). Export to JSON for later processing.
2.3 Filter for high‑impact candidates
jq '.instanceRecommendations[] | select(.estimatedMonthlySavings > 50)' recommendations.json
Focus on recommendations that save at least $50 per month; smaller savings often fall within noise.
3. Build an EC2 Fleet That Mixes Instance Types and Purchasing Options
EC2 Fleet lets you request a target capacity while letting AWS choose the cheapest combination of instance types, AZs, and purchase options.
3.1 Create a launch template (shared across the fleet)
aws ec2 create-launch-template \
--launch-template-name web-fleet-template \
--version-description v1 \
--launch-template-data '{
"ImageId":"ami-0abcdef1234567890",
"KeyName":"my-key",
"SecurityGroupIds":["sg-0123abcd"],
"UserData":"$(base64 -w0 user-data.sh)"
}'
Keep the template generic; the fleet will decide the exact instance type.
3.2 Define the fleet request JSON
{
"TargetCapacitySpecification": {
"TotalTargetCapacity": 100,
"OnDemandTargetCapacity": 20,
"SpotTargetCapacity": 80,
"DefaultTargetCapacityType": "spot"
},
"LaunchTemplateConfigs": [
{
"LaunchTemplateSpecification": {
"LaunchTemplateId": "lt-0abcd1234ef567890",
"Version": "$Latest"
},
"Overrides": [
{"InstanceType": "c5.large"},
{"InstanceType": "c5a.large"},
{"InstanceType": "c6g.large"}
]
}
],
"SpotOptions": {
"AllocationStrategy": "capacity-optimized",
"InstanceInterruptionBehavior": "terminate",
"InstancePoolsToUseCount": 4,
"CapacityRebalance": true
}
}
Save as fleet-request.json.
3.3 Submit the fleet request
aws ec2 request-fleet --cli-input-json file://fleet-request.json
AWS will provision the cheapest mix that satisfies the target capacity, automatically falling back to On‑Demand if Spot is unavailable.
4. Enable Spot Capacity Rebalancing for Seamless Fallbacks
Spot Capacity Rebalancing proactively replaces instances that are about to be reclaimed, reducing interruption‑related performance loss.
4.1 Turn on the feature at the fleet level (already set in the JSON above with "CapacityRebalance": true).
If you need to enable it on an existing fleet:
aws ec2 modify-fleet \
--fleet-id fleet-0abcd1234ef567890 \
--spot-options CapacityRebalance=true
4.2 Verify the setting
aws ec2 describe-fleets --fleet-ids fleet-0abcd1234ef567890 \
--query 'Fleets[].SpotOptions.CapacityRebalance'
A true response confirms the feature is active.
5. Automate Placement Decisions with Lambda and EventBridge
Even with Compute Optimizer and EC2 Fleet, you need a loop that re‑evaluates every week and updates the fleet configuration.
5.1 Create a Lambda function (Python) that:
- Pulls the latest Compute Optimizer recommendations.
- Generates a new
Overrideslist based on the top‑3 instance types per workload. - Calls
aws ec2 modify-fleetto replace the overrides.
import json, subprocess, os
def lambda_handler(event, context):
# 1. Get recommendations
cmd = ['aws','compute-optimizer','get-recommendation-summaries','--service-types','EC2','--output','json']
rec = json.loads(subprocess.check_output(cmd))
# 2. Build overrides (simplified)
overrides = []
for r in rec['instanceRecommendations'][:3]:
overrides.append({"InstanceType": r['recommendedInstanceType']})
# 3. Update fleet
payload = {
"LaunchTemplateConfigs": [{
"LaunchTemplateSpecification": {"LaunchTemplateId": os.getenv('LT_ID'),"Version":"$Latest"},
"Overrides": overrides
}]
}
subprocess.run(['aws','ec2','modify-fleet','--fleet-id',os.getenv('FLEET_ID'),'--cli-input-json',json.dumps(payload)], check=True)
return {'status':'updated'}
Deploy the function with the required IAM permissions (ComputeOptimizerReadOnlyAccess, EC2FullAccess).
5.2 Schedule the Lambda with EventBridge (cron weekly)
aws events put-rule \
--name WeeklyFleetRefresh \
--schedule-expression "cron(0 3 ? * SUN *)"
aws events put-targets \
--rule WeeklyFleetRefresh \
--targets Id=1,Arn=arn:aws:lambda:us-east-1:123456789012:function:RefreshFleet
Now the fleet automatically adapts to any change in usage patterns.
6. Monitor Cost Impact and Adjust Parameters
Automation is only valuable if you can see the dollars saved.
6.1 Set up a Cost Explorer report for the fleet tag
- Open the Cost Explorer console.
- Create a new report.
- Group by Tag and select the tag you applied to the fleet (e.g.,
CostProfile=web‑frontend). - Save the report and enable daily refresh.
6.2 Add a CloudWatch alarm for unexpected cost spikes
aws cloudwatch put-metric-alarm \
--alarm-name FleetCostSpike \
--metric-name EstimatedCharges \
--namespace AWS/Billing \
--statistic Maximum \
--period 86400 \
--threshold 150 \
--comparison-operator GreaterThanThreshold \
--evaluation-periods 1 \
--alarm-actions arn:aws:sns:us-east-1:123456789012:CostAlerts
Adjust the --threshold to a value that represents an acceptable monthly spend for the fleet.
7. Comparison of Placement Strategies
| Strategy | Purchasing Options | Typical Savings | Operational Overhead | Best For |
|---|---|---|---|---|
| Static On‑Demand EC2 | On‑Demand only | 0 % (baseline) | Low – set‑and‑forget | Predictable, non‑bursty workloads |
| Reserved Instances / Savings Plans | Reserved or Savings | 20‑40 % | Medium – need capacity planning | Steady state, long‑term workloads |
| Spot Instances Only | Spot only | 60‑90 % | High – handle interruptions | Fault‑tolerant batch jobs |
| Dynamic EC2 Fleet (recommended) | Mixed Spot, On‑Demand, Savings | 30‑50 % | Medium‑High – automation required | Variable workloads with occasional spikes |
The table shows why the dynamic fleet approach often outperforms pure Spot or pure Reserved strategies: it captures the bulk of Spot discounts while retaining a safety net of On‑Demand capacity.
8. Real‑World Implementation Checklist
- [ ] Enable Compute Optimizer and wait for the first recommendation set.
- [ ] Tag all compute resources with a consistent
CostProfilekey. - [ ] Create a generic launch template.
- [ ] Define an EC2 Fleet JSON that uses
capacity‑optimizedSpot allocation and enablesCapacityRebalance. - [ ] Deploy the Lambda refresh function with required IAM roles.
- [ ] Schedule the Lambda via EventBridge (weekly or bi‑weekly).
- [ ] Configure Cost Explorer and CloudWatch alarms for the fleet tag.
- [ ] Review the free AWS waste finder tool to catch any leftover idle resources.
- [ ] After a month of data, iterate on the
Overrideslist to include newer instance families.
Frequently asked questions
How often should I refresh the EC2 Fleet configuration?
A weekly refresh balances responsiveness to usage changes with API rate limits. For highly volatile workloads you can move to a daily cadence, but monitor Lambda invocation limits.
Does Spot Capacity Rebalancing guarantee zero interruptions?
No. It reduces the window between a Spot termination notice and a replacement instance, but occasional brief interruptions are still possible. Design your application for graceful handling of SIGTERM.
Can I apply this strategy to containers running on ECS or EKS?
Yes. Both services can launch tasks on an EC2 Fleet. For EKS, use the aws-node daemonset with the fleet’s launch template; for ECS, set the capacity provider to the fleet.
Will using a mixed fleet affect my Savings Plans coverage?
Savings Plans apply to any usage that matches the plan’s instance family, regardless of purchase type. Spot usage does not count toward Savings Plans, but the On‑Demand portion of the fleet will still be covered.
Key takeaways
- Profile workloads first; data drives the right mix of instance types.
- Compute Optimizer provides concrete, cost‑based recommendations.
- EC2 Fleet with
capacity‑optimizedSpot andCapacityRebalanceautomatically selects the cheapest capacity. - A weekly Lambda + EventBridge loop keeps the fleet aligned with evolving demand.
- Continuous cost monitoring via Cost Explorer and CloudWatch alerts validates savings.
- The approach works across EC2, ECS, and EKS, making it a versatile, organization‑wide strategy.
Implementing this dynamic placement strategy removes the guesswork from cloud budgeting and turns cost optimization into a repeatable, automated process. CloudBudgetMaster can automate the entire workflow for you. Today it scans AWS accounts in read‑only mode, identifies idle and wasted resources, and reports the dollar impact. Support for GCP, Azure, and Snowflake is coming soon. To try the detection engine now, create a free account and run the free AWS waste finder.
CloudBudgetMaster