Load balancing means putting a load balancer (nginx, HAProxy or a cloud service) in front of two or more servers that run the same site. It spreads incoming requests across them and takes a failed server out of rotation. It pays off when one server can no longer handle peak load or the site has to stay up during restarts and updates. For a small site that runs fine on a hosting plan, it is usually unnecessary.
Below you will find the four common distribution methods with their names in nginx and HAProxy, the session problem, a decision table and the prices of managed load balancers, which we checked on the providers’ pages on 30.10.2026.
What load balancing is and when you need it
Load balancing is the distribution of incoming requests across several servers. When everything goes through one server, that server is a single point of failure: at peak load requests queue up and time out, and visitors see a 503 Service Unavailable error or a 504 Gateway Timeout. If the server fails or has to restart, the site is down.
You set up a load balancer where you run your own servers: VPS, dedicated servers or cloud instances. On shared hosting you do not configure a balancer yourself, the provider takes care of the servers. When a plan is no longer enough, the usual next step is a VPS or a dedicated server, and only after that several servers behind a balancer.
Four distribution methods worth knowing
- Round Robin: the balancer sends requests in turn: the first to server A, the second to B, the third to C. It fits when the servers have roughly equal capacity. In nginx it is the default when no method is specified. In HAProxy
roundrobinwas the default up to version 3.2; from version 3.3 the default israndom. - Least Connections: the request goes to the server with the fewest active connections. If A is serving 10 users and B only 5, the new request goes to B. In nginx this is
least_conn, in HAProxybalance leastconn. - IP Hash: a user always lands on the same server based on their IP address. Useful for server-side cache and sessions. In nginx this is
ip_hash(the key is the first three octets of an IPv4 address or the whole IPv6 address), in HAProxybalance source. - Weighted distribution: a more powerful server gets more requests. Worked example: with
weight=3for A andweight=2for B, about 60% of requests go to A and 40% to B. In nginx the default weight is 1, and weights can also be combined withleast_connandip_hash.

Each method has its place. Round Robin suits simple static sites, Least Connections suits applications with sessions of varying length, IP Hash suits cache and sessions, and weighted distribution suits servers with different hardware.

How it works in practice
The load balancer sits in front of the servers: nginx, HAProxy, a dedicated appliance or a cloud service. It accepts every incoming request and decides which backend server gets it.
What matters is what happens when a server fails. Open source nginx checks passively: if a request to a server fails, nginx marks it as unavailable and avoids it for a while. The defaults are max_fails=1 and fail_timeout=10s, after which nginx carefully tries the server again with live requests. Active periodic health checks in nginx are part of the commercial subscription. In HAProxy you enable checks with the check parameter on each server line: a server that does not accept a TCP connection is taken out of rotation.
What changes with several servers, without invented benchmarks:
| Aspect | One server | Several servers behind a balancer |
|---|---|---|
| One server fails | Site is down | The remaining servers keep serving, as long as they have enough capacity |
| Restart or update | Downtime | Take servers out of rotation one at a time |
| Peak load | Limited by one machine | Add servers to the pool |
| Effort | One configuration | Sessions, uploaded files, the database and the balancer itself need planning |
| Single point of failure | The server | The balancer, unless it is redundant or managed |
Whether three small servers are faster than one large one depends on your application, and we did not measure it for this article. Check it yourself: run a load test (for example with k6, wrk or ab) against a test copy of the site, increase the number of concurrent connections until the 95th percentile response time or the error rate starts to climb, and compare both setups under the same load. Keep an eye on the database: if all web servers share one database, it often becomes the bottleneck.
Sessions: where load balancing gets tricky
Here is the trap. A user logs in on server A, and their session data is stored there. On the next request the balancer sends them to server B. There is no session there, and the user sees the login page again.
This is the sticky sessions problem. There are several ways to solve it:
- Shared session storage (Redis, Memcached): the session is stored not on the application server but on a separate cache server that all backends can see.
- IP Hash in the balancer: the user always goes to the same server. According to the nginx documentation this holds only while that server is available. If it fails, the request goes to another server and the session is lost.
- Data in a cookie or JWT token: the session travels with the user, whichever server they are sent to.
The first option is the most reliable, because no single server holds a session exclusively. Redis keeps the data in memory and is widely used for this job. Still, measure its response time during your load test.

What a managed load balancer costs
Cloud platforms offer load balancers as a service. List prices excluding taxes and backend servers, checked on 30.10.2026:
| Provider | Product | List price | Note |
|---|---|---|---|
| DigitalOcean | Regional Load Balancer | from $12 per month | According to the provider, each node adds 10,000 requests per second, 10,000 simultaneous connections and 250 SSL connections per second |
| Hetzner Cloud | LB11 | EUR 7.49 per month (EUR 0.0120 per hour) | Up to 5 services and 25 targets |
| AWS | Application Load Balancer, US East (N. Virginia) | $0.0225 per hour, about $16.43 for 730 hours, plus $0.008 per LCU-hour | Each partial hour is billed as a full hour |
On top of that come at least two backend servers and the work of keeping them in sync. Your own nginx or HAProxy on a small VM costs only the VM, but then it is a single point of failure itself until a second balancer stands by. When the load grows, you add a server to the pool: in nginx another server line in the upstream block, in the cloud another target.
Load balancing is one of the building blocks of scalable corporate hosting, next to a hot standby server that takes over when the main one fails.
Decision table
| Situation | What to do |
|---|---|
| The site runs on a hosting plan and response times stay good at peak hours | No balancer needed. Keep measuring regularly |
| One server is overloaded at peak hours | First caching and optimization, then a stronger server, then several servers |
| Updates without downtime are a must | Two servers behind a balancer with health checks |
| Logged-in users, shopping carts, uploads | First set up shared session and file storage, then add servers |
| Tight budget, your own VMs | A managed balancer from the price table, or nginx/HAProxy on a VM, with the balancer’s own failure risk planned for |
For most small and medium sites the first step is not load balancing but caching: our article on why your WordPress is slow shows where to start. On shared hosting the provider takes care of the servers. RichHost hosting plans start at $8 per month, with NVMe storage and servers in Europe and the USA.
How we checked: we did not run our own load test for this article. Distribution methods and defaults come from the nginx documentation (Load Balancing, ngx_http_upstream_module) and the HAProxy documentation on backends, prices from the DigitalOcean, Hetzner and AWS pages. Checked on 30.10.2026. Prices change, so check the provider’s page before you buy. The 3:2 weights are a worked example, not a measurement.
FAQ
Do I need load balancing on shared hosting?
No. On shared hosting you do not configure a balancer, the provider takes care of the servers. You set up load balancing when you run your own servers.
Which method should I start with?
Round Robin if the servers have equal capacity, or Least Connections if requests vary a lot in duration. More important than the method is moving sessions and uploaded files to shared storage first.
Is IP Hash enough for sessions?
Only partly. The user stays on their server as long as it is running. If it fails, the request lands elsewhere and the session is lost. Also, in nginx all users with the same first three octets of an IPv4 address land on the same server.
How much does a load balancer cost?
According to list prices checked on 30.10.2026, from EUR 7.49 per month (Hetzner LB11) or from $12 per month (DigitalOcean); AWS bills per hour plus LCU. Backend servers come on top.



