SkillSprout
Chapter 6 · Lesson 4
Intermediate
7 min read

Cost and Performance Optimization: Compute Optimizer, Trusted Advisor, Cost Explorer and Budgets

Overview

Running on AWS is not just keeping things up – it is keeping them efficient. SysOps administrators right-size resources, remove waste, buy commitments wisely and make costs visible to the teams that cause them. AWS provides a toolkit: Compute Optimizer (rightsizing recommendations), Trusted Advisor (best-practice checks), Cost Explorer (analysis), Budgets (alerts and actions) and Cost and Usage Reports (detailed data).

Think of a household energy bill. Compute Optimizer is the energy auditor who says the heater is oversized; Trusted Advisor is the checklist that finds a light left on; Cost Explorer shows last year's usage graphs; Budgets is the alarm that rings when the bill passes your limit.

Cost optimisation is also performance optimisation: using the right instance family, storage type and scaling policy often improves both.

Key Concepts

  • Compute Optimizer uses ML on CloudWatch metrics (14 days by default; memory requires the CloudWatch agent) to recommend EC2, ASG, EBS, Lambda, ECS-on-Fargate and RDS configurations (over-provisioned / under-provisioned / optimized).
  • Trusted Advisor checks five categories: cost optimisation, performance, security, fault tolerance, service limits (quotas); full checks need Business, Enterprise On-Ramp or Enterprise Support.
  • Cost Explorer visualises and forecasts costs (up to 12 months of history, with hourly/resource-level options); it can also recommend Savings Plans and Reserved Instances.
  • AWS Budgets: cost, usage, RI/Savings Plans coverage and utilisation budgets with alerts (SNS/email) and budget actions (apply IAM/SCP policy, stop EC2/RDS).
  • Cost allocation tags (user-defined and AWS-generated) must be activated in Billing; use tag policies to standardise.
  • Cost Anomaly Detection uses ML to alert on unusual spend; Cost and Usage Report (CUR/Data Exports) delivers line-item data to S3 for Athena/QuickSight.
  • Purchase models: On-Demand, Savings Plans (Compute/EC2 Instance/SageMaker), Reserved Instances, Spot, Dedicated Hosts; Spot discounts up to ~90% for interruptible workloads.
  • Quick wins: delete unattached EBS volumes and unused Elastic IPs, stop idle instances, move gp2 -> gp3, schedule dev/test shutdown, use S3 lifecycle and Graviton instances.

Detailed Notes

Purchase options

OptionCommitmentFlexibilityTypical savings
On-DemandNoneFullbaseline
Compute Savings Plan1/3 years $/hourAny family, Region, OS; also Fargate, Lambdaup to ~66%
EC2 Instance Savings Plan1/3 yearsOne family in a Regionup to ~72%
Standard Reserved Instance1/3 yearsFixed attributes; sellable on marketplaceup to ~72%
Convertible RI1/3 yearsExchangeableup to ~66%
SpotnoneCan be interrupted (2-minute notice)up to ~90%

Best practice: cover steady baseline with Savings Plans, burst with On-Demand, fault-tolerant work with Spot.

Compute Optimizer

bash
aws compute-optimizer update-enrollment-status --status Active --include-member-accounts
aws compute-optimizer get-ec2-instance-recommendations \
  --query "instanceRecommendations[].[instanceArn,finding,recommendationOptions[0].instanceType]"
aws compute-optimizer get-ebs-volume-recommendations --query "volumeRecommendations[].[volumeArn,finding]"

Install the CloudWatch agent for memory-based recommendations; enable enhanced infrastructure metrics (93 days) for seasonal workloads.

Trusted Advisor highlights

CategoryExample checks
Cost optimisationIdle load balancers, low-utilisation EC2, unassociated Elastic IPs, underutilised EBS
PerformanceHigh-utilisation instances, CloudFront delivery optimisation
SecurityOpen security groups (specific ports), S3 bucket permissions, MFA on root, exposed access keys
Fault toleranceEBS snapshots, RDS Multi-AZ, Route 53 failover, ASG health checks
Service limitsServices near quotas (e.g. EC2 vCPU, VPCs)

Check changes appear as EventBridge events, so you can alert or remediate automatically. Service Quotas lets you view and request increases and set CloudWatch alarms for usage.

Budgets with an automated action

bash
aws budgets create-budget --account-id 111122223333 --budget '{
  "BudgetName":"monthly-dev","BudgetLimit":{"Amount":"500","Unit":"USD"},
  "TimeUnit":"MONTHLY","BudgetType":"COST"}' \
  --notifications-with-subscribers '[{
  "Notification":{"NotificationType":"ACTUAL","ComparisonOperator":"GREATER_THAN","Threshold":80,"ThresholdType":"PERCENTAGE"},
  "Subscribers":[{"SubscriptionType":"EMAIL","Address":"finops@example.com"}]}]'

Budget actions can attach a deny policy or stop instances at 100% when approved.

Cost Explorer queries

bash
aws ce get-cost-and-usage --time-period Start=2025-02-01,End=2025-03-01 --granularity MONTHLY \
  --metrics UnblendedCost --group-by Type=TAG,Key=CostCenter
aws ce get-savings-plans-purchase-recommendation --savings-plans-type COMPUTE_SP \
  --term-in-years ONE_YEAR --payment-option NO_UPFRONT --lookback-period-in-days THIRTY_DAYS

Waste hunting checklist

ResourceAction
Unattached EBS volumes / old snapshotsSnapshot if needed, delete (DLM retention)
Unused Elastic IPs, idle NAT/ELBRelease / delete
Idle or oversized EC2/RDSRight-size or stop; schedule non-prod via Instance Scheduler/Automation
S3 non-current versions, multipart uploadsLifecycle rules
Data transferUse VPC endpoints, CloudFront, same-AZ traffic
Untagged resourcesTag policies + Config required-tags rule

