Spreading The Load
A load balancer accepts incoming connections and spreads them across many backend targets. Cloud providers offer several types that operate at different layers of the network stack, and the right choice depends on what decisions you need to make about the traffic.
The Main Types
Each type trades features for speed and flexibility.
- An application load balancer works at layer seven and can route by URL path, host header, or cookies.
- A network load balancer works at layer four and forwards by IP and port at very high throughput.
- A gateway load balancer inserts third party appliances such as firewalls into the traffic path.
Picking One
Use an application load balancer when you need content based routing for HTTP services. Reach for a network load balancer when you need extreme throughput, static IPs, or non HTTP protocols. The layer four option is faster because it does not parse application data.
Key idea
Application load balancers route on layer seven content like paths and headers, while network load balancers forward at layer four for raw speed and static IPs, so the choice follows whether you need to inspect application data.