Auto Scaling Groups (ASG)

šŸš€ What is an Auto Scaling Group (ASG)?

An Auto Scaling Group in AWS automatically launches or terminates EC2 instances based on demand, health checks, or schedules.

āœ… Its goal is to ensure your application has the right number of instances running at the right time — not too many (wasting money) and not too few (hurting performance).


🧩 Key Features

Feature Description
Automatic Scaling Increases or decreases instance count based on CPU, traffic, etc.
Health Checks Replaces unhealthy instances automatically
Integration with ELB Distributes traffic across ASG-managed instances
Launch Template/Profile Defines the AMI, instance type, key pair, and security group
Availability Zones Distributes instances across multiple AZs for high availability
Scheduled Actions Scale based on time (e.g., increase capacity at 9 AM, reduce at 6 PM)
Lifecycle Hooks Run custom logic during instance launch/termination

āš™ļø How ASG Works (High-Level Flow)

  • You create a Launch Template (defines instance config)
  • You define an Auto Scaling Group (min, max, desired capacity)
  • ASG monitors CloudWatch alarms (CPU, network, etc.)
  • Based on metrics or schedule:
    • Launches new EC2 instances
    • Terminates old or unhealthy ones
  1. If attached to a Load Balancer, traffic is automatically routed


šŸ“ˆ Example Scenario

Time Traffic ASG Response
10:00 AM Low ASG maintains minimum instances
1:00 PM High ASG scales out new instances
10:00 PM Low ASG scales in unused instances

šŸ“¦ ASG + ELB + CloudWatch = Dynamic Scaling

Time Traffic ASG Response
10:00 AM Low ASG maintains minimum instances
1:00 PM High ASG scales out new instances
10:00 PM Low ASG scales in unused instances

šŸ› ļø Scaling Policies

Policy Type Description
Target Tracking Keeps a metric (e.g., CPU at 50%) at target level
Step Scaling Scales based on metric thresholds in steps
Simple Scaling One action per CloudWatch alarm (older method)
Scheduled Scaling Triggers at specific times

āœ… Summary

Attribute Value
Purpose Auto-manage EC2 instance count
Key Components Launch Template, Scaling Policy, Health Check
Use Case Web apps, APIs, batch jobs, cost optimization
Cost Control Helps reduce costs during low traffic
High Availability Distributes across AZs, replaces failed nodes
Back to blog

Leave a comment