Performance efficiency tie-ins

Use Graviton (up to ~40% better price/performance), gp3, ALB target tracking, CloudFront caching and Lambda power tuning; verify with load tests and CloudWatch before and after changes.### Cost tools, purchasing options and rightsizing

ToolPurpose
Cost ExplorerVisualize and forecast; group by service, account, tag
BudgetsCost, usage, RI/Savings Plans coverage and utilization alerts with actions
Cost Anomaly DetectionML alerts for unusual spend
Cost and Usage ReportMost detailed data to S3 for Athena
Cost allocation tagsMust be activated in Billing before they show; not retroactive
Compute OptimizerRightsizing for EC2, EBS, Lambda, ASG, ECS on Fargate
Trusted AdvisorIdle resources and low utilization checks (full set needs Business/Enterprise support)
PurchasingCommitmentNotes
On-DemandNoneFlexibility
Compute Savings Plans1 or 3 years of $/hourUp to about 66% off, flexible across instance families, Fargate, Lambda
EC2 Instance Savings Plans / Standard RIFamily and RegionDeeper discount, less flexible
SpotNone, can be interrupted with 2-minute noticeUp to 90% off for fault-tolerant work
bash
aws ce get-cost-and-usage --time-period Start=2025-01-01,End=2025-02-01 --granularity MONTHLY --metrics UnblendedCost --group-by Type=TAG,Key=Team
aws budgets create-budget --account-id 111122223333 --budget file://budget.json --notifications-with-subscribers file://notify.json
aws compute-optimizer get-ec2-instance-recommendations

Delete unattached EBS volumes, old snapshots, idle load balancers and unused Elastic IPs, and schedule non-production stop/start with Instance Scheduler or SSM.

Real World Example

Scenario – cutting a 30% overspend. A SaaS company's AWS bill rose 30% in a quarter. Cost Anomaly Detection flagged data-transfer spikes; Cost Explorer grouped by the activated Team tag exposed one team's test environment running 24/7.

Actions: an SSM Automation schedule stops non-prod instances at night, Compute Optimizer downsizes 40 over-provisioned instances (memory data via the CloudWatch agent), gp2 volumes are converted to gp3, and a Compute Savings Plan covers the steady baseline. Budgets now alert teams at 80% and 100% of their monthly allowance.

Architecture Diagram

Cost optimisation feedback loop
Architecture
AWS Cloud
Cost Explorer / CURvisibility
Compute Optimizerrightsize
Trusted Advisorwaste checks
Right-sized fleet+ Savings Plans
Budgets + anomaly alerts
  1. 1Tags and Cost Explorer make spend visible per team and service.
  2. 2Compute Optimizer and Trusted Advisor identify rightsizing and idle resources.
  3. 3You right-size, schedule, tier storage and commit with Savings Plans.
  4. 4Budgets and anomaly detection alert if spend drifts, closing the loop.

Best Practices

  • ✓Activate cost allocation tags and enforce tagging with tag policies and Config rules.
  • ✓Set budgets and anomaly alerts per account/team; use budget actions for non-prod guardrails.
  • ✓Right-size with Compute Optimizer (with CloudWatch agent memory metrics) before buying commitments.
  • ✓Commit Savings Plans for steady-state usage; use Spot for fault-tolerant jobs.
  • ✓Schedule non-production resources off-hours and clean up unattached resources regularly.

Common Interview Questions

Exam Tips

SOA-C03 focus

  • Rightsizing recommendations -> Compute Optimizer; best-practice checks incl. service quotas -> Trusted Advisor.
  • Alert when forecast/actual spend crosses a threshold -> AWS Budgets; unusual spikes -> Cost Anomaly Detection.
  • Tags only appear in cost reports after activation as cost allocation tags.
  • Interruptible, fault-tolerant workloads -> Spot; steady-state -> Savings Plans / RIs.

Chapter quiz

Storage, Database and Cost/Performance Optimization · 10 questions

  1. 1.A reporting database on a 500 GB gp2 EBS volume slows down after sustained heavy I/O and BurstBalance falls to zero. What is the BEST fix with no downtime?

  2. 2.Objects in a versioned S3 bucket appear to have been deleted by a script. How can they be restored most simply?

  3. 3.A serverless application exhausts the maximum connections of an RDS MySQL instance during traffic spikes while CPU remains low. Which solution is MOST appropriate?

  4. 4.Which AWS tool provides recommendations to downsize over-provisioned EC2 instances and uses CloudWatch memory metrics when the agent is installed?

  5. 5.Finance wants spending reports grouped by a Project tag, but the tag does not appear in Cost Explorer even though resources are tagged. What must be done?

  6. 6.An EBS gp2 volume runs out of BurstBalance and IOPS drop. The team wants higher, predictable IOPS at lower cost without detaching the volume. What should they do?

  7. 7.An S3 bucket must automatically move logs to cheaper storage after 30 days, expire them after 365 days and remove incomplete multipart uploads. What should be used?

  8. 8.A reporting workload overloads the primary RDS instance with read queries. Which change reduces primary load with the least application change?

  9. 9.Finance wants to see cost per team, but the Team tag does not appear in Cost Explorer. What is required?

  10. 10.Compute Optimizer reports an instance as over-provisioned with low CPU and memory. The workload is steady and a 3-year plan is acceptable. What is a good sequence?

0 of 10 answered

Finished this lesson?

0 of 46 lessons done · 0% of the course