Back to: AWS-Basics-Advanced
AWS Load Balancer: Overview, Types, and Components
In cloud architectures, handling high traffic efficiently is crucial. A load balancer distributes incoming traffic across multiple resources (like EC2 instances) to ensure high availability, fault tolerance, and scalability.
AWS offers Elastic Load Balancing (ELB) β a fully managed service that automatically distributes incoming application or network traffic.
π 1. What is a Load Balancer?
A Load Balancer (LB) acts as a traffic manager for your application:
-
Distributes requests across multiple targets (EC2, containers, IP addresses).
-
Ensures no single instance is overloaded.
-
Increases fault tolerance β if one target fails, traffic is redirected to healthy targets.
-
Supports secure connections using SSL/TLS.
Real-world analogy: Think of a cashier line in a supermarket. The load balancer is like the manager directing customers to the shortest or fastest line, so everyone is served efficiently.
βοΈ 2. Types of AWS Load Balancers
AWS offers 3 main types of load balancers under Elastic Load Balancing:
Load Balancer | Protocol / Layer | Use Case |
---|---|---|
Application Load Balancer (ALB) | HTTP / HTTPS (Layer 7) | Web applications, advanced routing, microservices, container-based apps |
Network Load Balancer (NLB) | TCP / UDP / TLS (Layer 4) | Ultra-low latency, high-performance apps, millions of requests per second, static IP requirements |
Gateway Load Balancer (GLB) | IP traffic (Layer 3) | Third-party virtual appliances, security appliances, firewalls, monitoring appliances |
πΉ Application Load Balancer (ALB)
-
Operates at Layer 7 (Application Layer)
-
Supports path-based and host-based routing
-
Ideal for microservices and containerized apps
-
Supports HTTP/HTTPS and WebSocket protocols
-
Can integrate with AWS WAF (Web Application Firewall) for security
Example:
-
Route
/images/*
traffic to an EC2 group for image servers -
Route
/api/*
traffic to another EC2 group running your APIs
πΉ Network Load Balancer (NLB)
-
Operates at Layer 4 (Transport Layer)
-
Extremely fast and can handle millions of requests per second
-
Ideal for TCP/UDP applications
-
Supports static IP addresses and Elastic IPs
-
Best for low latency applications, such as gaming servers, IoT, or financial apps
πΉ Gateway Load Balancer (GLB)
-
Operates at Layer 3 (Network Layer)
-
Distributes traffic to third-party virtual appliances like firewalls or intrusion detection systems
-
Used in advanced security, monitoring, and network inspection setups
π 3. Key Differences Between Load Balancers
Feature | ALB | NLB | GLB |
---|---|---|---|
Layer | 7 | 4 | 3 |
Protocols | HTTP/HTTPS/WebSocket | TCP/UDP/TLS | IP |
Use Case | Web apps, microservices | High-performance apps, low latency | Security appliances, virtual appliances |
Routing | Host/path-based | Flow hash (IP/port) | Forward traffic to appliances |
Static IP | β | β | β |
TLS Termination | β | β | β |
Health Checks | Application-based | TCP/HTTP | IP-based |
π§© 4. Components of AWS Load Balancers
AWS Load Balancers are made up of several key components:
Component | Description |
---|---|
Listeners | Define protocol and port (e.g., HTTP:80, HTTPS:443) that the LB listens on. |
Target Groups | Logical grouping of EC2 instances, IP addresses, or Lambda functions that receive traffic. |
Rules | Define how the LB routes requests to target groups (ALB only). Supports host/path-based routing. |
Health Checks | Periodically check if targets are healthy; unhealthy targets donβt receive traffic. |
Security Groups / Network ACLs | Control inbound/outbound traffic to the LB (ALB/NLB). |
Cross-Zone Load Balancing | Distributes traffic evenly across multiple AZs for fault tolerance. |
π§ 5. Choosing the Right Load Balancer
Scenario | Recommended LB |
---|---|
Web application with HTTP/HTTPS | ALB |
API Gateway or microservices with path/host routing | ALB |
Ultra-low latency TCP app | NLB |
Security appliances or firewall deployment | GLB |
Mixed web + TCP traffic | Use ALB + NLB combo |
6. Best Practices
-
Use ALB for web apps and NLB for low-latency apps.
-
Enable cross-zone load balancing for HA.
-
Use AWS WAF with ALB for added security.
-
Regularly monitor CloudWatch metrics: RequestCount, HealthyHostCount, Latency, etc.
-
Configure sticky sessions only when needed.