Shrestha Rajat

Search

Search IconIcon to open search

Last updated Jul 9, 2023 Edit Source

# Auto Scaling Group (ASG)

#aws #cloud #compute

A service from AWS to spin up EC2 instances as well as remove them automatically according to the situation.

For example the ASG can be hooked up to an Cloudwatch-Alarms when the EC2 instance status check fails. Then CloudWatch then notifies the ASG which spins up a new instance.

# Scaling Processes

Launch – Adds a new EC2 instance to an Auto Scaling group • Terminate – Removes an EC2 instance from the group • AddToLoadBalancer – Adds instances to an attached ELB or TG • AlarmNotification – Accepts notifications from CloudWatch alarms that are associated with the group’s scaling policies • AZRebalance – Balances the number of EC2 instances in the group evenly across all of the specified Availability Zones • HealthCheck – Checks the health of the instances and marks an instance as unhealthy if Amazon EC2 or Elastic Load Balancing tells Amazon EC2 Auto Scaling that the instance is unhealthy • ReplaceUnhealthy – Terminates instances that are marked as unhealthy and then creates new instances to replace them • ScheduledActions – Performs scheduled scaling actions • Cooldowns – Used with simple scaling policy to prevent Auto Scaling from launching or terminating before effects of previous activities are visible. Default value is 300 seconds (5 minutes) • Termination Policy – Controls which instances to terminate first when a scale-in event occurs. • Termination Protection – Prevents Auto Scaling from terminating protected instances • Standby State – Used to put an instance in the InService state into the Standby state, update or troubleshoot the instance • Lifecycle Hooks – Used to perform custom actions by pausing instances as the ASG launches or terminates them.

# Dynamic Scaling

The ASG could be programmed to be certain metrics, or some conditions.

# Target Tracking

This method will use certain metrics to apply ASG actions. There are 4 metrics which are: • ASGAverageCPUUtilization—Average CPU utilization of the Auto Scaling group • ASGAverageNetworkIn—Average number of bytes received on all network interfaces by the Auto Scaling group • ASGAverageNetworkOut—Average number of bytes sent out on all network interfaces by the Auto Scaling group • ALBRequestCountPerTarget—Number of requests completed per target in an Application Load Balancer target group

# Target Tracking with SQS

You can use SQS to emit a custom metric to cloudwatch to scale the asg ie. to provision more instances according to the pending messages.

# Simple scaling

It scales according to the trigger if the alarm goes off after a simple metric set.

# Step Scaling

Will scale instances with variable alarm trigger, ie. will launch more instance if the metric is higher. Ie the size of alarm breach.

# Scheduled Scaling

We can also use scheduled scaling to roll out or roll down instances in certain times.