Load Balancer
A load balancer is a networking component that distributes incoming traffic across multiple backend servers or instances, improving availability, reliability, and performance by preventing any single server from becoming overwhelmed.
Definition
A load balancer is a networking component that distributes incoming traffic across multiple backend servers or instances, improving availability, reliability, and performance by preventing any single server from becoming overwhelmed.
Overview
Load balancers sit in front of a pool of servers and decide, for each incoming request, which backend instance should handle it. This solves two related problems at once: it spreads traffic evenly so no single server is overloaded while others sit idle, and it provides fault tolerance, since the load balancer can detect an unhealthy instance via health checks and stop routing traffic to it until it recovers. Load balancers operate at different layers of the network stack. Layer 4 (transport-layer) load balancers route based on IP address and port without inspecting the actual content of the traffic, making them fast and protocol-agnostic. Layer 7 (application-layer) load balancers can inspect HTTP headers, paths, and cookies, enabling smarter routing like sending `/api/*` requests to one service and `/images/*` to another, or maintaining session affinity so a user's requests consistently hit the same backend. Every major cloud provider offers managed load balancing — AWS has the Application, Network, and Gateway Load Balancer variants; Azure and Google Cloud offer comparable managed services — which removes the need to run and patch load-balancing software yourself. Load balancers are a core building block of both Auto Scaling (new instances are automatically registered behind the load balancer as they're launched) and cloud-native architectures more broadly, where a service mesh often extends load-balancing logic down to traffic between individual microservices, not just at the edge of the system.
Key Concepts
- Distributes incoming traffic across multiple backend servers or instances
- Health checks automatically remove unhealthy instances from rotation
- Layer 4 (transport) load balancing for fast, protocol-agnostic routing
- Layer 7 (application) load balancing for content-aware routing and session affinity
- Integrates with Auto Scaling to register and deregister instances automatically
- Supports SSL/TLS termination to offload encryption from backend servers
- Improves fault tolerance by rerouting traffic away from failed instances