Skip to content

What Is a Load Balancer? Definition and Examples

Quick answer

A load balancer spreads incoming requests across servers and stops using one that fails its health checks. A plain definition, a three-server trace and a Python sketch.

What Is a Load Balancer? Definition and Examples

A load balancer is a system that sits in front of several servers and spreads incoming requests across them. It checks which servers are healthy and stops sending traffic to one that has failed, so users keep getting a response even when a single machine goes down.

Key takeaways

  • A load balancer is a traffic router in front of two or more servers.
  • Health checks are how it learns that a server is down and takes it out of rotation.
  • Round robin sends requests in turn; least connections favours the least busy server.
  • One server with low traffic does not need a balancer. Two or more servers usually do.

On this page:

TermWhat it doesExample
Load balancerSpreads requests across servers and skips unhealthy onesThree app servers behind one address
Reverse proxyReceives requests on behalf of servers; may also cache or add securityA proxy that forwards to one app server
Auto scalingAdds or removes servers as demand changesStarting two more servers at peak time
FailoverSwitches to a standby when the main system failsA backup database taking over

What is a load balancer?

It is the single front door for a group of servers. According to Amazon Web Services, its Elastic Load Balancing service automatically distributes incoming application traffic across multiple targets and virtual appliances. Users talk to one address, and the balancer decides which server handles each request.

This gives you two things. Work is shared, so no single machine is overloaded. And if a server fails, the others carry on.

How does a load balancer know a server is down?

It sends health checks. Cloudflare's documentation explains that a monitor issues health monitor requests at regular intervals to evaluate the health of each endpoint within a pool, and that when a pool becomes unhealthy, the load balancer takes it out of the endpoint rotation.

The check can be simple. For an HTTP or HTTPS check, Cloudflare says no response within the configured timeout and retries is considered unhealthy. For a TCP check, the monitor sends a TCP SYN to the specified port and needs a SYN/ACK to succeed.

Illustrative trace (made-up rule, not a vendor default). Mark a server unhealthy after 3 failed probes in a row, and healthy again after 2 good probes. With round robin, six requests go to servers A, B, C, A, B, C. Then B fails its checks:

RequestB healthyB unhealthy
1AA
2BC
3CA
4AC
5BA
6CC

Round robin is easy to sketch in Python. This runs as shown and prints which server gets each request.

from itertools import cycle

servers = ["server-A", "server-B", "server-C"]
rotation = cycle(servers)

for request_id in range(1, 7):
    print(f"request {request_id} -> {next(rotation)}")

Least connections is a different rule: each new request goes to the server with the fewest active connections. It helps when some requests take much longer than others.

Where are load balancers used in India?

Anywhere traffic arrives in waves. Picture an online admissions portal on the last day of the form, a made-up scenario. With two app servers behind a balancer, one can crash and the form stays open. Without one, the same crash ends the day for every applicant.

Balancers also let teams deploy without downtime: take one server out, update it, put it back, then repeat for the next. Cloud providers sell them as managed services, so you rarely install one yourself.

Checklist: do you need one?

  • One server and low traffic: no balancer needed yet.
  • Two or more servers: a balancer helps share load and survive a failure.
  • You need zero-downtime deploys: a balancer helps.

What are the common mistakes and confusions?

The first is thinking a balancer removes every single point of failure. The balancer itself can fail, so production setups run it redundantly. The second is weak health checks. If the check only tests that a port is open, a server whose app is broken may still look healthy.

Third, people mix up layers. Some balancers route on connection details such as IP address and port. Others read the request, such as the URL or headers, and route on that. Pick based on what your routing needs.

Look at Docker, Kubernetes and serverless to see where balancing sits in container setups, and Docker for beginners for the packaging side. For the bigger picture, see the system design roadmap.

Next step

Run the Python sketch, then change the list to two servers and remove one by hand to mimic a failure. When you are ready to go further, follow the cloud engineer roadmap or the backend developer roadmap.

Frequently asked questions

What is a load balancer in simple words?

It is a traffic router in front of several servers. It receives each request and passes it to one healthy server, so no single machine is overloaded and users still get answers if one fails.

How does a load balancer know a server is down?

It sends health checks at regular intervals. If a server gives no response within the configured timeout and retries, it is treated as unhealthy and taken out of rotation until it passes again.

What is the difference between round robin and least connections?

Round robin sends requests to servers in turn. Least connections sends each new request to the server with the fewest active connections, which suits requests that take very different amounts of time.

Do I need a load balancer for a small website?

Usually not. One server with low traffic works without one. Once you run two or more servers, or want updates without downtime, a load balancer becomes useful.

Is a load balancer the same as a reverse proxy?

They overlap but are not the same. A reverse proxy receives requests for servers behind it. A load balancer adds the job of spreading requests across several servers and checking their health.

Share LinkedIn X WhatsApp
×

Our Courses

Practice-Based Learning Tracks, Supercharged By A.I.