
Load Balancer: How It Works and Why It Is Used
Learn what a Load Balancer is, how it distributes traffic between multiple servers, and how it helps improve performance, scalability, and high availability. This article also explains the role of frontend and backend tiers, queues and messaging, along with AWS Load Balancer types such as ALB, NLB, and GWLB in a simple and practical way.
Load Balancer
Introduction
A Load Balancer is a service or device that distributes incoming network traffic across multiple servers. Its main purpose is to prevent one server from becoming overloaded and to keep the application fast, reliable and available.
For example, if thousands of users access a website at the same time, sending all requests to one server can make the server slow or even cause it to crash. A load balancer distributes these requests among multiple servers.
How a Load Balancer Works
A simple architecture looks like this:
1
2
3
4
5
6
7
8
9
10
Users
|
v
+-------------+
|Load Balancer|
+-------------+
/ | \
/ | \
v v v
Server 1 Server 2 Server 3When a request arrives, the load balancer decides which server should handle that request.
For example:
- Request 1 → Server 1
- Request 2 → Server 2
- Request 3 → Server 3
- Request 4 → Server 1
This helps to distribute the workload between the servers.
Frontend Tier and Backend Tier
A web application can be divided into different tiers.
The Frontend Tier is the part that the user sees and interacts with.
For example:
- Login page
- Buttons
- Forms
- Dashboard
- Website pages
Technologies can include HTML, CSS and React.
The Backend Tier works behind the scenes. It processes requests and performs the actual work.
For example:
- Authentication
- API processing
- Database operations
- Business logic
- AI processing
Technologies can include FastAPI, Django, Node.js and Java.
A common architecture can look like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
User
|
v
Frontend Tier
|
v
Load Balancer
|
+--------+--------+
| | |
v v v
Backend Backend Backend
Server 1 Server 2 Server 3Here, the load balancer distributes incoming requests between multiple backend servers.
Types of AWS Load Balancers
AWS provides Elastic Load Balancing (ELB). It has different load balancers for different requirements.
Application Load Balancer (ALB)
ALB is mainly used for HTTP and HTTPS applications, such as websites and REST APIs.
It can understand HTTP requests and route traffic based on information such as the URL path or host name.
For example:
1
2
3
4
5
example.com/users → User Service
example.com/products → Product Service
example.com/ai → AI ServiceSo, ALB is commonly used for web applications and APIs.
Network Load Balancer (NLB)
NLB is designed for high-performance and low-latency network traffic.
It supports protocols such as TCP, UDP and TLS.
NLB is useful when an application needs very high performance and handles network-level traffic.
So, the easy way to remember is:
NLB → Network traffic → High performance
Gateway Load Balancer (GWLB)
GWLB is mainly used for network and security appliances.
For example:
- Firewalls
- Intrusion detection systems
- Traffic inspection systems
- Other network security appliances
It helps organisations deploy and scale these appliances.
So:
GWLB → Gateway → Security/Network appliances
The important thing is that these are different types of load balancers, but the main concept remains the same: handling and distributing traffic according to the requirement.
Role of Queue and Messaging
A queue is different from a load balancer, but both can be used in the same application.
A load balancer distributes incoming requests between servers.
A queue stores tasks or messages until they can be processed.
For example, suppose 1,000 users request AI article summaries at the same time.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Frontend
|
v
Load Balancer
|
v
Backend Servers
|
v
Message Queue
|
+--------+--------+
v v v
Worker Worker Worker
| | |
+--------+--------+
|
v
AI ModelThe load balancer distributes requests between backend servers, while the queue manages tasks that may take longer to process.
Therefore:
Load Balancer → Distributes traffic
Queue → Manages tasks/messages
They work together, but a queue does not perform the same job as a load balancer.
Benefits of a Load Balancer
1. High Availability
If one server fails, the load balancer can stop sending traffic to that server and send requests to healthy servers.
1
2
3
4
5
6
7
Load Balancer
|
+---- Server 1 ✓
|
+---- Server 2 ✗
|
+---- Server 3 ✓This helps keep the application available.
2. Scalability
When the number of users increases, we can add more backend servers behind the load balancer.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Before:
Load Balancer
|
Server 1
After:
Load Balancer
|
+--+--+--+
| | |
↓ ↓ ↓
S1 S2 S3This allows the application to handle more traffic.
3. Better Performance
Instead of one server handling all requests, the traffic is distributed between multiple servers. This reduces the workload on individual servers and can improve response time.
4. Health Checking
A load balancer can check whether backend servers are healthy.
If a server becomes unavailable, the load balancer can stop sending requests to it.
1
2
3
4
5
6
7
Load Balancer
|
+---- Server 1 ✓
|
+---- Server 2 ✗
|
+---- Server 3 ✓This helps prevent users from being sent to a failed server.
Real-World Example
Suppose we have an online shopping website.
During a big sale, thousands of users may access the website at the same time.
Without a load balancer:
1
2
3
4
5
6
7
Users
|
v
One Server
|
X
OverloadedWith a load balancer:
1
2
3
4
5
6
7
8
Users
|
v
Load Balancer
/ | \
v v v
Server Server Server
1 2 3The load balancer distributes the traffic between the servers, allowing the website to handle more users.
Conclusion
A Load Balancer is an important part of a scalable and highly available application. It distributes incoming traffic between multiple servers instead of allowing one server to handle all requests.
The basic architecture can be remembered as:
Frontend → Load Balancer → Backend Servers
For long-running or background tasks, a queue can also be added:
Backend → Queue → Workers
In AWS, ALB, NLB and GWLB are used for different requirements, but the main idea is simple:
A Load Balancer distributes traffic so that the application can handle users efficiently, remain available and scale when traffic increases.
# amazon-ec2# aws-certification# training-and-certification# cloud-practitioner# distributed-architecture
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article