What is the primary difference between a Layer 4 (Transport) and Layer 7 (Application) Load Balancer?
- A Layer 4 load balancers are strictly hardware-based appliances, while Layer 7 balancers are software-defined solutions running in virtualized environments.
- B Layer 4 routes based on IP addresses and ports without inspecting payloads; Layer 7 can inspect HTTP headers and URLs to perform content-aware routing.
- C Layer 4 is significantly slower than Layer 7 because it must perform complex deep packet inspection to determine the final destination for every segment.
- D Layer 7 is unable to handle or terminate encrypted HTTPS traffic, requiring a secondary decryption layer to be placed before the load balancer in the network.
Load balancing occurs at different levels of the networking stack. A Layer 4 (Transport) load balancer is 'packet-aware'—it sees the source/destination IP and Port but doesn't understand the application data. This makes it extremely fast and efficient for high-throughput traffic. A Layer 7 (Application) load balancer is 'message-aware'. It terminates the connection, parses the HTTP request, and can make smart decisions based on the URL (e.g., `/images` hits one server while `/api` hits another) or even session cookies. While Layer 7 provides much greater flexibility and session management, it requires more CPU and memory to process the high-level application data.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- What is the downside of enabling 'Sticky Sessions' (Session Affinity) on a Load Balancer?
- In WebRTC (P2P Mesh), why is a STUN server required?
- What is the fundamental difference between a Network Switch and a Router?
- In Cloud Networking (AWS), what is the limitation of VPC Peering compared to a Transit Gateway?
- Which protocol is ideal for real-time multiplayer gaming positions or Voice over IP (VoIP), and why?
- What is the purpose of the 'Time To Live' (TTL) field in an IP packet?