Skip to content

Asg

Basics

  • ASG use LC & LT to launch instances
  • ASG has minimum, desired & max size values
  • ASG keeps number of running instances equal to desired capacity
  • Scaling policies are used to tune auto scaling based on metrics
  • ASG uses whatever subnets are configured to launch EC2. It tries to level capacity between subnets
  • Scaling can be of types -
  • Manual
  • Scheduled -Time based adjustment based on known loads
  • Dynamic
    • Simple - Use a pair of rules one to provision & one to terminate instances
    • Stepped - Same as simple but bigger increase or decrease based on metric value
    • Target Tracking - Define ideal amount of metric. ASG works on matching this target. Only few metrics can be used for target tracking
  • Cooldown Period - Time ASG should wait before taking next scaling action
  • ASG by default use EC2 status checks to monitor health of an instance. IF an instance fails the status check it is terminated and replaced by a new instance
  • ASG can be configured to use ALB status checks instead of EC2 status checks. This gives richer health checks

Scaling Processes

  • Launch & Terminate processes - If Launch is suspended new instances can't be launched. If terminate process is suspended one can not terminate an instance
  • AddToLoadBalancer - Adds provisioned EC2 to load balancer
  • AlarmNotification - Accept alarms from CW
  • AZRebalance - Distribute instances evenly across AZ
  • HealthCheck - Health checks are on or off
  • ReplaceUnealthy - Whether unhealthy instances will be replaced automatically
  • ScheduledActions - Schedule on or off
  • StandBy - Set an instance to be standby or in service. Any instance in StandBy is not effected by any ASG actions
  • ASG are free
  • More smaller instances should be preferred

Lifecycle Hooks

  • Define custom actions than can occur during transitions in ASG lifecyle
  • Lifecycle hooks pause within the launch or terminate flows till either a confiurable timeout happens. One can either Continue or Abandon after timeout
  • Or you complete your custom action & then resume ASG process to CompleteLifcycleAction
  • Lifecyle Hooks can be integrated with SNS or Event Bridge

Healthchecks

  • Types of Healthchecks - EC2, ELB(can be enabled) & Custom
  • For EC2 status checks, any status other than Running is considered to be UnHealthy
  • ELB - EC2 instance needs to be runnin & passin ELB health check. E.g. specific page loads
  • Custom - Allows external systems to mark an instance healthy or unhealthy
  • Health check grace period is the time delay after which health checks are stared. It is 300s by default