Lab 9: Enabling Auto Scale to Handle Spikes and Troughs

Lab 9: Enabling Auto Scale to Handle Spikes and Troughs

In the Lab 9 I am going to add a Auto Scale group to main web server.

What is Auto Scale?
“Auto Scaling helps you ensure that you have the correct number of Amazon EC2 instances available to handle the load for your application. You create collections of EC2 instances, called Auto Scaling groups. You can specify the minimum number of instances in each Auto Scaling group, and Auto Scaling ensures that your group never goes below this size. You can specify the maximum number of instances in each Auto Scaling group, and Auto Scaling ensures that your group never goes above this size” (Source: AWS, http://docs.aws.amazon.com/autoscaling/latest/userguide/WhatIsAutoScaling.html)

First we have to create a group. 
In the EC2 dashboard, left pane click Auto Scale configuration
Then Click Create Auto Scaling group

Screen Shot 2017-10-20 at 8.11.58 PM

Click Create Launch configuration 

Screen Shot 2017-10-20 at 8.12.56 PM

Then you will get the window to select AMIs. Select the web server from my AMIs. 

Screen Shot 2017-10-20 at 8.13.14 PM

Select t2.micro (free tier)
Click Next

Screen Shot 2017-10-20 at 8.14.09 PM

In the configurations. 
Name : scale-web
IAM role:WebServerRole

Click Next

Screen Shot 2017-10-20 at 8.14.47 PM

Keep the default storage as we always used. 
Click Next

Screen Shot 2017-10-20 at 8.14.54 PM

In the security group. Select existing one and choose WebRDPGroup

Screen Shot 2017-10-20 at 8.15.08 PM

Review the details and click Create launch configuration 

Screen Shot 2017-10-20 at 8.15.44 PM

After that it will take you to another step for creating auto scaling group. 
Group Name: scale-web-asg
Subnets : All the subnets 

Screen Shot 2017-10-20 at 8.17.22 PM

In the advanced settings 
Select receive traffic from one or more load balancers
Target Group – Webapp 
Health check type – ELB 
Click Next

Screen Shot 2017-10-20 at 8.25.30 PM

Select, keep this group at its initial size. Because for I don’t need any lower or higher size of my web server. 
Click Next

Screen Shot 2017-10-20 at 8.25.51 PM

Review and select Create

Screen Shot 2017-10-20 at 8.26.47 PM

In the EC2 instances area you can see now new instances been created. That is my auto scaling instance. 

Screen Shot 2017-10-20 at 8.28.40 PM

I am going to keep all other instances off and trying to log into my website. Yes I can. 
My server IP is – 172.31.0.192

Screen Shot 2017-10-20 at 8.30.47 PM

Lets refresh the page after switching on my other servers. 
Now IP is 172.31.26.185

Screen Shot 2017-10-20 at 8.33.27 PM

Again refreshed, Now IP is 172.31.26.185

Screen Shot 2017-10-20 at 8.33.46 PM

I am going to stop the main server and trying now. 

Screen Shot 2017-10-20 at 8.38.47 PM

Now my IP is 172.31.0.192
That is my auto scale group instance. 

Screen Shot 2017-10-20 at 8.40.32 PM

This end of the Lab 9. 

If you want to stop the auto scaling, then detach the instance from the auto scaling group. Otherwise whenever you turning of the main server, it will create a copy of it. 

Note: Do not try to access the website and process a payment when auto scaling instances are running as well with main web server. 
When the main web server also running and when auto scaling instance running at same time then when you are trying to access the website or processing the payment it will make a conflict because main server also running and same time copy of the main server is running that auto scaling instance. 
Make sure to turn of the auto scaling instance. 

Leave a comment