Load Balancer Types: L4 vs L7
L4 vs L7 is the foundational LB choice. Pick wrong and you pay forever in operational complexity.
What each does
L4 (TCP/UDP): forwards based on IP/port; cheap; fast.
L7 (HTTP): inspects headers, paths, cookies; routes intelligently.
When L4 wins
- 1. Sub-ms latency required.
- 2. Non-HTTP protocols.
- 3. Pure throughput.
- 4. SSL passthrough preferred.
When L7 wins
Most modern web traffic. Header-based routing. Path-based routing. SSL termination. Rate limiting.
HTTP-aware features only available at L7.
Hybrid posture
Many orgs: L4 at the edge; L7 inside (ingress controllers, service mesh).
Each layer does what it does best.
Antipatterns
- L7 for non-HTTP. Wrong layer; loses features.
- L4 with HTTP-aware needs. Re-implement at app layer.
- Multiple LB layers without thinking. Latency stacks.
What to do this week
Three moves. (1) Apply this pattern to your highest-risk network path. (2) Measure the failure mode rate before/after. (3) Document the change so the next incident-responder inherits the knowledge.