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
Amazon AWS IAM Roles and Policies

When You want to Provide access to Amazon Web Services Console or if you're planning to provide REST API Keys to your Developers of a ...

Continue Reading...
Using AWS Lambda with S3 and DynamoDB

AWS lambda is handy tool for event driven computation, here we will learn how to configure and setup lambda function so to run our function ...

Continue Reading...
How to access EC2 instance even if pem file is lost

Accessing the EC2 instance even if you loose the pem file is rather easy.

1. First, create a new instance by creating new access ...

Continue Reading...

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