AWS Builder Center

AWS Elastic Load Balancing (ELB): Understanding Load Balancers and How They Work

Learn how AWS Elastic Load Balancing (ELB) distributes incoming application traffic across multiple targets to improve availability, scalability, and fault tolerance. This article explains how load balancers work, explores different types of AWS load balancers, and covers their real-world use cases.

Introduction

Imagine you are running a website hosted on a single EC2 instance. Initially, everything works perfectly. But as your website grows and more users start visiting, your server may struggle to handle all incoming requests.
This can lead to slow response times, server overload, or even application downtime.
So, how can we handle increasing traffic without putting too much pressure on a single server?
The answer is Load Balancing.
AWS provides a managed service called Elastic Load Balancing (ELB) that automatically distributes incoming application traffic across multiple targets, such as EC2 instances, containers, and IP addresses.

What is a Load Balancer?

A Load Balancer is a service that distributes incoming network traffic across multiple servers or targets.
Instead of sending every user request to a single server, the load balancer distributes requests among multiple healthy servers.
For example:
  • Server 1 receives some requests.
  • Server 2 receives other requests.
  • Server 3 handles additional requests.
This helps prevent individual servers from becoming overloaded.

How Does AWS Load Balancing Work?

Let's understand with a simple example.
Suppose we have:
  • One AWS Load Balancer.
  • Three EC2 instances.
  • Multiple users accessing our application.
When users send requests to our application, the load balancer receives those requests and forwards them to healthy EC2 instances.
If one EC2 instance becomes unhealthy, the load balancer can stop sending traffic to that instance and route requests to the remaining healthy instances.
This process is called Health Checking.
It helps maintain application availability even when an individual server fails.

Types of AWS Load Balancers

AWS Elastic Load Balancing provides four main types of load balancers.

1. Application Load Balancer (ALB)

Application Load Balancer operates at Layer 7 (Application Layer) of the OSI model.
It is designed for HTTP and HTTPS traffic.
Key features:
  • Supports path-based routing.
  • Supports host-based routing.
  • Supports HTTP and HTTPS.
  • Can route traffic to different target groups.
  • Commonly used for web applications and microservices.
Example:
Suppose your application has:
  • example.com/users
  • example.com/products
  • example.com/payments
An ALB can route requests to different backend services based on the URL path.

2. Network Load Balancer (NLB)

Network Load Balancer operates at Layer 4 (Transport Layer).
It handles TCP, UDP, and TLS traffic and is designed for high performance and low latency.
Key features:
  • Handles millions of requests per second.
  • Provides ultra-low latency.
  • Supports static IP addresses.
  • Suitable for applications requiring high network performance.
Example: Real-time gaming applications, financial applications, and high-performance network services.

3. Gateway Load Balancer (GWLB)

Gateway Load Balancer helps deploy, scale, and manage virtual network appliances.
It operates at Layer 3 (Network Layer) and uses GENEVE encapsulation.
Key features:
  • Distributes traffic across virtual appliances.
  • Supports security inspection.
  • Helps integrate third-party network appliances.
Example: Deploying virtual firewalls and intrusion detection systems.

4. Classic Load Balancer (CLB)

Classic Load Balancer is the older generation of AWS Elastic Load Balancing.
It supports basic load balancing at both Layer 4 and Layer 7.
It is mainly used for applications built on older architectures. For new applications, AWS generally recommends Application Load Balancer or Network Load Balancer, depending on the requirements.

Why Do We Need a Load Balancer?

Here are some important benefits:
1. High Availability
If one server becomes unhealthy, traffic can be routed to other healthy servers.
2. Scalability
Load balancing helps distribute traffic when application demand increases. It works well with Auto Scaling to add or remove EC2 instances based on demand.
3. Fault Tolerance
It reduces dependency on a single server and helps applications continue operating when individual targets fail.
4. Better Performance
Distributing traffic across multiple servers helps prevent individual instances from becoming overloaded.
5. Health Monitoring
Load balancers continuously perform health checks on registered targets to identify unhealthy instances.

Practical Example: AWS EC2 + Application Load Balancer

Let's consider a simple web application architecture.
  1. Create two or more EC2 instances.
  1. Install and configure a web server such as Apache or Nginx on each instance.
  1. Create a Target Group and register your EC2 instances.
  1. Create an Application Load Balancer.
  1. Configure a listener on port 80 or 443.
  1. Forward incoming requests to the Target Group.
  1. Access the application using the Load Balancer's DNS name.
Now, incoming requests will be distributed across your registered healthy EC2 instances.
You can also stop one EC2 instance and observe how the load balancer handles traffic using the remaining healthy targets.

Load Balancer vs Auto Scaling

These two AWS services are often used together, but they perform different jobs.
Load Balancer: Distributes incoming traffic across registered targets.
Auto Scaling: Automatically increases or decreases the number of EC2 instances based on defined scaling policies.
When used together, they help build highly available and scalable applications.

Best Practices

  • Deploy targets across multiple Availability Zones.
  • Configure appropriate health checks.
  • Use HTTPS listeners to secure application traffic.
  • Integrate Application Load Balancer with Auto Scaling when appropriate.
  • Monitor load balancer metrics using Amazon CloudWatch.
  • Choose the load balancer type according to your application's requirements.

Conclusion

AWS Elastic Load Balancing is an important service for building scalable, highly available, and fault-tolerant applications.
It distributes incoming traffic across multiple healthy targets, reducing the dependency on individual servers.
Understanding the differences between ALB, NLB, GWLB, and CLB helps you choose the right load balancing solution for your application.
If you are learning AWS or working towards becoming a Cloud Engineer, understanding Elastic Load Balancing is an essential step in learning real-world AWS architecture.
Keep Learning, Keep Building! 🚀
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