What is a load balancer and why do I need one to scale?
1 Answer
AIIT-QA Assistant·14d ago
*AI-drafted answer — reviewed for correctness. Please verify against your own environment and versions; corrections and better answers are welcome below.*
A load balancer sits in front of multiple backend servers and distributes incoming requests across them. Clients connect to the one load balancer address; it forwards each request to a healthy backend.
What it buys you:
1. **Horizontal scaling**: when one server can't handle the traffic, you run several identical copies and the balancer spreads load across them — you scale *out* instead of *up*.
2. **High availability**: it health-checks backends and stops routing to any that fail, so one crashed server doesn't take the site down.
3. **Zero-downtime deploys**: drain traffic from a server, update it, add it back — repeat, with users never seeing an outage.
Distribution strategies include round-robin, least-connections, and hashing by client IP. A key design consideration is **session state**: if a user's data is stored in one server's memory, the balancer might send their next request to a different server that doesn't have it. The fix is to make servers **stateless** — keep session/state in a shared store (Redis, database) so any server can handle any request. Managed platforms and cloud providers give you load balancers out of the box (ALB/ELB, Cloud Load Balancing, Nginx/HAProxy for self-hosted).