ALB vs NLB
Layer 7 application load balancing versus Layer 4 network load balancing on AWS.
Overview
What is being compared
Both are AWS load balancers, and each solves a distinct set of problems. The Application Load Balancer works at Layer 7: it terminates HTTP and HTTPS connections and routes on content. The Network Load Balancer works at Layer 4: it passes TCP and UDP connections through to targets with very low latency and without modifying packet headers.
- OSI layer — 7, HTTP and HTTPS — 4, TCP and UDP
- Connection — Terminated and inspected — Passed through without inspection
- Routing — Path, host, query string, headers — Flows to targets
- Features — Sticky sessions, authentication, WebSocket, AWS WAF — TLS pass-through, non-HTTP protocols
- Client IP at target — In X-Forwarded-For — Preserved natively
- IP addresses — Dynamic, reach it by DNS name — Static Elastic IP per AZ
- Latency — Adds 1 to 5 ms for HTTP parsing and rules — Sub-millisecond
Layer 7 versus Layer 4 routing
The ALB ends the client's connection and opens its own to the target, so it can read the request and must carry the client IP in a header. The NLB hands the same flow to the target, so the target sees the client directly.
> [!NOTE] AWS WAF attaches only to ALB and CloudFront, never to NLB.
> [!TIP] Both load balancers side by side, a partner call through an NLB in front of an ALB, and the choice between them play step by step in Visual Explanation below.
Sign up free to read the full topic
More Comparisons topics
Start free on Cariara · Coding problems · System design studio