All guides
Home Glossary Load balancer
Term

Load balancer

A device or software that distributes incoming network traffic across a group of backend servers to optimize resource utilization and ensure high availability.

A load balancer is a hardware appliance or software service that sits in front of a group of backend servers and distributes incoming network traffic across them to optimize resource utilization and ensure high availability. Acting as a reverse proxy, it prevents any single machine from becoming a bottleneck or a single point of failure when traffic spikes.

How it works

When a client sends a request, the load balancer intercepts it, selects a healthy backend node from its target pool, and forwards the traffic. To keep the pool reliable, it runs continuous health checks—sending periodic pings or HTTP probes to each server. If a node stops responding or returns errors, the balancer automatically removes it from rotation until it recovers.

Routing decisions depend on the configured distribution algorithm and the OSI layer at which the balancer operates:

  • Layer 4 (Transport): Routes packets based on IP address and TCP/UDP port without inspecting the payload, offering low latency and high throughput.
  • Layer 7 (Application): Inspects HTTP headers, cookies, and URL paths to make content-aware routing decisions, such as sending API calls to one server cluster and static assets to another.
  • Common algorithms: Round Robin cycles through servers sequentially, Least Connections directs traffic to the node handling the fewest active sessions, and IP Hash (Source IP Affinity) maps a client IP consistently to the same backend server.

Modern load balancers such as NGINX, HAProxy, and AWS ELB also handle SSL/TLS termination, decrypting incoming HTTPS traffic at the edge so backend servers can focus on application logic rather than cryptographic overhead.

Example

Below is a minimal NGINX configuration distributing HTTP traffic across three application servers using the least_conn algorithm:

upstream app_backend {
    least_conn;
    server 10.0.1.11:8080 max_fails=3 fail_timeout=15s;
    server 10.0.1.12:8080 max_fails=3 fail_timeout=15s;
    server 10.0.1.13:8080 max_fails=3 fail_timeout=15s;
}

server {
    listen 80;
    server_name example.com;

    location / {
        proxy_pass http://app_backend;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

In this setup, if any upstream server fails three consecutive connection attempts within 15 seconds, NGINX marks it unavailable and routes requests exclusively to the remaining healthy nodes.

What matters when choosing a server or hosting

Whether you deploy a self-managed proxy on a VPS or use a managed cloud service, evaluate these infrastructure factors:

  • Network bandwidth and NIC speed: Every incoming and outgoing byte passes through the balancer. Unmetered or high-throughput network interfaces prevent the proxy itself from saturating its link.
  • Low-latency private networking: Keep the load balancer and backend nodes inside the same data center or VPC over private IPs to minimize internal hop latency and avoid public bandwidth charges.
  • CPU performance for TLS: If the balancer terminates HTTPS connections, prioritize modern processors with hardware AES acceleration.
  • Redundancy options: A single balancer still creates a single point of failure. Look for hosting providers that support floating IPs, BGP anycast, or active-passive failover pairs.

Common mistakes

  • Storing local session state: Saving user sessions in local server memory breaks user logins when requests bounce between nodes. Store session data in a shared datastore like Redis instead of relying solely on sticky sessions.
  • Using superficial health checks: Checking only whether TCP port 80 is open can route traffic to an app whose database connection is dead. Configure a dedicated /health endpoint that verifies critical dependencies.
  • Forgetting forwarded headers: Without passing X-Forwarded-For and X-Forwarded-Proto, backend logs record only the balancer's internal IP, which can interfere with rate limiting and access controls.
  • Ignoring upstream DNS and connection overhead: High-frequency automated clients can overwhelm backend pools if upstream targets are resolved repeatedly; optimizing connection reuse alongside techniques covered in our guide on IP Caching for Web Scrapers: 87% Faster Speeds, Lower Load & Real Numbers helps keep infrastructure strain low.

FAQ

What is the difference between a load balancer and a reverse proxy?

A reverse proxy sits in front of one or more servers to handle tasks like caching, compression, and TLS termination. A load balancer is a specialized reverse proxy focused specifically on distributing traffic across multiple backend servers and monitoring their health.

When should I use Layer 4 instead of Layer 7 load balancing?

Use Layer 4 when you need raw packet-forwarding speed, handle non-HTTP protocols like raw TCP or game traffic, or want end-to-end TLS passthrough. Choose Layer 7 when you need URL-based routing, header inspection, or web application firewall rules.

Can a load balancer itself become a single point of failure?

Yes. In production environments, teams deploy load balancers in high-availability pairs using protocols like VRRP with a floating virtual IP, or rely on multi-zone managed cloud balancers that automatically fail over across data centers.

All glossary terms

Glossary

Related terms

Full glossary

New guides every week.

A digest of the best pieces on servers, VPN and self-hosted software. No ads, no spam.

1 email a weekOne-click unsubscribeRU · EN
Only slipjar.app articles, nothing else.