Auto Scaling

Termination policy

Scaling policy

Simple scaling policy

  • Simple & straight forward scaling policy, when a threshold meet -> adding or removing a specified number of instances.

Target tracking policy

  • Create it own Cloudwatch alarms.

  • There's no need for a cooldown period like in Simple Scaling Policies because the policy continuously tracks the metric and adjusts the capacity to maintain the target level.

  • Ex: Target value of CPU utilization is 50% -> it will create 2 alarms (1 for 50%, 1 for 35%). When the 35% reach, it will scale to maintain the CPU utilization at 50%.

Options

ELB Health check

Be careful with this option.

You need to add the instance to Target group first, before enable this option. If not your instance will automatically terminated if that do not have Scale-in protection turn on.

  • If will check all the instance (health check) in the Target group, if 1 instance fail the Health check -> replace that instance. If it keep replacing the instance, then something is wrong with the Health check.

  • If there are multiple Target group attached to the ASG, all the instance in each Target group need to be healthy.

Scale-in protection

Turn this on if you want to protect a specific instance. There is an Instance scale-in protection, so do not mistaken with that.

This will not protect the instance from manual operation.

When you stop the instance, the ASG will consider the instance is not healthy and replace it. It will terminate it even though you Enable the Terminate protection for that instance.

Instance scale-in protection

If protect from scale in is enabled, newly launched instances will be protected from scale in by default. This will protect the instance from the launch.

This will prevent the ASG from scale-in, so turn it ON only when you understand the down fall of this.

Standby Instance

  • This option will remove the instance from the management of ASG.

  • ASG will not check the health of standby instances until it return to InService

  • When a terminated instance is changed from StandBy to InService, it first checks the health of that instance

    • Healthy -> InService

    • Unhealthy -> remove & create a new instance from the Launch Template.

The ASG will not check the Health of Standby instances. So even you manually terminate the instance outside of ASG, the ASG will not know so the Standby instance is always healthy.

-> You need to check the EC2 instance information to determine healthy or not.

Lifecycle

Lifecycle Transition

When instances launch or terminate, they transition between different states.

  • Launch states: Pending => Pending:Wait => InService

  • Terminate states: InService => Terminating:Wait => Terminated

Lifecycle hooks

Lifecycle hooks in AWS Auto Scaling provide a powerful mechanism to execute custom actions on instances during launch or termination events.

Heartbeat timeout

  • The amount of time, in seconds, for the instances to remain in wait state.

  • Min: 30sec, max: 2H

Trivia

  • ASG scale between Min instance and Max instance. The number of instance depend on Desired instances.

Last updated