L4 vs L7 Balancing
Packets or requests.
Load balancers work at one of two levels. Layer four looks only at network addresses. Layer seven reads the actual HTTP request. The names come from the layers of the networking model.

- Two levels
- Layer 4: addresses
- Layer 7: the request itself
Layer 4 vs layer 7
A layer four balancer sees only IP addresses and ports. It can't read the request, so it's extremely fast, and works for any protocol. A layer seven balancer reads the HTTP path, headers, and cookies. It's slower, but much smarter. It can send slash images to one group of servers, and slash api to another.
Layer 4
- Sees IPs and portsVery fastAny protocol
Layer 7
- Reads HTTP paths, headersSmart routingCan end HTTPS
Where they show up
In practice, you often see both. A layer four balancer at the edge spreads huge traffic across several layer seven balancers. Those route each request by path, to the right service. Cloud providers offer both kinds, and tools like Nginx and HA Proxy can do layer seven routing.
| key | value |
|---|---|
| Edge | L4 for raw speed |
| Inside | L7 for smart routing |
| /api | to API servers |
| /images | to image servers |
Summary
Layer four balancers are fast and simple, layer seven balancers read requests and route them smartly. Next, how a balancer knows which servers are healthy.
Key takeaways- L4: addresses only
- L7: reads requests
- Often used together