AWS Builder Center
AWS Load Balancer: Complete Beginner-Friendly Guide

AWS Load Balancer: Complete Beginner-Friendly Guide

When an application becomes popular, many users may access it at the same time. Sending all traffic to a single server can overload the server and cause slow performance or downtime.

AWS Student Builder | Cloud & DevOps Learner

What Is an AWS Load Balancer?

An AWS Load Balancer is a managed service that distributes incoming application traffic across multiple targets, such as EC2 instances.
A simple architecture looks like this:
1
2
3
4
5
6
7
Users
|
v
Load Balancer
/ | \
v v v
EC2-1 EC2-2 EC2-3
Instead of users connecting directly to one server, they connect to the Load Balancer.
The Load Balancer then forwards requests to appropriate backend targets.

Why Do We Need a Load Balancer?

A Load Balancer provides several important benefits:
  • High Availability – traffic can be distributed across multiple servers.
  • Scalability – applications can handle increasing traffic more effectively.
  • Fault Tolerance – unhealthy servers can be removed from normal traffic.
  • Better Performance – requests are distributed instead of overloading one server.
  • Health Checks – AWS can continuously check the health of registered targets.
  • Security – the Load Balancer can act as the public entry point while backend servers remain more restricted.

Types of AWS Load Balancers

AWS provides different types of Elastic Load Balancing for different use cases.

1. Application Load Balancer (ALB)

The Application Load Balancer works at the application layer, commonly called Layer 7.
It is commonly used for:
  • HTTP/HTTPS applications
  • Web applications
  • REST APIs
  • Microservices
  • Path-based routing
  • Host-based routing
Example:
1
2
3
4
5
6
7
8
User
|
v
ALB
|
+----> Web Servers
|
+----> API Servers

2. Network Load Balancer (NLB)

The Network Load Balancer operates primarily at Layer 4.
It is designed for high-performance network traffic such as TCP and UDP.
It is useful when applications require:
  • Very high performance
  • Low latency
  • TCP traffic
  • UDP traffic
  • TLS traffic

3. Gateway Load Balancer (GWLB)

The Gateway Load Balancer is designed for deploying, scaling, and managing network security appliances.
Examples include:
  • Firewalls
  • Intrusion Detection Systems
  • Intrusion Prevention Systems
  • Other network inspection appliances

Understanding Application Load Balancer (ALB)

For beginners working with AWS web applications, ALB is especially important.
A typical ALB architecture looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
Internet
|
v
Application Load
Balancer
|
Listener
|
Target Group
/ \
v v
EC2-1 EC2-2
Apache Apache
Let's understand each component.

1. Load Balancer

The Load Balancer is the entry point for incoming application traffic.
Users access the Load Balancer instead of directly accessing individual EC2 instances.

2. Listener

A Listener checks for incoming connection requests on a specific protocol and port.
Common examples are:
1
2
HTTP → Port 80
HTTPS → Port 443
For example:
1
2
3
4
5
6
Internet
|
v
ALB
|
+---- HTTP Listener :80

3. Listener Rules

Listener rules determine how the ALB should handle incoming requests.
For example:
1
2
IF path = /api
THEN send traffic to API Target Group
Another example:
1
2
IF host = shop.example.com
THEN send traffic to Shop Target Group
This makes ALB useful for applications containing multiple services.

4. Target Group

A Target Group contains the backend targets that receive traffic from the Load Balancer.
For example:
1
2
3
4
5
6
7
Target Group
|
+---- EC2-1
|
+---- EC2-2
|
+---- EC2-3
The ALB forwards requests to targets registered in the appropriate Target Group.

5. Targets

Targets are the backend resources that actually run your application.
For a simple AWS lab, your targets might be:
1
2
EC2-1 → Apache Web Server
EC2-2 → Apache Web Server

6. Health Checks

Health checks are one of the most important Load Balancer features.
The Load Balancer checks whether registered targets are healthy.
For a simple web server, the health check path is commonly:
1
/
Example:
1
2
3
4
5
6
7
ALB
|
+---- EC2-1 → Healthy
|
+---- EC2-2 → Healthy
|
+---- EC2-3 → Unhealthy
If a target becomes unhealthy, the Load Balancer can stop sending normal traffic to that target.

Security Groups with an ALB

