ALB vs NLB vs GLB: When to Use Which
Understand the differences between Application, Network, and Gateway Load Balancers and match each to its ideal use case.
Elastic Load Balancing Overview
Elastic Load Balancing (ELB) automatically distributes incoming application traffic across multiple targets—EC2 instances, containers, Lambda functions, or IP addresses. ELB is a managed service, meaning AWS handles provisioning, scaling, and availability of the load balancer itself across multiple AZs.
AWS offers three types of load balancers under the ELB umbrella: Application Load Balancer (ALB), Network Load Balancer (NLB), and Gateway Load Balancer (GWLB). Each operates at a different layer of the OSI model and is optimised for different use cases.
Application Load Balancer (ALB)
The ALB operates at Layer 7 (HTTP/HTTPS) of the OSI model. It can inspect HTTP headers, paths, query strings, hostnames, and cookies to make intelligent routing decisions. ALB is the go-to choice for web applications, microservices, and API endpoints that need content-based routing.
Key ALB features: path-based routing (/api/* to one target group, /static/* to another), host-based routing (different virtual hosts to different backends), HTTP header and query string routing, WebSocket support, and HTTP/2 support. ALB can route to EC2 instances, containers (ECS/EKS), Lambda functions, and IP addresses.
# Create an ALB
aws elbv2 create-load-balancer \
--name my-alb \
--subnets subnet-aaaa1111 subnet-bbbb2222 \
--security-groups sg-12345678 \
--type applicationAll lessons in this course
- ALB vs NLB vs GLB: When to Use Which
- Target Groups and Health Checks
- Listener Rules and Path-Based Routing
- SSL Termination and Sticky Sessions