Load Balancer
What Is a Load Balancer?
A load balancer is software, hardware, or a cloud service that distributes incoming application traffic across multiple healthy servers. It keeps websites, APIs, and web applications responsive when demand rises or a server fails. Clients connect to one public virtual endpoint, while the load balancer routes each connection or request to a backend server pool. Load balancing is the practice, while a load balancer is the component that performs it.
How Does a Load Balancer Work?
What does a load balancer do? It accepts traffic, selects an available backend target, and avoids targets that fail health checks.
- A client sends a request to the application's public address.
- The load balancer identifies eligible servers in its target pool.
- It applies a routing rule or algorithm to select a server.
- It forwards the connection or request to that server.
- It removes unhealthy targets until they pass health checks again.
Layer 4 vs. Layer 7 Load Balancing
The right layer depends on whether the application needs fast connection forwarding or detailed request-aware routing.
| Type | Routes using | Best for | Trade-off |
|---|---|---|---|
| Layer 4, often called NLB | IP address, port, and protocol | High-throughput TCP or UDP traffic | Less visibility into HTTP requests |
| Layer 7, often called ALB | Hostnames, paths, headers, and cookies | Websites and APIs needing content-based rules | More processing, including common TLS termination |
An ALB is Layer 7. An NLB can be faster because it makes decisions from network connection details rather than inspecting application requests.
Common Load-Balancing Algorithms and Session Handling
| Method | How it routes traffic | Useful when |
|---|---|---|
| Round robin | Cycles through servers in order | Servers have similar capacity |
| Weighted round robin | Sends more traffic to higher-capacity servers | Server capacity differs |
| Least connections | Chooses the server with fewer active connections | Requests vary in duration |
| IP hash or sticky sessions | Keeps a user on one server | A legacy app stores session data locally |
Sticky sessions can create uneven load. Shared session storage is usually a stronger long-term design.
Benefits of Load Balancing
Load balancing supports reliable growth without directing all traffic to one machine.
- Improves availability by routing around a failed application instance.
- Supports horizontal scaling by adding or removing servers.
- Enables safer maintenance through connection draining.
- Creates more consistent response times during traffic spikes.
Practical Limits and Configuration Risks
A load balancer improves traffic distribution, but it cannot repair every performance problem.
- It cannot fix slow code, database bottlenecks, or failing downstream services.
- Poor health checks may mark a broken server as healthy.
- The load balancer itself needs redundancy, monitoring, and careful TLS configuration.
- Long-lived connections can make simple algorithms appear balanced when they are not.
Using Load Balancers in Modern Web Applications
Cloud deployments commonly place a load balancer in front of containerized services, APIs, and autoscaling server groups. An AI web app builder can help create and deploy an application, while production traffic still needs reliability planning. Explore app design and development guidance and the wider Emergent glossary when designing scalable systems.
on Emergent today

