Domain 4 · Cost-OptimizedDesign Cost-Optimized Architectures3 min read
Cost-optimized compute
Exam guide task statement 4.2: Design cost-optimized compute solutions.
On this page
Buy steady capacity with commitments, run interruptible work on Spot, right-size everything, pick the compute model that leaves the least idle capacity, and switch off what isn't being used.
Purchasing options
- On-Demand: Pay by the second with no commitment. Short, unpredictable, or brand-new workloads.
- Savings Plans: Commit to a dollar amount of compute per hour for 1 or 3 years. Compute Savings Plans apply across instance families, Regions, Fargate, and Lambda; EC2 Instance Savings Plans give a deeper discount for one instance family in one Region.
- Reserved Instances: A 1- or 3-year commitment to an instance configuration. Standard RIs give the biggest discount; Convertible RIs can be exchanged. Zonal RIs also reserve capacity.
- Spot Instances: Spare capacity at a large discount that AWS can reclaim with a two-minute warning. For fault-tolerant, flexible work: batch, CI, stateless web workers, big data.
- Dedicated Hosts: A physical server for you alone, for licenses tied to sockets or cores (AWS License Manager tracks them) or compliance rules.
- On-Demand Capacity Reservations: Reserve capacity in an AZ with no term commitment; combine with Savings Plans for a discount.
Right-sizing and scaling for cost
- AWS Compute Optimizer: Uses utilization history to recommend smaller or different instance types, EBS volumes, Lambda memory, and ECS task sizes.
- Pick the family by the bottleneck (compute, memory, storage), then the smallest size that meets peak needs with headroom. Graviton instances often cost less for the same work.
- Scale horizontally with Auto Scaling so capacity follows demand, and use scheduled scaling to shrink overnight.
- EC2 hibernation: Saves memory contents to the EBS root volume and stops the instance; you pay only for storage while stopped, and the app resumes warm.
- Mix purchase options in one Auto Scaling group: a baseline of On-Demand covered by Savings Plans plus Spot for the rest, spread across several instance types.
Choosing the compute service
- AWS Lambda: Billed per request and per millisecond, nothing when idle. Cheapest for spiky or intermittent work; Arm (Graviton) functions cost less per GB-second.
- AWS Fargate: Pay for the vCPU and memory of each task with no instances to manage or leave idle. Fargate Spot runs interruptible tasks at a discount.
- Amazon EC2 for containers: Usually cheaper for large, steady container fleets that keep instances busy, especially with Savings Plans or Spot.
- Containers and microservices pack more work onto fewer instances than one-app-per-server designs.
Load balancer choice
- One ALB can route to many services by host and path, so you pay for one load balancer instead of several.
- Choose by layer: ALB (layer 7) for HTTP routing, NLB (layer 4) for TCP and UDP or extreme throughput, Gateway Load Balancer for inspection appliances. Don't pay for features the workload doesn't use.
Availability by workload class
- Production needs multi-AZ capacity and headroom. Development and test usually don't: run them in one AZ, on smaller or Spot instances, and stop them outside working hours.
- AWS Outposts makes sense when workloads must stay on premises for latency or data residency; edge processing (Local Zones, CloudFront Functions) can also cut data that travels back to a Region.
Check yourself
6 practice questions on this topic
Start practice