3.2.1.1. Compute Cost Optimization (Right-sizing, RI, Savings Plans, Spot Instances)
š” First Principle: Maximizing compute cost efficiency requires dynamically matching capacity to actual workload demand and leveraging flexible pricing models to pay only for what is needed.
Scenario: A company runs a batch processing application that can be interrupted and restarted without data loss. They also have a core web application with a stable, predictable baseline load that runs 24/7. The architect needs to minimize compute costs for both workloads.
Compute often represents the largest portion of cloud spend. Effective optimization is crucial.
Right-Sizing
: Continuously evaluating compute instance sizes to ensure they are appropriately matched to workload requirements. Avoiding over-provisioning (paying for unused capacity) or under-provisioning (leading to performance issues).- Practical Relevance: Use
"Amazon CloudWatch metrics"
(CPU, memory, network) and "AWS Compute Optimizer recommendations".
- Practical Relevance: Use
- "Reserved Instances (RIs)": A purchasing option that provides a discounted hourly rate for specific
"EC2 instances"
in exchange for a 1- or 3-year commitment.- Practical Relevance: Ideal for steady-state, predictable workloads. Can be "Convertible" (flexible instance family/OS) or "Standard" (fixed).
- "Savings Plans": A flexible pricing model that offers significant discounts on compute usage in exchange for a 1- or 3-year commitment to a consistent amount of compute usage, measured in $/hour.
- Practical Relevance: Provides more flexibility than
"RIs"
, automatically applying discounts across instance families, regions, and even services. Ideal for reducing overall compute spend.
- Practical Relevance: Provides more flexibility than
- "Spot Instances": A purchasing option that leverages unused
"EC2"
capacity. Offer up to 90% discount compared to"On-Demand"
prices.- Practical Relevance: Ideal for fault-tolerant, flexible, and interruption-tolerant workloads (e.g., batch jobs, testing, stateless microservices). Instances can be interrupted with a 2-minute warning.
- Managed Services/Serverless: (Covered in 3.2.1.4) Often more cost-efficient for highly variable workloads due to pay-per-use models.
Visual: Compute Cost Optimization Strategies
Loading diagram...
ā ļø Common Pitfall: Buying "Reserved Instances"
for workloads with unpredictable or fluctuating usage patterns. This leads to paying for capacity that isn't used. "Savings Plans"
or "On-Demand"
with "Auto Scaling"
are better for such workloads.
Key Trade-Offs:
- Flexibility vs. Discount:
"Standard RIs"
offer the highest discount but are the least flexible (locked to an instance family)."Savings Plans"
offer slightly lower discounts but are much more flexible, applying across instance families, regions, and even services.
Reflection Question: How would you apply different "EC2"
purchasing options (e.g., "Spot Instances"
, "Reserved Instances"
, "Savings Plans"
) to optimize costs for both a fault-tolerant, interruptible batch workload and a stable, predictable 24/7 web application? Explain the rationale for each choice based on workload characteristics.