Today's Offer - AWS Certification Training - Enroll at Flat 10% Off.

- AWS Blogs -

What Should You Know About AWS Elastic Load Balancer?

Amazon Elastic Load Balancer (ELB) allows you to make applications highly available through continuous health checks and even traffic distribution across multiple instances. Take an example that you have a WordPress blog running on a single t2-micro EC2 instance. When you publish this blog, it goes viral and your site gets thousands of requests together. Since you are using a single t2-micro EC2 instance, there are heavy chances that your website will crash.

So, how to manage this condition gracefully?

You may opt for the vertical scaling and launch a large number of instances like m5-large in place of the t2-micro instances. When you replace the t2-micro instance with more powerful ones, things are possible to manage gracefully. Sadly, the vertical scaling is not an economical option.

Another approach is using a bunch of smaller t2-micro instances together and distributes the traffic among them. It can be achieved with the help of Amazon Elastic Load Balancer that distributes incoming network traffic across multiple targets in multiple availability zones. It uses health checks to verify which instance is healthy and able to direct traffic across other instances.

Amazon Elastic Load Balancer Types

There is a total of three types of Elastic Load Balancers, and you can use any one of them that fits your requirements the most.  Amazon Elastic Load Balancer Types

Classic Load Balancer (CLB)

As the name suggests, it was used traditionally for EC2-classic instances. It operates well on both levels either connection level or the request level. But it does not support features like path-based routing or host-based routing. It needs to be configured first. Once configured, it distributes the load among multiple registered instances regardless of what is available on the server currently. In this way, it is used to distribute the traffic to a single URL.

Read: How to Prepare for the AWS Certified Cloud Practitioner Exam?

Application Load Balancer (ALB)

This load balancer is mainly designed for web applications with HTTP and HTTPS traffic. It is a network-based model called the OSI (Open System Interconnection) model that is used to explain the working of computer networks. The OSI model has seven network layers in total and the top layer is Application layer.

The Amazon ELB works at the top layer; hence it is named as the application load balancer (ALB). It provides advanced routing features too like path-based routing and host-based routing. It can work with microservices and containers too. You must be wondering what we meant by the host-based and path-based routing here. Let us discuss the concepts in brief below.

Host-based Routing

Consider you have two websites janbask.com and training.janbask.com. Each website is hosted on two EC2 instances for high availability. The next step is distributing incoming traffic between these two websites. With CLB, you have to create two load balancers, one for each website. But the same thing can be done with a single application load balancer i.e. ALB. In this way, you save time and money by using a single ALB instead of two CLBs.

Path-based Routing

Consider your Company website is janbasktraining.com and blogs page is hosted on janbasktraining.com/blog URL. Now the operation team has to decide either the main website and the blog page should launch on same or different instances. With ALB, you can route the traffic to the requested URL. Again, a single ALB is enough to handle both URLs together at highly manageable costs.

Read: AWS vs. OpenStack vs. SoftLayer - Which One is the Best?

AWS Curriculum

Network Load Balancer (NLB)

This load balancer operates at the network layer of the OSI model, so it is named as the Network Load Balancer (NLB). Consider, your Company website is running on m4-xlarge instances and you are using an application load balancer to manage the traffic among instances.

Your Company launched a new product recently and it got viral and started getting millions of requests every second. Here, ALB is not a suitable choice to manage the sudden spike in traffic. In this condition, NLB shines out of three. It has the capability to manage a sudden spike in traffic since it works at the connection level. It is able to handle static IP addresses too.

I hope you have enough idea now about AWS load balancer key concepts and its different types. Let us go a little practical in the next section.

How to create an Amazon Load Balancer?

We are taking the example of path-based routing here to manage two different paths “/” and “/blog” by creating two EC2 instances to handle each path independently. Let us get started.

Step 1 – Launch two EC2 instances

To know how to launch an EC2 instance, read our blog - https://www.janbasktraining.com/blog/create-amazon-ec2-instance/

Read: AWS & DevOps- The Powerful Tech Trend of 2019

