Skip to main content
Glossary

Load Balancer

A device or software that distributes incoming network traffic across multiple servers to ensure no single server becomes overwhelmed.

Detailed Explanation

A load balancer sits between clients and servers, routing each request to the server best equipped to handle it. This prevents any single server from becoming a bottleneck and ensures high availability—if one server fails, the load balancer stops sending traffic to it.

Common load balancing algorithms include round-robin (rotate through servers), least connections (send to the server with fewest active connections), IP hash (route based on client IP for session persistence), and weighted (distribute based on server capacity). Load balancers operate at Layer 4 (TCP/UDP) or Layer 7 (HTTP), with L7 providing more intelligent routing based on content.

Why It Matters

Load balancers are essential for scaling any application beyond a single server. They ensure high availability, improve performance, and enable horizontal scaling.

Real-World Example

A popular API sits behind an AWS Application Load Balancer that distributes requests across 10 EC2 instances. If one instance crashes, the load balancer routes traffic to the remaining 9 with no user-visible impact.

When to Use

When you have more than one server handling traffic, need high availability, or want to scale horizontally. Even single-server apps should consider a load balancer for SSL termination and health checks.

Advantages

  • Distributes traffic evenly across servers
  • Provides high availability and failover
  • Enables horizontal scaling
  • SSL termination offloads servers
  • Health checks detect and remove failed servers

Disadvantages

  • Adds a potential single point of failure
  • Can introduce latency if misconfigured
  • Session persistence requires careful configuration
  • Costs for managed load balancers
  • Complex routing rules can be hard to debug

Frequently Asked Questions

What is the difference between Layer 4 and Layer 7 load balancing?

Layer 4 (TCP/UDP) routes based on IP and port—faster but less flexible. Layer 7 (HTTP) routes based on content (URL, headers, cookies)—more intelligent but slower. Use L7 for content-based routing; L4 for raw performance.

What is a reverse proxy?

A reverse proxy sits in front of servers and forwards client requests. Load balancers are a type of reverse proxy that distributes traffic. Other reverse proxy functions include SSL termination, caching, and security.

How do I handle session persistence with a load balancer?

Use sticky sessions (IP hash or cookie-based) to route the same user to the same server. Better: store sessions in a shared store (Redis) so any server can handle any request.

Do I need a load balancer for a small app?

For a single-server app, you may not need load balancing. However, a load balancer (or reverse proxy like NGINX) still provides SSL termination, health checks, and makes future scaling easier.

What is a health check?

A health check is a periodic test that verifies a server is running and responsive. The load balancer stops sending traffic to servers that fail health checks, ensuring users are only routed to healthy instances.

Back to Glossary

Browse all terms in our software development glossary.

Browse All Terms