Module 9: Enabling Auto Scale to Handle Spikes and Troughs

Auto Scaling helps you maintain application availability and allows you to scale your Amazon EC2 capacity up or down automatically according to conditions you define such as user-defined policies, schedules, and health checks. You can define which EC2 instance you want to run with the help of auto scaling and it will ensure you that you running your desire instances.

Auto Scaling can also automatically increase the number of Amazon EC2 instances during demand spikes to maintain performance and decrease capacity during lulls to reduce costs. Auto Scaling is well suited both to applications that have stable demand patterns or that experience hourly, daily, or weekly variability in usage.

Features and Benefits

  • Maintain your Amazon EC2 instance availability and Automated Provisioning
  • Adjustable Capacity and Automatically Scale Your Amazon EC2 Fleet
  • Reusable Instance Templates                           (Source: https://aws.amazon.com/autoscaling/)

Task list for the module 9:  

  • To enable Auto Scaling Group 
  • To Create launch configuration for Auto Scaling
  • To Create Auto Scaling group
  • To check and monitor  the auto scaling on dinostore website page
  • To check the auto scale testing by terminate instances

The architecture of the project: diagram1 (1).png

Steps for the task: To enable Auto Scaling Group 

In this task, I will demonstrate how to create auto scaling group and its configuration. You can use Auto Scaling to manage Amazon EC2 capacity automatically, maintain the right number of instances for your application, operate a healthy group of instances, and scale it according to your needs.

  1.  You need to go AWS EC2 dashboard from services menu in the AWS console management.  Choose ‘Auto Scaling Group’ from Auto Scaling. 1.jpg

Click “Create Auto Scaling Group“:  Step 1: Create launch configuration and Step 2: Create Auto Scaling group.

Steps for the task:  Create launch configuration

An AMI is a template that contains the software configuration (operating system, application server, and applications) required to launch your instance. So whenever your system needs Auto scaling, it will directly fetch the AMIs that you will mention here for creating the new instance.

  1. In this section, You have to choose “My AMIs”. I am going to choose “My AMIs” which I created during module 6 deployment. 2.jpg 2. Choose your “DinoStoreWebServer” AMI. and click on “Select” for further configuration. 3.jpg

3. In the configure details page, Type the name of Auto Scale “Scale-Web” and Choose IAM role that we created before “WebServerRole“. On the Add storage page, keep the storage configuration default as it is!5.jpg6.jpg

4. Click “Next: Configure Security Group“. Select an existing security group = WebRDPGroup. Then Click “Review“.7.jpg8.jpg

5. Click “Create launch configuration” and select your an existing key pair or you can create a new key pair. In this case, I chose my existing key pair.9.jpg

Steps for the task: Create Auto Scaling group

In this section, I will create Auto Scaling group. An Auto Scaling group is a collection of EC2 instances and the core of the Auto Scaling service. You create an Auto Scaling group by specifying the launch configuration you want to use for launching the instances and the number of instances your group must maintain at all times. You can also mention that which Availability Zone you want to launch your instances.You can also specify the Availability Zone in which you want the instances to be launched.

  1. click Name the Auto Scaling Group name and your network details. Initially, we start with 2 instance group size.

14.jpg

2. Keep the group at its initial size. Note that you can use scaling policies if you had criteria to scale up or down beyond the two instances we have. 15.jpg16.jpg

3. Review and click ” Create Auto Scaling Group17.jpg20.jpg21.jpg

4.  Now you need to back in your AWS EC2 dashboard, check out that newly created Auto-scaling information to watch the instances launch. Those two “ASG-WebServer” are an auto-scaling group.22.jpg

5. Now you need to check your Load Balancer. You will get there four instances, previously there were two instances registered.  Now You can see four instances are registered under the Load balancer. All are up and running and status is “InService“.23.jpg

Steps for the task: To check and monitor the auto scaling on dinostore website page

In this section, you will monitor the auto scaling effect on the dinostore website pages. You will refresh the page again and again so that you will able to see four different private IP address and website is still running.

  1. Open up your local browser with Dinostore website. Replace the URL with the Load balancer URL. Keep refreshing the page. And see the effect of auto scaling.

24.jpg25

26.jpg

27.jpg

Steps for the task: To check the auto scale testing by terminate instances

In this section, I will terminate my two original servers including WebServer and Webserver 02 (Real-only). Those servers are not in the auto-scaling group. After terminating the server, I will check whether the website is running or not!

  1. In the AWS EC2 Instances window, terminate the WebServer and Webserver0228.jpg29.jpg

The result of Servers termination:

After terminating two original servers including WebServer and WebServer02, You will notice only two Private IP address are showing while refreshing pages. 30.jpg31.jpg

2. Now we will test the auto scaling, terminate one of the auto-scale instances and watch what happens in both the EC2 instances window and the auto scaling groups window. You will notice that one instance will be created automatically after deleting one auto-scale group server.32.jpg

The result of Auto Scale Instance termination:

You can only see one IP address after refreshing your website again and again.33.jpg

And One Auto-Scale instance is automatically initiated to create.34.jpg

After creating new automatic auto scaling instance. If you refresh your website, You will able to see two private IP addresses at this time. 36.jpg37.jpg

If you check Load balancer console, you will notice that there is now another new instance is automatically registered with the status “InService35.jpg

Auto Scaling will help you to reduce the load during the rush time of your business website, Your customers will be experiences better availability services.Auto Scaling can dynamically increase and decrease capacity as needed. As you pay for the EC2 instances you use, you save money by launching instances when they are actually needed and terminating them when they aren’t needed.

It also provides you better fault tolerance, because Auto Scaling can detect when an instance is unhealthy, terminate it, and launch an instance to replace it automatically.  The another benefit is that If one Availability Zone becomes unavailable, Auto Scaling can launch instances in another one to compensate.

Screencast link : https://www.youtube.com/watch?v=AkIOG5iK5ME 

The next Module I will discuss “ Configuring DNS with Route 53”

Enjoy your shopping 24/7 Service on Wildlife Dino-Store website! 

Thank you 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s