Autoscaling Application with AutoScaling Groups and AWS LoadBalancer

In this Blog Post, let us look at how to make your website highly available and scalable using AWS Load Balancer and AutoScaling Groups

Creating AMI:

  1. Launch an instance, Setup your application on it and shut it down.
  2. Go to your AWS EC2 Console. Select your instance and create AMI, by right-click on the selection and choose Image > Create Image.
  3. Wait for it to AMI creation to complete, you can check its status in Image > AMI on the Left Side Menu.
  4. Wait for Status to be Available and then terminate the original instance, if needed.

Create Load Balancer:

  1. Navigate to Load Balancer Section on Left Side Menu and select Create Load Balancer
  2. Choose your Load Balancer Type Appropriately  between Application, Network and Classic Load Balancer.
  3. Configure your Security group and other setting Appropriately and Create  a Target Group (dont choose any instances) and wait for the Load Balancer to Launch.
  4. After Launch, when you visit Load Balancer URL, It should throw an 503 Service not available exception (which is already expected, since we didnt host our website yet)

Now that all is set, Lets setup Auto Scaling and Load Balancing for your Application.

Creating Auto Scaling Group:
    Before we can create a Auto Scaling Group, we need to create a Launch Configuration (you can either use a single AMI to create a Launch Configuration or use Launch Templates.). You can do this by choosing Launch Configuration in AUTO SCALING section on your left-side menu, Click on Create Launch Configuration and choose your previously created AMI, Instance Type and Instance Settings like Security Groups and Storage Settings etc., and complete creation of Launch Configuration

  1. Choose Auto Scaling Groups in “AUTO SCALING” section in left-side menu.
  2. Click on “Create Auto Scaling Group”, Choose use existing Launch Configuration and select the configuration you selected earlier.
  3. Create Auto Scaling Group with your preferred Settings. Making Sure you select “Receive traffic from one or more load balancers” in Advanced Details.
  4. Launch your Auto Scaling Group and wait for instances to Launch
  5. Refresh the Load Balancer URL to see your Application.

Testing Auto Scaling Group:
Based on whether you selected CPU Average or Average Network In/Out or Load Balancer Request Count per target. Create a suitable load and check your AWS EC2 instance count increasing and they being Auto Added to your Load Balance Target Group.

 

Note: If you create a classic Load Balancer, then you will be asked to select the Load Balancer, If you created a Network/Application Load Balancer, you will be asked to choose a Target Group During Creation of Auto Scaling Group.

Posted On 09 February 2019 By MicroPyramid


Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
Creating Elastic Search Cluster (EC2, cloud-aws Plugin)

While handling Large amounts of data with elasticsearch, you may run out of server capacity or compute power, Forming a Elasticsearch cluster will reduce the ...

Continue Reading...
Configuring and Testing Load Balancer in AWS EC2

When You have an application that is serving Huge Customer Base, so will be your Traffic. Sometimes The Application simply stops responding. We can use ...

Continue Reading...
how to setup custom domain for amazon cloudfront

We all want our own domain name to be setup for cloud front instead of amazon default cloud front domain name. We need two things ...

Continue Reading...
open source packages

Subscribe To our news letter

Subscribe and Stay Updated about our Webinars, news and articles on Django, Python, Machine Learning, Amazon Web Services, DevOps, Salesforce, ReactJS, AngularJS, React Native.
* We don't provide your email contact details to any third parties