Load Balancer
ELI5 — The Vibe Check
A load balancer is like a traffic cop for servers. When thousands of requests hit your site, the load balancer distributes them across multiple servers so no single one gets overwhelmed. If one server dies, the load balancer stops sending traffic to it and other servers pick up the slack.
Real Talk
A load balancer distributes incoming network traffic across multiple backend servers using algorithms like round-robin, least connections, or IP hash. It improves availability, scalability, and fault tolerance. Can operate at Layer 4 (TCP/UDP) or Layer 7 (HTTP/HTTPS).
Show Me The Code
# Nginx load balancer config
upstream backend {
least_conn; # Algorithm: least connections
server app1.example.com:3000;
server app2.example.com:3000;
server app3.example.com:3000;
# Health checks
keepalive 32;
}
server {
location / {
proxy_pass http://backend;
}
}
When You'll Hear This
"Add a load balancer in front of the three app servers." / "The load balancer detected app2 is unhealthy and pulled it from the pool."
Related Terms
Reverse Proxy
A reverse proxy sits in front of your servers and handles incoming traffic on their behalf.
Round Robin
Round Robin is the simplest load balancing strategy: send request 1 to server A, request 2 to server B, request 3 to server C, then back to server A, and s...
Sticky Session
Sticky sessions make sure a user always gets routed to the SAME server, like getting the same cashier every time you visit a store.