A load balancer is a tool—either hardware or software—that distributes
incoming network traffic across multiple servers. It’s used to ensure no
single server gets overwhelmed and to keep websites and apps fast,
stable, and reliable.
🧭 Basic Idea
Think of it like a traffic cop at an intersection, directing cars (data requests)
to different roads (servers) to prevent jams (overload).
🧱 What It Does
Distributes traffic evenly across multiple backend servers
Increases reliability — if one server fails, traffic goes to another
Improves performance — faster response by using the least busy
server
Scales applications — lets you add/remove servers without
downtime
⚙️Common Load Balancing Algorithms
Algorithm How It Works
Round Robin Sends traffic to each server in turn
Chooses the server with the fewest active
Least Connections
connections
Routes requests based on the client’s IP
IP Hash
address
Weighted Round
Prefers more powerful servers more often
Robin
📦 Types of Load Balancers
1. Layer 4 (Transport Layer)
Routes traffic based on IP address and port
Fast and efficient
Examples: HAProxy (L4), AWS ELB (TCP)
2. Layer 7 (Application Layer)
Smarter — understands HTTP/HTTPS, cookies, and more
Can route based on URLs, headers, or content
Examples: NGINX, AWS ALB, Traefik
☁️Cloud-Based Examples
AWS Elastic Load Balancer (ELB)
Google Cloud Load Balancer
Azure Load Balancer
Cloudflare Load Balancing
📈 Why Use a Load Balancer?
Benefit Description
High
If one server fails, others take over
availability
Scalability Easily add/remove servers as needed
Performance Reduces server response time
Can hide real server IPs and prevent
Security
direct attacks
🧪 Simple Use Case Example
Let’s say you run an online store with 3 web servers:
1. A user opens your website
2. The load balancer picks one of the 3 servers (e.g. using round robin)
3. That server handles the request and sends back the page
4. If one server crashes, the load balancer sends future users to the
remaining 2
If you want, I can show you:
How to set up a basic NGINX load balancer
Compare AWS vs. GCP load balancers
Use load balancing with containers (Docker/Kubernetes)
What are you working on?