AWS – Auto Scaling

Auto Scaling helps you to maintain application availability and allows you to scale your Amazon EC2 capacity up or down automatically according to condition to define

Steps to create an Auto Scaling

  1. Create an Auto Scaling Group
  2. Configure your Auto Scaling Group
  3. Add an Elastic Load Balancer ( Optional)
  4. Configure Scaling Policies

Auto-scaling improves availability and will keep your infrastructure at the size needed to run your application.

Auto Scaling Components 

Groups 

Launch Configuration 

Your Group uses a lunch configuration as a template for its EC2 instances . When you create a lunch configuration, you can specify information such as :

  • AMI ID
  • instance type
  • key pair
  • security groups
  • block device mapping for your instance

When you create an Auto Scaling Group, you must specify the lunch configuration . You can specify your lunch configuration with multiple Auto Scaling Groups

You can’t modify a lunch configuration after you’ve created it 

Scaling Plans 

A scaling plan tells Auto Scaling when and how to scale . For example, you can base a scaling plan on the occurrence of specific conditions ( dynamic scaling ) or an a schedule.

 

 

Attach EC2 Instances to Your Auto Scaling Group

Auto Scaling provides you with an option to Enable Auto Scaling Group for one or more EC2 Instances by attaching them to your existing Auto Scaling Group. After the instances are attached they become part of Auto Scaling group

The instance that you want attach must meet the following criteria

  • the instance is in the running state
  • The AMI used the lunch instance must still exist
  • The instance is not a member of Auto Scaling group
  • The instance is in a same Availability Zone as the Auto Scaling Group
  • If the Auto Scaling Group has an attached load balancer, the instance and the load balancer must both be in EC2- Classic or the same VPC

 

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

Adding lifecycle hooks to Auto Scaling group gives you a grater control over how instance launch and terminate . Here is some things to consider when adding a lifecycle hook to your Auto Scaling, to help ensure that group continues to perform as expected.

considerations :

  • keep instance in a wait state
  • cooldowns and custom actions
  • health check grace period
  • Lifecycle Action Result
  • Spot Instances

When we create an Auto Scaling group, we must specify a launch configuration, and we can only specify one for an auto scaling group at a time.

you can only specify one launch configuration for an Auto Scaling group at a time, and you can’t modify a launch configuration after you’ve created it

Leave a comment