AWS Cloud Architecture•Part 2: Networking, VPC & Traffic Routing (6 - 20)
ALB vs NLB vs GWLB.
In Simple Words:
- ALB (Application Load Balancer): Layer 7 (HTTP/HTTPS/gRPC). Path-based routing, host-based routing, SSL termination, and WebSockets.
- NLB (Network Load Balancer): Layer 4 (TCP/UDP/TLS). Ultra-high throughput, millions of requests/sec with ultra-low latency, and provides static Elastic IPs.
- GWLB (Gateway Load Balancer): Deploys and scales third-party virtual network appliances (firewalls, deep packet inspection).
hcl
# Application Load Balancer path-based listener rule:
resource "aws_lb_listener_rule" "api_routing" {
listener_arn = aws_lb_listener.front_end.arn
priority = 100
action {
type = "forward"
target_group_arn = aws_lb_target_group.api_tg.arn
}
condition {
path_pattern { values = ["/api/*"] }
}
}