What is a load balancer?
Why Interviewers Ask This
Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for System Design development. It reveals whether you understand the building blocks that more complex concepts rely on.
Answer
A load balancer distributes incoming network traffic across multiple servers to ensure no single server becomes overwhelmed, improving availability and responsiveness. It sits between the client and server pool, acting as a reverse proxy. Load balancing algorithms: (1) Round Robin: requests distributed in rotation — simple, assumes equal server capacity; (2) Weighted Round Robin: more requests sent to higher-capacity servers; (3) Least Connections: new requests go to the server with the fewest active connections — good for long-lived connections; (4) IP Hash: client IP determines which server — ensures the same client always reaches the same server (session affinity/sticky sessions); (5) Random: random server selection; (6) Resource-based: routes based on actual server CPU/memory metrics. Layer 4 LB: operates at TCP/UDP level — fast, no content inspection; Layer 7 LB: operates at HTTP level — can route based on URL, headers, cookies (content-aware). Health checks: continuously tests servers; removes unhealthy ones from rotation. Types: hardware (F5), software (Nginx, HAProxy), cloud-managed (AWS ALB/NLB). Benefits: high availability (no SPOF), horizontal scalability, SSL termination, DDoS protection. The load balancer itself can be a bottleneck — use redundant load balancers (active-passive or active-active) for high availability.
Pro Tip
If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.