Auto Scaling Group

What is an Auto Scaling Group (ASG)?

Auto scaling groups are a logical group of related resources that work together. These resources can be EC2 Instances/Spot Fleets, ECS Tasks, DynamoDB and Aurora (replicas). It is a way of monitoring your deployed application and adding steady, predictable performance. It ensures that services always have the correct resource to operate.

AWS Auto Scaling Notes:

  • Works for EC2, ECS, DynamoDB and Aurora.
  • Uses CloudWatch for metrics.
  • Scaled in and out not up and down.
  • Autoscaling responds to status check and CloudWatch Metrics.
  • Scales based on performance or schedule.
  • Scaling policies are used to define how to respond to change in demand.
  • Scaling groups define a collection of resources that are similar.
  • No additional cost to ASG but resources created incur normal cost.
https://docs.aws.amazon.com/autoscaling/ec2/userguide/what-is-amazon-ec2-auto-scaling.html

 

ASG Health Checks:

  • Continuous monitoring of compute in a ASG.
  • All instances assume to be healthy unless ASG is told otherwise.
  • Sources such as EC2 (Launch checks), ELB, VPC Lattice and custom health checks can notify ASGs of unhealthy instances.
  • Unhealthy instances are terminated and relaunched to meet desired capacity of group.
  • New instances are launched with the associated launch template/config of ASG.
  • Grace period should be set to allow time for compute to become active.

Types of Autoscaling:

  1. Dynamic: Scales based on demand.
  2. Predictive: Uses ML to make a prediction.
  3. Scheduled: Scales based on a defined schedule.

Autoscaling Policies:

  • Target Tracking scaling: Changes capacity of group based on CloudWatch Metric. Example: Want CPU to stay at 50%.
  • Step Scaling: Changes capacity of group based on 'step adjustments' which vary based on size of CloudWatch Alarms breach.
  • Simple Scaling: Changes capacity of group based on single adjustment with a grace period based on CloudWatch Alarms. Older and shouldnt be used as much.

Additional Scaling Settings:

  • Termination Policy: Controls which instances to terminate first.
  • Termination Protection: Ensure instance isnt terminated.
  • Standby State: Puts instance in standby for update/troubleshooting.
  • Lifecycle Hooks: Performs custom actions before ASG launches or terminates (Scripts/process data).

Key Configuration Component Summary:

  • Create compute launch template.
  • Configure the compute purchase option (On-Demand/Spot?)
  • Configure the VPC and Subnets
  • Attach the Load Balancer.
  • Configure Health Checks
  • Configure the group size and scaling.