What Is AWS Load Balancer And How It Works

Hassanfahad
4 min readMay 25, 2024

Heard the “Load Balancer” or “Elastic Load Balancer” term so much in the world of cloud computing in articles, tutorials, and interviews and are still confused about how it works?

So, congratulations! you are at the right place. Because, in this article, we will cover the following points:

  • What is a “Load Balancing” And “Load Balancer”
  • How a “Load Balancer” works
  • Difference between “Load Balancer” & “Elastic Load Balancer”
  • Why use an “Elastic Load Balancer”
  • Different kinds of Load Balancer in AWS

Load Balancing:

Let's understand the concept of “Load Balancing” with some real-world examples. Let's assume, you have a call center that receives thousands of calls regularly each day each hour, and every minute with only 1 junior call center agent. Now, if you want to scale up and increase the potential of receiving more calls in your call center what will you do? Probably you will hire more call center agents. So by hiring more agents, you are distributing or balancing your incoming call load to multiple agents to entertain more customers/calls.

So, in software development, load balancing means you are distributing your load across different machines/servers to increase the performance of your application

Load Balancer:

Now we understand the concept of load balancer, so who will perform this load balancing function? That’s called a “Load Balancer”. It’s a managed server that intelligently redirects the incoming requests to the underlying servers/machines or ec2 instances. Still didn’t get the full idea? Don’t worry, we will cover how it works later in the article with some visuals.

How does a “Load Balancer” work?

Consider a traditional application architecture where users send requests for information, which are then processed by a single server(e.g. ec2 instance). The server handles these requests and responds with the required data. In this conventional setup, all incoming requests, even if they amount to 1,000 per second, are directed to the same server. As the volume of requests increases, this single-server model experiences significant performance degradation due to the heavy load, leading to slower response times and potential system failures.

Now, let’s consider a scenario where the load increases to 1,000 requests per second, which is an overwhelming amount for a single server to manage. By introducing an AWS Load Balancer and adding additional EC2 instances to the architecture, we can effectively handle this increased load and enhance performance. In this case, we incorporate a load balancer and add two more EC2 instances, resulting in three instances. These instances are connected to the load balancer, which provides a DNS name, such as http://my-alb2234.amazonaws.com. After implementing these changes in the cloud infrastructure, all incoming requests are directed to the load balancer’s DNS name. The load balancer then distributes the incoming requests across the three EC2 instances based on various algorithms. This ensures that as the number of requests increases, the load is efficiently managed by the three EC2 instances, thereby preventing performance degradation.

You might be thinking of what if one of the instances got any failure or malfunction. You are thinking correctly. So, in these kinds of scenarios load balancer comes into play and will automatically stop redirecting the incoming requests to the failed ec2 instance until it again gets back to its normal or active state.

Difference Between “Load Balancer” & “Elastic Load Balancer”:

A load balancer and an elastic load balancer serve similar purposes, but they have key differences. A standard load balancer is static, meaning it cannot automatically scale out or scale in. With a traditional load balancer, the number of EC2 instances remains constant, regardless of fluctuations in traffic. This means you are limited to the initial configuration, whether the demand increases or decreases.

In contrast, an elastic load balancer is designed with scalability in mind. It can automatically adjust the number of EC2 instances based on the specified configuration. When setting up an elastic load balancer, you define the minimum and maximum limits for the number of EC2 instances. This allows the load balancer to dynamically respond to changes in traffic, adding or removing instances as needed. Additionally, various scaling strategies can be applied to an elastic load balancer to suit specific use cases, ensuring optimal performance and cost efficiency.

Why Use A “Elastic Load Balancer”:

  • Provides the scalability to your application with growing traffic
  • Help to handle the server/ec2 instance failures even without knowing the end users.
  • Provide a cost-effective model at the same time along with scalability. No upfront or fixed costs are associated with your scalability.

Different Types Of Load Balancer In AWS:

  1. Application Load Balancer(ALB):
  • Supports HTTP / HTTPS / gRPC protocols
  • Provides HTTP routing features
  • Provides static DNS

2. Network Load Balancer(NLB):

  • Supports UDP / TCP protocols
  • Provide high performance with millions of requests per second
  • Provide static IP via Elastic IP

3. Gateway Load Balancer(GLB):

  • Supports GENEVE protocol on IP Packets
  • Route traffic to Firewall that you manage on EC2 instances
  • Helpful for intrusion detection

--

--