What is Load Balancing?
Load balancing distributes incoming requests across two or more servers so no single machine carries all the traffic. The balancer picks a server with an algorithm such as round robin or least connections, probes each one with health checks, and pulls a failed server out of rotation automatically, so one failure does not take the site down.
For growing sites and developers deciding whether one server is still enough, and how a load-balanced setup routes, checks and fails over.
knowledge
- Read time
- 4 min
- Sections
- 7
- Updated
- 14 Nov 2026
- Written by
- WebJi® team
Last editorial update: 14 November 2026. Prices follow the dated sources on this page; checkout confirms current charges.
What is load balancing?
Load balancing spreads incoming requests across two or more servers so no single machine carries all the traffic, and removes a failed server from rotation automatically so its failure becomes a routing change rather than an outage. Think of the attendant at a toll plaza waving each vehicle to the shortest lane.
- Distribution: an algorithm such as round robin or least connections picks the server for each request.
- Health checks: the balancer probes each backend and stops sending traffic to one that fails.
- Failover: the remaining servers absorb the failed server's share.
- One address: visitors reach a single IP or hostname; the pool behind it can grow or shrink.
Most sites meet load balancing at a threshold: a sale-day spike, a server that cannot keep up, or a requirement that the site survive one machine failing.
Which load balancing algorithms are used?
Algorithms are either static, handing out work on a fixed plan without looking at server state, or dynamic, checking each server's current load first. Static rules are simpler; dynamic rules adapt when one server slows down.
| Algorithm | Type | Rule | Best when |
|---|---|---|---|
| Round robin | Static | Each request goes to the next server in turn | Identical servers, short requests |
| Weighted round robin | Static | Higher-weight servers get a bigger share | Mixed hardware in one pool |
| IP hash | Static | A hash of the client IP picks the server | Keeping a visitor on one server without cookies |
| Least connections | Dynamic | The server with the fewest open connections wins | Requests of uneven length |
| Least response time | Dynamic | The server answering fastest recently wins | Pools with uneven performance |
How do health checks and failover work?
A health check is a periodic probe — an HTTP request to a status URL, a TCP connect, or watching live traffic for errors — and a server that fails it stops receiving new requests until it passes again.
Active checks test each server on a schedule before traffic arrives. Passive checks mark a server down when real connections start failing. Either way, visitors see no error page; the pool simply shrinks by one and rejoins the server once it recovers. Make the status endpoint check the things that matter, such as the database connection, or a server can look "healthy" while serving errors.
What is the difference between Layer 4 and Layer 7 load balancing?
A Layer 4 balancer routes by IP address and port without reading the request, while a Layer 7 balancer reads HTTP — URLs, headers and cookies — and can route by content.
- Layer 4 (transport): fast and protocol-agnostic; suits plain TCP services, databases and very high throughput.
- Layer 7 (application): can send
/api/to one pool and/images/to another, terminate HTTPS, add headers and keep carts sticky.
Most web applications want Layer 7, because the routing intelligence is the feature; the speed difference rarely decides anything at the scale where balancing begins.
What does a simple Nginx load balancer look like?
Open-source Nginx balances HTTP traffic with an upstream block listing the backend servers and a proxy_pass that sends requests to it. This example uses least connections, marks a server down after three failures in 30 seconds, and keeps a backup server in reserve.
upstream app_pool {
least_conn;
server 10.0.0.11:80 max_fails=3 fail_timeout=30s;
server 10.0.0.12:80 max_fails=3 fail_timeout=30s;
server 10.0.0.13:80 backup;
}
server {
listen 80;
server_name example.in;
location / {
proxy_pass http://app_pool;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Open-source Nginx performs passive health checks through max_fails; scheduled active checks need NGINX Plus or a tool such as HAProxy. Test with sudo nginx -t before sudo systemctl reload nginx. The same proxy pattern in front of Apache is shown in Nginx reverse proxy for Apache.
How do carts and logins work behind a load balancer?
Carts and logins break when each request lands on a different server that does not share session data, so either pin each visitor to one server (sticky sessions) or store sessions where every server can read them.
Sticky sessions use an affinity cookie or the IP hash rule. The cleaner long-term fix is a shared session store such as Redis or the database, plus shared or synced file uploads, so any server can serve any user. WordPress and WooCommerce also need the same wp-content/uploads on every node. How servers are grouped for this is covered in what is server clustering.
How is a load balancer different from a CDN or a cache?
A CDN serves cached static files from edges near users, a cache stores computed pages so they are not rebuilt, and a load balancer decides which origin server handles whatever traffic is left. Large sites run all three together.
| Layer | What it does | Where it runs |
|---|---|---|
| Load balancer | Chooses which server handles each request | In front of your server pool |
| CDN | Serves cached static files near the visitor | A global edge network |
| Cache | Stores computed responses to avoid rebuilding them | On each server or in a shared store |
The edge layer is explained in what is a CDN.
When does an Indian business actually need load balancing?
You need load balancing when one well-sized server can no longer handle peak traffic, or when the site must stay up if a single server fails; if the workload fits one machine, a larger server is cheaper and simpler.
Signs include response times climbing at every peak, a campaign or sale flattening the site, and maintenance windows customers will not accept. First try caching and a larger machine: WebJi® cloud servers start at 2 vCPU and 8 GB RAM for ₹5,900 a month before 18% GST (published pricing; checkout confirms). A multi-server, load-balanced setup is designed and quoted by email at support@webji.services before any payment. The single-server options are compared in cloud vs VPS.
Frequently asked questions
Is DNS round robin the same as load balancing?
It is a crude form. Publishing several A records spreads visitors between servers, but DNS does not check health, so a dead server keeps receiving its share until you remove the record and caches expire. A real balancer reacts in seconds.
Is the load balancer itself a single point of failure?
It can be. Production setups run two balancers sharing a floating IP (for example with keepalived), or use a provider's managed balancer that is redundant by design, so losing one balancer does not take the site down.
Can I load balance a WordPress site?
Yes, but every node needs the same code, a shared database, shared uploads and a shared object cache such as Redis. Most WordPress sites get further with page caching and a stronger single server before adding nodes.
Where does SSL go in a load-balanced setup?
Usually on the Layer 7 balancer, which decrypts HTTPS once and forwards requests to the backends over a private network. Pass the X-Forwarded-Proto header so the application knows the visitor used HTTPS.
Checked against Nginx documentation, 14 November 2026 · Reviewed by the WebJi® team, Jaipur.
Ready to get started with WebJi®?
Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.