A good architecture is to allow users to reach the ALB while restricting direct access to the EC2 instances.
For example:
1
2
3
4
5
6
7
8
9
10
11
12
Internet
|
| HTTP/HTTPS
v
ALB-SG
|
| HTTP
v
EC2-SG
|
v
EC2 Instances
The ALB Security Group can allow HTTP/HTTPS from the Internet.
The EC2 Security Group can allow HTTP traffic only from the ALB Security Group.
This helps prevent users from directly accessing the backend servers.

HTTP, HTTPS, SSL and TLS

For web applications, you will often see:
1
2
HTTP → Port 80
HTTPS → Port 443
HTTPS uses TLS encryption to protect data in transit.
People often say "SSL certificate," but modern HTTPS uses TLS. SSL is the older protocol family.
With an ALB, TLS can be terminated at the Load Balancer.
For example:
1
2
3
4
5
6
7
8
9
User
|
| HTTPS
v
ALB
|
| HTTP
v
EC2
The ALB handles the client TLS connection.
You can also configure encrypted traffic between the ALB and backend targets when your architecture requires it:
1
2
3
4
5
6
7
8
9
User
|
| HTTPS
v
ALB
|
| HTTPS
v
EC2
AWS Certificate Manager (ACM) can be used to manage certificates for HTTPS listeners.

ALB Path-Based Routing

One powerful ALB feature is path-based routing.
For example:
1
2
3
4
example.com/api
|
v
API Target Group
While:
1
2
3
4
example.com/images
|
v
Image Target Group
This allows different parts of an application to use different backend services.

ALB Host-Based Routing

ALB can also route traffic based on the hostname.
For example:
1
2
3
4
api.example.com
|
v
API Target Group
and:
1
2
3
4
www.example.com
|
v
Web Target Group
This allows multiple applications or services to share the same Load Balancer.

ALB with Auto Scaling

A common production architecture combines:
ALB + Target Group + Auto Scaling Group + EC2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Users
|
v
ALB
|
v
Target Group
|
+----------+----------+
| | |
EC2 EC2 EC2
^ ^ ^
| | |
+---- Auto Scaling ---+
When traffic increases, Auto Scaling can launch additional instances according to the configured scaling policy.
The Load Balancer can then distribute traffic among healthy targets.

Simple AWS ALB Lab

A beginner-friendly lab can be built using:
  • 2 EC2 instances
  • Apache Web Server
  • 1 Target Group
  • 1 Application Load Balancer
  • 2 Security Groups
You can use EC2 User Data to install Apache automatically, so you do not need to manually SSH into the instances just to install the web server.
Example User Data:
1
2
3
4
5
6
7
8
9
#!/bin/bash

apt update -y
apt install apache2 -y

systemctl enable apache2
systemctl start apache2

echo "<h1>Hello from EC2 Server</h1>" > /var/www/html/index.html
You can customize each server with a different message:
1
2
EC2-1 → Hello from Server 1
EC2-2 → Hello from Server 2
Then access the ALB DNS name in your browser.

Complete ALB Traffic Flow

The easiest way to remember an ALB is:
1
2
3
4
5
6
7
8
9
10
11
12
13
User
↓
Load Balancer
↓
Listener
↓
Listener Rule
↓
Target Group
↓
Healthy Target
↓
Application
For HTTPS:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
User
↓
HTTPS :443
↓
ALB
↓
TLS Termination
↓
Listener
↓
Target Group
↓
EC2
↓
Application

ALB vs NLB

FeatureALBNLB
Main LayerLayer 7Layer 4
HTTP/HTTPSYesYes
TCPNot its primary focusYes
UDPNoYes
Path-based routingYesNo
Host-based routingYesNo
Application-aware routingYesNo
High-performance network trafficNot its primary purposeYes

Easy way to remember:

ALB = Application
NLB = Network

Final Takeaway

An AWS Load Balancer is an important service for building highly available and scalable applications.
The most important ALB concepts to remember are:
1
2
3
4
5
6
7
8
9
10
11
ALB
↓
Listener
↓
Listener Rule
↓
Target Group
↓
Targets
↓
Health Checks
Once you understand this sequence, you have a strong foundation for learning more advanced AWS architectures such as:
  • ALB + Auto Scaling
  • ALB + Route 53
  • ALB + HTTPS/TLS
  • ALB + ACM
  • ALB + ECS
  • ALB + Microservices
The simple idea is:
The Load Balancer receives the traffic, checks the available targets, and sends the request to a healthy backend server.
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