Course contentsShow
← System Design
Lesson 110 of 1,9193. Load BalancingFree lesson

Layer 7 (Application) Load Balancing

Learn HTTP/HTTPS load balancing that can route based on URL paths, headers, cookies, and application-level data.

Layer 7 (Application) Load Balancing

What you'll learn: How Layer 7 load balancers inspect HTTP/HTTPS content to route traffic intelligently based on application-level data.

What Makes Layer 7 Special?

Unlike Layer 4 load balancers that only see IP addresses and ports, Layer 7 load balancers operate at the application layer. They can read and understand the actual HTTP/HTTPS requests your users send, examining URLs, headers, cookies, and even request bodies.

How It Works

Think of Layer 7 load balancing like a smart receptionist who reads your entire request form, not just your name tag. Instead of blindly forwarding you to any available person, they route you to the specialist who handles your specific need.

A Layer 7 load balancer can route based on:

  • URL paths: /api/users goes to the user service, /api/orders goes to the order service
  • HTTP headers: Mobile user-agents route to mobile-optimized servers
  • Cookies: Session cookies enable sticky sessions at the application level
  • Query parameters: Requests with ?region=eu go to European servers
  • HTTP methods: POST requests might go to write-heavy servers

The Tradeoff

Layer 7 load balancing is more powerful but more expensive. The load balancer must:

  1. Terminate the TCP connection
  2. Parse the entire HTTP request
  3. Make routing decisions
  4. Establish a new connection to the backend

This requires more CPU and memory than Layer 4, but enables sophisticated routing that can optimize your architecture significantly.

Key Takeaway: Layer 7 load balancers inspect HTTP/HTTPS content to make intelligent routing decisions based on application-level data like URLs, headers, and cookies, trading performance overhead for powerful routing capabilities.