1Statelessness is Key
To use ASGs effectively, instances must be stateless. If an ASG terminates an instance during scale-in, any local data on that instance is destroyed. Store session state in ElastiCache or DynamoDB, and files in S3.
2Step-by-Step Breakdown
What is an ASG?. An ASG automatically adjusts the number of EC2 instances to meet application demand.
Launch Templates. Defines the blueprint (AMI, instance type, security group) the ASG uses to launch new instances.
Capacity Settings. You define Desired, Minimum, and Maximum capacity constraints.
Scaling Out vs Scaling In. Scaling out adds instances during traffic spikes. Scaling in terminates instances during lulls to save costs.
Knowledge Check. What blueprint must an ASG use to know which AMI to deploy?
- →VPC Configuration
- →Launch Template
Target Tracking Policies. The simplest scaling policy: you tell ASG 'Keep average CPU at 50%', and it does the math for you.
Integration with ELB. ASGs automatically register new instances with your Load Balancer's Target Group.
Health Checks. If an instance fails the EC2 or ELB health check, the ASG terminates it and launches a fresh replacement.
Cooldown Periods. A cooldown prevents the ASG from launching or terminating additional instances before previous scaling actions take effect.
Summary. ASGs ensure high availability and cost optimization automatically.