When launching instances given a Name tag to your instance. For the first path, add the tag NAME as the key and MAIN as the value. For the second path, add the tag NAME as the key and BLOG as the value. These values will help you to distinguish quickly between two paths. Once both instances are launched, it should look like this: Launch two EC2 instances

Step 2 – Install Apache server on instances

SSH into the first instance with the “Name MAIN” and run the following commands to install the Apache server on instances successfully. Install Apache server on instances After these steps, add the IP address of the instance in the browser and hit ENTER. The Apache server is installed successfully in the first instance. Now, SSH into the second instance with the “Name BLOG” and run the following commands to install the Apache server on instances successfully. Install Apache server on instances Install Apache server on instances You can see that all commands are the same except for the last one. Now paste the IP address in the browser with the /blog suffix and hit Enter. The Apache server is installed successfully in the second instance.

Step 3 - Generate Target Groups

A target group guides the load balancer which protocol and port will receive the traffic on the registered instances.

  • Open the Amazon dashboard, in the left navigation bar, scroll down and click on “Target Groups”.Generate Target Groups
  • Choose the option “Create Target Group” from the top. Give a Target Group “Name” and click “Create” Button.
  • Now navigate to the “Targets” tab at the bottom, click on “Edit”, select the “Main” instance, click “Add to Registered” and Click “Save”.Generate Target Groups
  • After this, create the second target group with the name Blog and add the blog instance to it as we did above.

Step 4 - Create or configure the ALB

Open the Amazon dashboard, in the left navigation bar, scroll down and click on “Load Balancers”. Click on “Create Load Balancer” button on the top.

  • Choose the Application Load Balancer (ALB) from available options.Create or configure the ALB
  • Give a proper name to the load balancer and add a minimum of two availability zones to increase the availability.
  • In the next step, click “configure security settings” option. You may see a warning message here but it is fine as we are listening to HTTP traffic here. Next, click on “configure security groups” button.Create or configure the ALB
  • Now select the same security group that you assigned to the launched instances earlier. Once done, click on “Configure routing” option.Create or configure the ALB
  • From Target groups, select the existing target group. In the Name, select MAIN and click Next.
  • Click “Next” again, review, and click Create.

Congratulations, you have created an Application Load balancer with these easy steps. But we have to configure Blog instance too, so let us continue. Don’t forget to note down the DNS name here that we need later.

  • Select the “Listeners” tab and click “View/Edit rules”.
  • Click the “+” sign at the top of each rule. From Add condition, select “Path is” and type “/blog”.
  • Now add action, select Blog then click Save
  • After this, we can use the DNS name of the load balancer to visit two different paths and see the final output.Create or configure the ALBCreate or configure the ALB

I hope you learned something meaningful from this blog. Now you can create your own AWS Elastic Load balancer and start using it for your applications. The highlighting features of AWS ELB include high availability, automatics scaling, multiple availability zones, robust security etc that are necessary to make any application fault tolerant.

Read: AWS vs. Heroku vs. Firebase - Which one is the best?

    Janbask Training

    JanBask Training is a leading Global Online Training Provider through Live Sessions. The Live classes provide a blended approach of hands on experience along with theoretical knowledge which is driven by certified professionals.


Trending Courses

AWS

  • AWS & Fundamentals of Linux
  • Amazon Simple Storage Service
  • Elastic Compute Cloud
  • Databases Overview & Amazon Route 53

Upcoming Class

2 days 14 Nov 2019

DevOps

  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing

Upcoming Class

3 days 15 Nov 2019

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning

Upcoming Class

3 days 15 Nov 2019

Hadoop

  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation

Upcoming Class

4 days 16 Nov 2019

Salesforce

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL

Upcoming Class

2 days 14 Nov 2019

QA

  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing

Upcoming Class

-0 day 12 Nov 2019

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum

Upcoming Class

3 days 15 Nov 2019

SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design

Upcoming Class

7 days 19 Nov 2019

Comments

Search Posts

Reset

Receive Latest Materials and Offers on AWS Course

Interviews