19
MarAmazon 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.
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.
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 Change Instance EC2 Type Setting in AWS?
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: How to Create and Activate an AWS Account?
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.
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.
To know how to launch an EC2 instance, read our blog - https://www.janbasktraining.com/blog/create-amazon-ec2-instance/
Read: AWS vs. OpenStack vs. SoftLayer - Which One is the Best?
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:
SSH into the first instance with the “Name MAIN” and run the following commands to install the Apache server on instances successfully. 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.
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.
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 “Load Balancers”. Click on “Create Load Balancer” button on the top.
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.
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: What Is The Average Salary Of AWS Certified Developer?
A dynamic, highly professional, and a global online training course provider committed to propelling the next generation of technology learners with a whole new way of training experience.
AWS
DevOps
Data Science
Hadoop
Salesforce
QA
Business Analyst
MS SQL Server
Python
Artificial Intelligence
Machine Learning
Tableau
Search Posts
Trending Posts
What is SFDC? What does SFDC stand for?
921
What Is The Difference Between Tables And Views In SQL?
573
How to Add A New Column to a Table in SQL?
553
What is the SQL Insert Query? How to Insert (Date, Multiple Rows, and Values in Table)
458
What Is SQL Candidate Key? Difference between Primary Key & Candidate Key
370
Related Posts
Receive Latest Materials and Offers on AWS Course
Interviews