Auto Scaling in AWS helps in maintaining the availability of application and, therefore, allow users to scale up or scale down the capacity of Amazon EC2 according to the conditions defined by the user. Auto Scaling ensures that you have the correct number of EC2 instances available to handle the load of your application. The collection of EC2 instances is called Auto Scaling Groups. Users can specify a minimum number of instances in each Auto Scaling group and the process of AWS Auto Scaling ensures that the group you created never goes below the size.
- Scaling process automatically increases the number of Amazon Elastic Computing Cloud instances during demand spikes which improve the performance and decreases the capacity during intervals which eventually reduces the costs.
- The process is very well-suited both for applications which have stable demand patterns and ones which experience variability in usage as well.
- By specifying scaling policies, based on your increase and decrease of demand you can launch or terminate instances.
- Auto Scaling is one great way of maximizing the benefits of AWS cloud.
- It ensures better fault tolerance where it can detect some unhealthy instance, terminate it and launch an instance to replace it.
- Establishes that your application has always the right amount of capacity for handling the current traffic demands.
- Users pay for the EC2 instances you use, hence, you save money by launching the instances when they are actually needed and terminating when they are no longer needed. Efficiency? Yes. Speed? Yes.
Step 1: Creating a Launch Configuration
Auto Scaling creates EC2 instance which is specified by the launch configuration. This launch configuration comprises of all information regarding EC2 instance. Your Launch Configuration requires pieces of information like:
1. Instance Type,
2. Security Groups,
3. Key Pairs
4. Besides many other configuration settings.
Steps in Launch Configuration
1. By opening the navigation pane in Amazon EC2 console under Auto Scaling, click Launch Configurations.
2. Click on Create Auto Scaling Group page on Welcome to Auto Scaling page.
3. Click on Create Launch Configuration on Create Auto Scaling Group page.
4. You should then Choose AMI which is Amazon Machine Images. This page displays a list of basic configurations. These basic configurations serve as templates for your instance.
5. Choose 64-bit Amazon Linux AMI from this page.
6. Select hardware configuration for your instance from Choose Instance Type page. You must use t2.micro instance which is selected by default.
7. Click next on Configure details.
8. Perform the following instruction on Configure Details page: do the following:
- a. Enter name of your launch configuration in the Name field.
- b. You can select an IP address type under Advanced Details.
- c. If you are not sure if you have a default VPC (Virtual Private Cloud) which you want to connect to your instance, you can select Assign a public IP address to every instance.
- d. Now you can click on Skip to review.
9. Click Edit security Groups on the Review page. To choose the existing security group follow the instructions and then click Review.
10. Click Create Launch Configuration on the Review page.
11. Select one option from the options listed from Select an existing key pair or create a new key pair dialog box.
12. Click Create launch configuration to create your launch configuration.
Step 2: Creating an AWS Auto Scaling Group
Auto Scaling groups are collection of EC2 instances and they are the essence of AWS Auto Scaling service. Creation of Auto Scaling group can be done by specifying the launch configuration. You even have a choice of specifying your Availability Zone.
How To create an Auto Scaling group?
1. Follow below-mentioned instructions on Configure Auto Scaling group details page:
- a. Enter name of your Auto Scaling group in Group name.
- b. Select VPC in Network, if you are launching a t2.micro instance. If launching type does not require a VPC and account supports EC-2 Classic, you can select either Launch into VPC or EC2-Classic.
- c. Selected Subnet if you chose a VPC in the previous step and if you selected EC2-Classic, select an Availability Zone from Availability Zone(s).
*Adding Load Balancer
- d. Next click on Configure scaling policies.
2. Select Keep this group at its initial size from Configure scaling policies page.
3. Click on Review.
4. Click on Create Auto Scaling group on the Review page.
5. Tap on Close, on the Auto Scaling group creation status page.
*Adding Load Balancer
1. On the Details tab, click on Edit.
2. From Load Balancers select Load Balancer.
3. Then click on Save.
When you no longer need the load balancer, you can even detach the load balancer from Auto Scaling group.
Now when you are ready with your Auto Scaling group, you must now verify that the group has launched your EC2 instance.
Step 3: Verifying Your AWS Auto Scaling Group
Know how to verify that your Auto Scaling group has launched your EC2 instance:
1. Select the Auto scaling group that you just created from the Auto Scaling Groups page.
2. To know about all information from Auto Scaling group, click on Details tab.
3. Now choose the Scaling History option. The Status column displays the current status of the instance. The column shows In Progress status when your instance is launching status. The status changes to Successful once the instance is launched. Keep refreshing the page to see the current status of your instance.
4. Selecting on Instances tab you can know the health status and lifecycle of your instance. The Lifecycle column displays the state of newly launched instance. You will see that your EC2 instance is in the InService lifecycle state. In the Health Status column you can see health on your instance.
You have an option of either deleting your AWS Auto Scaling set up or just your AWS Auto Scaling group. Choosing the later one allows you to keep your launch configuration to use at a later time.
Step 4: Deleting Your AWS Auto Scaling Infrastructure (Optional)
You may choose to delete your Auto Scaling set up as a whole or just delete your Auto Scaling group and you may keep your launch configuration for later use.
Steps for deleting your AWS Auto Scaling group
1. By opening the Amazon EC2 console, in the navigation pane, click on Auto scaling Groups which can be found under Auto Scaling.
2. Select Auto Scaling group on the Auto Scaling groups page.
3. To delete click on Delete which can be done by clicking on Actions.
To cross verify that your Auto Scaling group has been deleted or not, you can check the Name column which indicates that the Auto Scaling group has been deleted. The columns Desired, Min, and Max shows 0 instances for the Auto Scaling group.
You can skip the below-mentioned steps if you would like to keep your launch configuration.
To delete your launch configuration
1. Click on Launch Configurations under Auto Scaling in the navigation pane.
2. Select your Launch Configuration from the Launch Configurations page.
3. Select Delete Launch Configuration from Actions option. You may get a prompt ensuring that you really want to delete or not.
AWS Scaling – Stepping Ahead
Amazon Web Services introduced its Auto Scaling feature back in the year 2009 while Microsoft did the same for Azure in the year 2011. But Google announced its Auto Scaling service for Compute Engine, its infrastructure-as-a-service platform, in 2014.
Auto Scaling is a very useful feature for your site or application which can help you design a scalable architecture. A scalable architecture will automatically scale-up and scale-down and, therefore, can meet your need regardless of how slow or fast or large or small your site would scale over time. Some of the popular ways of Auto Scaling is a front-end site traffic scaling where scaling is done based on the number of incoming requests and back-end batch processing which comprises of load based scaling and time-based scaling.
References: Amazon Docs, Amazon, Rightscale Docs, Techcrunch.