Skip to content
We areTOP 1%

What is the difference between Layer 4 and Layer 7 load balancing?

MediumConceptLoad Balancing
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

A Layer 4 load balancer routes using transport-level information (IP addresses and TCP or UDP ports) without inspecting the payload. A Layer 7 load balancer understands the application protocol, usually HTTP, and routes on paths, headers, cookies or hostnames.

  • L4: very fast with low overhead, protocol-agnostic, and can pass encrypted traffic through untouched; it cannot make content-based decisions.
  • L7: supports path-based routing (for example, /api to one service and /images to another), header-based canary releases, cookie-based sticky sessions, caching and request rewriting.
  • Cost: L7 must terminate TLS and parse every request, which uses more CPU and adds slight latency.
  • A common setup places an L4 balancer at the edge and L7 proxies such as NGINX or Envoy behind it.

More in Load Balancing

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account