AWS Auto-Scaling Deep Dive — Advance Concepts

Gaurav Gupta
4 min readFeb 20, 2020

--

ASG Creation-

From Launch Configuration: Same as we create EC2 Instance & some other options to define about ASG.
From Launch Templates: Already saved config that can be reused to launch.

ASG Creation

I’ll discuss below options of ASG.

Schedule Actions:

Launch ASG according to schedule time i.e according to your business time, you can schedule to scale.

Scaling Policies

Simple Scaling Policy: Simple scaling policies must wait for the cooldown period to expire after a scaling activity or health check replacement before they can respond to alarms that are breached

Scaling Policy with Steps: Scaling policies with steps continuously evaluate alarms as they are breached, even while a scaling activity or health check replacement is in progress.(Eg: If CPU > 70 %, add “X” no. of Instances)

Cooldown period: Number of seconds after a scaling activity completes before another can begin.

NOTE: By default, “Target Tracking Scaling Policy” is set in scaling policies option. We can change it two above discussed two options.

IMPORTANT POINT: Once you change the Target group in ASG, if any new instance launches from ASG then it will become part of ALB if you already attached ALB to ASG.

Suspended Process: (In details Tab)

If Suspended Process — Launch (No New Instance will be launched if we change)

If Suspended Process — Terminate (No Instance will be Terminated)

If Suspended Process — Health Check (No Health Check will performed)

Lifecycle State of Instance:

ASG — Instances — Actions

Detach — New Instance will be replaced.

set to Standby — No Traffic to that Instance

Instance Protection — Scale In — No Instance removal if we try to remove.

Lifecycle Hooks:

Auto Scaling lifecycle hooks enable you to perform custom actions as Auto Scaling launches or terminates instances. For example, you could install or configure software on newly launched instances, or download log files from an instance before it terminates.

There is a script you need to run to make instance in service otherwise it will be in pending state.

#!/bin/bash

aws autoscaling complete-lifecycle-action — lifecycle-action-result CONTINUE — lifecycle-hook-name LaunchHook — auto-scaling-group-name demo-asg-launch-template — instance-id i-XXXXXXXXXXXX — region eu-west-1 — profile aws

Termination Policies in Details Tab:

If there are 100 Instances attached in a ASG, which instance will be terminate first.

Termination Policies Types:

Default — Read the conditions from doc( https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-instance-termination.html)

ASG Monitoring:

ASG Notifications:

Create a SNS Notification whenever instances launch/terminate/fail to launch/fail to terminate

Activity History:

All activities happen in ASG like instance creation, termination etc.

Thanks for reading, Happy Clouding :)

--

--

Gaurav Gupta
Gaurav Gupta

Responses (1)