Design Cost-Optimized Architecture

๐ฏ EC2 Auto Scaling Default Termination Policy Order
๐ When Auto Scaling needs to terminate an instance, it checks in this order:
Spot vs On-Demand
(Terminate Spot first, if mixed.)Oldest Launch Configuration
(Terminate instance using the oldest launch configuration.)Oldest Launch Template
(If no launch configuration, terminate instance with oldest launch template.)Oldest Instance
(By launch time.)Closest to Billing Hour
(If all else is equal.)
๐ง Easy memory trick:
"Spot โ Config โ Template โ Time โ Billing" โ
Just remember:
"SCTTB = Spot, Config, Template, Time, Billing**"
โก Quick Apply to Your Question:
Instance B = Oldest launch configuration โ โ TERMINATE!
Instance A = Oldest launch template (lower priority than config).
Instance C = Newest launch config โ safe.
Instance D = Closest to billing hour โ last check.
โ Therefore, Instance B is the correct answer!
Launch Template and Launch Configuration:
Launch Template: Can mix On-Demand + Spot Instances and multiple instance types. โ
(Best for cost optimization and flexibility.)Launch Configuration: Cannot mix On-Demand + Spot or multiple instance types. โ
(Older, less flexible.)
Quick Tip:
Need mixed instances (On-Demand + Spot)? Only launch templates can do this! Remember:
"Templates are flexible, Configurations are not."
(Other options are wrong because they either overpromise or underdeliver.)
Subscribe to my newsletter
Read articles from Varish Ansari directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Varish Ansari
Varish Ansari
As a DevOps and Cloud Engineer, I design and manage scalable AWS cloud infrastructures, implement Infrastructure as Code using Terraform, and automate CI/CD pipelines with GitHub Actions. I also work with Docker and Docker Swarm and ECS for containerized deployments, optimize cloud security using AWS WAF, Security Hub, and GuardDuty, and enhance monitoring and observability with CloudWatch, Prometheus, and Grafana. My focus is on automation, scalability, and security to ensure efficient and resilient cloud environments