L4 vs L7 Load Balancing
As a Tech Lead engineer, explain L4 vs L7 Load Balancing. What problem does it solve and how would you describe it in an interview?
Answers use simple, clear English.
Quick interview answer
At Tech Lead depth: start with the problem, then mechanism, then a short example. L4 (TCP) routes by IP/port fast.
Detailed answer
At Tech Lead depth: start with the problem, then mechanism, then a short example. L4 (TCP) routes by IP/port fast. L7 (HTTP) routes by path/header/cookie — enables sticky sessions, TLS, WAF integration. Core: L4 (TCP) routes by IP/port fast. L7 (HTTP) routes by path/header/cookie — enables sticky sessions, TLS, WAF integration. Real-time example: ALB routes /api → API target group, /static → S3; NLB for gRPC TCP passthrough. Pros: L7 smart routing; L4 performance for non-HTTP. Cons: L7 terminates TLS — cert management; L4 no URL awareness. Common mistakes: L7 LB without health checks; single LB bottleneck. Best practices: Health check app endpoint not TCP only; cross-zone LB. Audience level: Tech Lead.
Full explanation
L4 (TCP) routes by IP/port fast. L7 (HTTP) routes by path/header/cookie — enables sticky sessions, TLS, WAF integration.
Real example & use case
ALB routes /api → API target group, /static → S3; NLB for gRPC TCP passthrough.
Pros & cons
Pros: L7 smart routing; L4 performance for non-HTTP. Cons: L7 terminates TLS — cert management; L4 no URL awareness.
Common mistakes
L7 LB without health checks; single LB bottleneck.
Best practices
Health check app endpoint not TCP only; cross-zone LB.
Follow-up questions
- How would you test L4 vs L7 Load Balancing?
- What metrics prove L4 vs L7 Load Balancing is healthy in prod?
- How does L4 vs L7 Load Balancing change at 10× traffic?