Networking interview question · Most asked

Compare layer 4 and layer 7 load balancers. When would you use each?

Create a free account to save this page, take notes and track your progress. Sign in

Summary

Layer 4 balancers route TCP/UDP by IP and port, preserve the protocol, handle very high throughput and offer static IPs (AWS NLB, Azure Load Balancer). Layer 7 balancers understand HTTP, terminate TLS and route by host, path or headers, and integrate WAFs and authentication (AWS ALB, Azure Application Gateway, Google Cloud Application Load Balancer).

Longer Answer

Use L7 for web apps and APIs (path routing, HTTP/2 and gRPC, redirects, header manipulation). Use L4 for non-HTTP protocols, client IP preservation, fixed IPs for allow-lists, or extreme performance. Often both appear: an NLB in front for static IPs and an ALB or ingress behind it.

Key Points

  • L4: IP/port, any TCP/UDP, static IPs.
  • L7: HTTP-aware routing, TLS, WAF.
  • Choose by protocol and features.
  • They can be combined.

Deep dive: Networking Tutorial: Load Balancers

Explanation

What interviewers look for

Matching the choice to protocol and requirements.

More most-asked Networking questions

← All Networking questions

Was this page helpful?