L4 vs L7 Load Balancing
Give a real production-style example of using L4 vs L7 Load Balancing. Walk through the scenario end-to-end.
Answers use simple, clear English.
Quick interview answer
Scenario: ALB routes /api → API target group, /static → S3; NLB for gRPC TCP passthrough. Implementation notes: Health check app endpoint not TCP only; cross-zone LB.
Detailed answer
Scenario: ALB routes /api → API target group, /static → S3; NLB for gRPC TCP passthrough. Implementation notes: Health check app endpoint not TCP only; cross-zone LB. 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: Engineering Manager.
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
Open one as its own read / solve / listen card