What is a load balancer? Explained with a restaurant host seating diners
A load balancer passes each visitor to a server that is working and has room. Like a restaurant host seating diners across open tables so no waiter is swamped.
- Author
Umair Mateen- Published
- Reading time
- 5 min
- Category
- DevOps
In one sentence: A load balancer is a service that sits in front of a group of servers and passes each visitor's request to a server that is working and has room, so no single server is overwhelmed and the site keeps running if one fails.
The everyday picture
Think of a busy restaurant with a host at the door. Diners do not walk in and pick any table they like. They stop at the host stand first.
The host knows which tables are free, which waiters are busy and which tables are closed for cleaning. They seat each new group where it will be served quickly. When one area is full, the next group goes somewhere else.
A load balancer is that host. Your website's visitors are the diners. Your servers are the tables. The visitors only ever see the front door, never the seating plan.
Every visitor stops at the load balancer first. It seats them at a working server, and both servers order from the same kitchen, so any table gives the same meal.
How it works, step by step
- Visitors arrive at one address (diners come to the front door). Your website has a single web address, and every request goes to the load balancer (the host) first, not straight to a server.
- The load balancer checks which servers are healthy (the host checks which tables are open). It sends small test requests, called health checks, to each server on a regular schedule. A server that keeps failing them is marked unhealthy.
- It picks a server using a rule (the host's seating plan). A simple rule is round robin: take turns, one server after another. Other rules send the request to the server with the fewest open connections or the quickest replies.
- The server handles the request (the table is served). All servers usually share the same database (one kitchen), so it does not matter which one a visitor lands on.
- If a server fails, traffic moves (a table closes, guests go elsewhere). Unhealthy servers stop getting new visitors. Once a server passes its checks again, the load balancer starts sending it visitors again.
Try it · Myth or fact
Load balancers: myth or fact?
Decide for yourself first, then tap each statement to check it.
0 of 4 checked
Where the picture stops
- A host seats a few groups a minute. A load balancer routes requests in a fraction of a second, and cloud load balancers can add capacity on their own as traffic grows.
- A restaurant has one door. A load balancer can itself be spread across several locations, such as different data centres, so it is not a single weak point. In a simple setup, though, it can be one.
- Diners usually stay at one table for the whole meal. On the web, each click can be a new request that lands on a different server, which is why servers should keep shared information in the database, not in their own memory.
Why it matters for your business
- Fewer outages: if one server crashes or is being updated, visitors are sent to the others. AWS lists availability as a main benefit: load balancers detect server problems and redirect traffic.
- Room to grow: you can add more servers behind the same address when traffic rises, which is how scaling out works in practice.
- Steadier speed: spreading the work stops one server from slowing down while others sit idle, so pages load more evenly for customers.
- Safer updates: your team can take servers out one at a time to update them, without taking the whole site offline.
An example
Imagine a regional online ticket seller. Most days, two servers handle its traffic easily. When tickets for a popular concert go on sale, visits jump sharply for an hour.
A load balancer sits in front of its servers. Before the sale, the team adds two more servers behind it. Buyers still go to the same web address, and the load balancer spreads them across all four. Midway through, one server freezes. Its health checks fail, the load balancer stops sending it buyers, and the other three carry on while the team restarts it.
Frequently asked questions
Do I need a load balancer for a small website?
Not always. A site running on a single server has nothing to balance. A load balancer becomes useful once you run two or more servers, for more capacity or so the site stays up if one fails.
What is a health check?
It is a small, regular test request the load balancer sends to each server. If a server fails enough checks in a row, it is marked unhealthy and stops receiving new visitors until it recovers.
Is a load balancer the same as a CDN?
No. A CDN keeps copies of your content close to visitors around the world. A load balancer shares live requests across your own servers. Many sites use both.
What does round robin mean?
It is the simplest way to share requests: each new request goes to the next server in the list, in turn. It works well when all servers are similar and requests take about the same effort.
Related explainers
The DevDrift sets up cloud hosting and deployments for web platforms: see how.
Sources
Could you explain this to a colleague now?
Mark it and posts that mention it will show a tick. Saved in this browser only.