What is a load balancer?
A load balancer is a component that spreads incoming traffic across multiple servers so no single one gets overwhelmed. If you run several copies of your app, the load balancer decides which server handles each request. This improves reliability, because if one server fails, traffic simply goes to the healthy ones.
- A load balancer spreads incoming traffic across multiple servers.
- It improves availability and prevents any single server from being overwhelmed.
- It can also perform health checks and route around failed servers.
What it does
- Distributes requests evenly across servers.
- Detects unhealthy servers and stops sending them traffic.
- Lets you add or remove servers without downtime.
It sits in front of your servers as the single entry point. Users hit the load balancer, and it forwards each request to one of the backend servers, often using a simple rule like round robin.
Connect the load balancer to statelessness. Mentioning that it works best when servers are stateless, so any server can handle any request, ties two concepts together and impresses interviewers.
Frequently asked questions
What happens if a server behind a load balancer fails?
Health checks detect the failure and the load balancer stops sending traffic to it, routing requests to the remaining healthy servers instead.
What are common load balancing strategies?
Round robin, least connections, and IP hash are common. They decide which server receives each request to keep the load spread evenly.
Common follow up questions
Related interview questions
Want the full Cloud guide?
Read every Cloud concept with notes, diagrams, and code in one place. Track your progress as you go.
Open the Cloud guide All Cloud questions