Compare Layer 4 and Layer 7 balancing
Choose between connection-level routing and application-aware routing.
- Explain what transport and application-layer balancers can inspect and control.
Layer 4 balancing uses transport information such as IP addresses, protocol, and ports. It can route TCP or UDP flows without interpreting application requests. Layer 7 balancing understands protocols such as HTTP and can route by host, path, header, or cookie, terminate TLS, and apply request-aware policies. That extra context brings more flexibility and more protocol work, configuration, and processing cost.
A Layer 4 device cannot select a backend based on an encrypted HTTP path unless the traffic is decrypted by a component that can inspect it.
Practice: what can each layer see?
Try it
Up to 15 XPLayer 4 or Layer 7?
Ask what the balancer has to read to make each decision. If it’s inside the HTTP request, you need Layer 7.
“Spread a game server’s UDP traffic across a pool.”
“Send `/api/*` to the API pool.”
“Balance PostgreSQL connections.”
“Route `beta.example.com` to a separate pool.”
“Send users with a `canary=1` cookie to the new version.”
“Forward encrypted traffic without holding any certificates.”
Key takeaways
Layer 4 routes transport flows; Layer 7 can route application requests.
TLS must be terminated before encrypted HTTP paths can be inspected.
Choose the layer based on needed policy, protocol, and operational cost.
Lesson quiz
5 questions · pass with 4 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…