Load balancer
The notes
How it works
A load balancer sits between users and backend servers, distributing incoming traffic across multiple servers so no single server becomes overwhelmed. It acts as a traffic director for your application.
- Users send requests to the application and the load balancer receives them first
- Instead of sending all requests to one server, it distributes them across multiple backend servers using specific algorithms
- Each server processes its assigned requests and sends responses back through the load balancer to the users
- It also monitors server health, automatically routing traffic away from failed servers to maintain availability
Distribution algorithms
Round robin
- Distributes requests sequentially to each server in rotation
- Simple and fair; ideal when servers have similar capacity and requests need similar processing
Least connections
- Routes traffic to the server with the fewest active connections
- Best for applications where request processing time varies significantly
IP hash
- Uses the client's IP address to determine which server receives the request
- Ensures the same user always connects to the same server (session persistence)
Key benefits
- Prevents overload: no single server handles all traffic, so none becomes a bottleneck and resources are used well
- Increases availability: if a server fails, traffic is automatically redirected to healthy servers, so users see no downtime
- Improves performance: response times stay fast even under high traffic
- Scalability: easily add or remove servers without disrupting service; new servers are automatically included in the rotation, enabling seamless horizontal scaling
Common use cases
- Web applications: distribute HTTP/HTTPS traffic across web servers
- Microservices: route API requests to service instances
- Database clustering: distribute read queries across replicas
System design deck
1. Fundamentals
2. Scaling
3. Frontend vs backend
4. Client-server architecture
5. Databases
6. Load balancer
7. Caching
8. Latency vs throughput
9. Availability and redundancy
10. CAP theorem
and many more
Make them stick
Sign in to see every card full size, tick the ones you've got, come back to the rest later, and keep your own notes on each card.
Watch the lesson
System design, Lesson 3, from 4:39: Load Balancer in Computing World