System Design: Load Balancers
March 28, 2025
1 min read
0 views
You have built a great app. Suddenly, 10,000 users sign up. Your server crashes. Why?
The Traffic Cop
A Load Balancer (LB) is like a traffic cop at a busy intersection.
Instead of all traffic hitting one server, the LB sits in front and distributes requests.
- Request 1 -> Server A
- Request 2 -> Server B
- Request 3 -> Server C
Algorithms
How does the LB decide?
- Round Robin: A -> B -> C -> A. Simple, fair.
- Least Connections: Send to the server with fewest active users.
- IP Hash: User X always goes to Server A (Useful for caching/sessions).
Nginx as LB
You don't need expensive hardware. Nginx can do this.
CSS
upstream myapp {
server 10.0.0.1;
server 10.0.0.2;
server 10.0.0.3;
}
server {
location / {
proxy_pass http://myapp;
}
}
Conclusion
Scaling horizontally (adding more cheap servers) is almost always better than scaling vertically (buying one super-computer).
Similar Posts
System Design: Caching Strategies
Aug 20, 2025