Layer 4 vs Layer 7 Load Balancing
Balancing on connection metadata (IP and port) versus on the content of the request (path, host, headers).
Layer 4 forwards TCP or UDP connections without inspecting them. It is fast, protocol-agnostic, preserves end-to-end TLS, and can do nothing content-aware — no path routing, no header-based canaries, no request-level retries.
Layer 7 terminates the connection and reads the request, which unlocks path and host routing, header manipulation, per-request retry and timeout, response caching, compression and request-level observability. It costs CPU, adds latency, and means TLS is terminated there (or re-encrypted onwards).
Most web architectures want L7 at the edge. L4 is the right choice for non-HTTP protocols, for extreme throughput, and where regulatory or trust requirements say the traffic must stay encrypted end to end.