Skip to content

Load Balancers & Proxies

  • Load Balancer — Distributes incoming traffic across multiple servers
  • Forward Proxy — Sits in front of clients (hides the client from the server)
  • Reverse Proxy — Sits in front of servers (hides servers from the client)
flowchart TB
subgraph Clients[Clients]
U1[User 1]
U2[User 2]
U3[User 3]
end
subgraph LB[Load Balancer / Reverse Proxy]
LBR[Distributes traffic<br/>Round-robin, least connections]
end
subgraph Servers[Backend Servers]
S1[Server 1]
S2[Server 2]
S3[Server 3]
end
subgraph Database[Database]
DB[(Database)]
end
U1 --> LBR
U2 --> LBR
U3 --> LBR
LBR --> S1
LBR --> S2
LBR --> S3
S1 --> DB
S2 --> DB
S3 --> DB
style Clients fill:#3b82f6,color:#fff
style LB fill:#7c3aed,color:#fff
style Servers fill:#10b981,color:#fff
style Database fill:#f59e0b,color:#fff

A load balancer distributes incoming requests across multiple servers so no single server gets overwhelmed.

Load balancing algorithms:

Terminal window
Round Robin → Request 1 → Server A, Request 2 → Server B, Request 3 → Server C...
Least Connections → Send to server with fewest active connections
IP Hash → Same user always goes to the same server (session persistence)
Weighted → More powerful servers get more traffic

Why use a load balancer?

  • Scalability — add more servers as traffic grows
  • High availability — if one server fails, traffic goes to the others
  • SSL termination — decrypt HTTPS at the load balancer (less work for servers)

A forward proxy sits between the client and the internet:

Client → Forward Proxy → Internet → Server

Used for:

  • Anonymity — hides the client’s IP from the server
  • Bypassing restrictions — access blocked websites
  • Content filtering — schools/corporations block certain sites
  • Caching — serve frequently accessed content faster

A reverse proxy sits between the internet and your servers:

Internet → Reverse Proxy → Server

Used for:

  • Load balancing — distribute traffic
  • Caching — cache responses to reduce server load
  • SSL termination — handle HTTPS at the proxy
  • Security — hide internal server details
  • Rate limiting — prevent abuse

Common tools:

ToolWhat it does
NginxWeb server + reverse proxy + load balancer
HAProxyHigh-performance load balancer
CloudflareCDN + reverse proxy + DDoS protection
TraefikModern reverse proxy (great for containers)

Forward ProxyReverse Proxy
HidesThe client (you)The server
KnowsWho the client isWho the server is
Used byClients (users)Server owners
ExampleVPN, corporate proxyNginx, Cloudflare

  • A load balancer spreads traffic across multiple servers for scalability and reliability
  • A forward proxy sits in front of clients (hides the user — like a VPN)
  • A reverse proxy sits in front of servers (hides the server — like Cloudflare)
  • Load balancers use algorithms like round-robin and least connections
  • Common tools: Nginx (reverse proxy), HAProxy (load balancer), Cloudflare (CDN + proxy)