Auto Scaling Components

  • Groups
    • EC2 instances are organized into groups to treat as single unit for scaling and management.
    • Specify minimum, maximum, and, desired EC2 instances during creation.
  • Configuration templates
    • Group needs launch template or configuration as a configuration template for its EC2 instances.
    • Details like AMI ID, instance type, key pair, security groups, and block device mapping are listed
  • Scaling options
    • Provides ways to scale Auto Scaling groups.
  • Like, scaling on a schedule.

Auto Scaling Lifecycle

Scale Out

Scale out events launch EC2 instances and attach them to Auto Scaling group, if

  • manually increase size of group.
  • create a scaling policy to automatically increase group size as per increase in demand.
  • Scheduled scaling to increase group size at specific time.

During scale out event

  • Required EC2 instances are launched
  • using its assigned launch configuration
  • instances start in Pending state
  • perform a custom action by adding lifecycle hook to Auto Scaling group, here
  • instance is attached to group if fully configured and clears EC2 health checks
  • instance enters InService state
  • instance is counted against desired capacity of Auto Scaling group.

Instances In Service

Instances are in InService state if either

  • scale in event occurs, EC2 Auto Scaling terminates this instance to reduce group size.
  • put instance into a Standby state.
  • detach instance from Auto Scaling group.
  • instance fails a required number of health checks, it is removed from group, terminated, and replaced.

Scale In

Scale in events direct group to detach instances and terminate, if

  • manually decrease size of group.
  • create a scaling policy to automatically decrease group size based as per demand.
  • set scaling by schedule to decrease group size at a specific time.
  • create a scale in event for each scale out event created.
  • Hence, resources will match demand

During scale in event

  • Auto Scaling group detaches one or more instances.
  • termination policy is used to find which instances to terminate.
  • Instances to terminate, enter Terminating state, and can’t be put back into service.
  • perform a custom action by adding lifecycle hook to Auto Scaling group, here
  • Finally, instances is completely terminated and enter Terminated state.

Attach an Instance

  • Attach a running EC2 instance as per criteria, to Auto Scaling group.
  • After attaching instance, it is managed as part of Auto Scaling group.

Detach an Instance

  • can detach instance from Auto Scaling group.
  • After detaching, manage it separately from Auto Scaling group or
  • attach it to a different Auto Scaling group.

Lifecycle Hooks

  • add a lifecycle hook to Auto Scaling group to execute custom actions when instances launch or terminate.
  • Can be added in a scale out or scale in event
  • In scale out event,
    • instances start in Pending state
    • If present, EC2_INSTANCE_LAUNCHING lifecycle hook, instance move from Pending state to Pending:Wait state.
    • After lifecycle hook action, instance enter Pending:Proceed state.
    • After full configuration, instances attach to Auto Scaling group and are in InService state.
  • In scale in event
    • instances are detached from Auto Scaling group and are in Terminating state.
    • If present, EC2_INSTANCE_TERMINATING lifecycle hook, instances move from Terminating to Terminating:Wait state.
    • After lifecycle hook action, instance enter Terminating:Proceed state.
    • When instance is fully terminated, they enter Terminated state.

Enter and Exit Standby

  • can put any instance from InService state to Standby state, to remove from service, troubleshoot or make changes to it, and then put it back into service.
  • Instances in Standby state are managed by Auto Scaling group.
  • they are not active part of application until back into service.

Auto Scaling Limits

Default Limits

  • Launch configurations per Region: 200
  • Auto Scaling groups per Region: 200

Auto Scaling Group Limits

  • Scaling policies per Auto Scaling group: 50
  • Scheduled actions per Auto Scaling group: 125
  • Lifecycle hooks per Auto Scaling group: 50
  • SNS topics per Auto Scaling group: 10
  • Classic Load Balancers per Auto Scaling group: 50
  • Target groups per Auto Scaling group: 50

Scaling Policy Limits

  • Step adjustments per scaling policy: 20

Scaling Options

  • Maintain current instance levels at all times
  • Manual scaling – User specify only change in maximum, minimum, or desired capacity of group.
  • Scale based on a schedule – scaling actions are performed automatically as a function of time and date.
  • Scale based on demand – Define parameters to control scaling like CPU utilization %
  • Predictive scaling – EC2 Auto Scaling with AWS Auto Scaling to scale resources across multiple services.
Menu