AWS Auto Scaling: Key Concepts
AWS Auto Scaling is a set of AWS capabilities that automatically adjusts compute capacity based on demand. When traffic increases, AWS can add capacity (scale out), and when traffic decreases, it can remove capacity (scale in). This helps applications maintain performance during traffic spikes while avoiding the cost of running unnecessary resources during quiet periods.
For EC2, the main component is an Auto Scaling Group (ASG). The ASG manages a collection of EC2 instances and lets you define a minimum, desired, and maximum number of instances. For example, you might configure Min = 2, Desired = 2, and Max = 6. When a scaling policy detects high demand, the ASG launches additional instances; when demand falls, it can terminate instances. The ASG can also replace unhealthy instances automatically.
When an Application Load Balancer (ALB) is used, the ALB distributes incoming requests across the EC2 instances through a Target Group. The important part is that the Auto Scaling Group can be associated with the Target Group, so newly launched instances are automatically registered with it. The ALB performs health checks, and once a new instance is healthy, it can start receiving traffic. When an instance is removed during scale-in, it is automatically deregistered so the ALB stops sending new traffic to it.
Example
Suppose the application normally runs with two instances:
Target Group
├── EC2 #1
└── EC2 #2
Traffic increases → the scaling policy triggers → the ASG creates EC2 #3:
Target Group
├── EC2 #1
├── EC2 #2
└── EC2 #3 ← automatically registered
The ALB health-checks EC2 #3. Once it is healthy, the ALB can send requests to it.
Simple mental model
- ALB → distributes incoming requests
- Target Group → contains the instances that can receive traffic
- Auto Scaling Group → manages how many EC2 instances exist
- Scaling Policy → decides when to add/remove capacity
- Scale Out → add instances
- Scale In → remove instances
- Health Checks → help ensure only healthy instances receive traffic
Auto Scaling manages how many instances exist.
ALB manages where requests go.
The Target Group connects the two.