Skip to content
Reviewed by Bipeen Sinha Sep 29, 2026

Home › Guides › What is load balancing

Tech Explained · 2026

What Is Load Balancing? How It Works, 6 Algorithms and Load Balancer vs Reverse Proxy in 2026

Load balancing is the practice of spreading incoming network requests across several backend servers so no single machine becomes a bottleneck or a single point of failure. A load balancer sits in front of your servers, checks which ones are healthy, and forwards each request to one of them. AWS pulls a failing target after two consecutive failed health checks.

29 September 20269 min readBy the 360 Digital Transformation Editorial Team
Key takeaways
  • Load balancing is a routing decision, not a speed trick. It spreads requests across servers that can already handle them, and does nothing for a slow query.
  • Health checks matter more than the algorithm. AWS target groups default to a 30 second probe and a healthy threshold of 5, so a fresh server waits about 150 seconds for traffic.
  • Layer 4 forwards packets, Layer 7 reads requests, and a load balancer is not a reverse proxy, even when the same Nginx binary does both jobs on one box.
  • Managed wins for most small teams: roughly $0.0225 per ALB hour plus $0.008 per LCU hour in US East (Ohio).
  • Sticky sessions are a workaround. Nginx only opened cookie based persistence in 1.29.6, and needing it means your app keeps state in the wrong place.
  • Six algorithms exist. Two cover almost everything: round robin and least connections.

Your Django API runs fine on one EC2 box until the Monday dispatch rush, and then response times triple and someone in sales asks why the app is slow again. So you launch a second server. Now you have a different problem: nothing is sending traffic to it. That gap, between having capacity and using it, is the whole job of a load balancer.

Keep one picture in your head throughout. A two person platform team at a Pune logistics SaaS runs a Django API peaking near 400 requests per second between 9 and 11 AM: two app servers, one Postgres primary, one deploy a week. That is the size at which this stops being theory.

How Load Balancing Actually Works

A load balancer owns the public address your users hit, so nothing reaches your app servers directly. It picks a backend for each request in four steps, and only the third is the part people talk about:

  1. Accept the connection. Your DNS name resolves to the balancer, not a server, which is why swapping backends needs no client side change.
  2. Consult the health table. Backends that failed their last probe are not candidates.
  3. Apply the algorithm, chosen from the healthy list only.
  4. Proxy the response back. The client never learns which server served it unless you leak that in a header.

Step two causes outages. A balancer with a perfect algorithm and a broken health check sends every request to a dead box.

What happens to one request

The health table is consulted before the algorithm, which is why a failing server disappears with no code change.

How a load balancer routes one request to a healthy backend Clients send a request to a load balancer. The balancer consults a health table, applies an algorithm, and forwards the request to one of two healthy app servers. A third server that failed two health checks is skipped. Clients browser, app, API Load balancer 1. health table 2. algorithm App server 1 healthy, 14 open connections App server 2 healthy, 9 open connections App server 3 failed 2 checks, not a candidate request forward least connections wins skipped health probe every 30 s, GET / expecting 200

Probe interval and threshold values are the documented AWS target group defaults, checked 29 September 2026.

The worked example: three backends on your laptop

Do this before touching a cloud console. Start three trivial backends, each serving one file naming its port:

mkdir -p /tmp/lb/{8001,8002,8003}
for p in 8001 8002 8003; do
  echo "served by $p" > /tmp/lb/$p/index.html
  (cd /tmp/lb/$p && python3 -m http.server $p) &
done

Now put Nginx in front. The upstream block is the whole idea: a named pool plus one directive picking the algorithm. least_conn has been in Nginx since 1.3.1, per the official ngx_http_upstream_module reference.

upstream dispatch_api {
    least_conn;
    server 127.0.0.1:8001 weight=2 max_fails=2 fail_timeout=10s;
    server 127.0.0.1:8002 max_fails=2 fail_timeout=10s;
    server 127.0.0.1:8003 max_fails=2 fail_timeout=10s backup;
}

server {
    listen 8080;
    location / {
        proxy_pass http://dispatch_api;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_connect_timeout 2s;
        proxy_next_upstream error timeout http_502 http_503;
    }
}

Reload Nginx, then prove the distribution rather than trusting the config:

for i in $(seq 1 20); do curl -s localhost:8080/ ; done | sort | uniq -c

Expect a two to one split between 8001 and 8002 because of weight=2, and nothing from 8003, since backup only takes traffic when the others are down. Now kill the 8001 process and rerun the loop. Traffic moves within one request, because proxy_next_upstream retries on a connection error instead of handing the user a 502. That directive is the difference between a blip and an incident.

The 6 Load Balancing Algorithms, and Which to Actually Pick

1

Round robin

Each healthy server in turn. Assumes every request costs the same and every server is the same size: wrong often enough to matter, right often enough to be everyone’s default.

Default choice
2

Weighted round robin

A thumb on the scale: give a 4 vCPU box weight=2 against a 2 vCPU box. Honest use case is mixed instance sizes mid migration, not permanent architecture.

Mixed hardware
3

Least connections

Send to whoever holds the fewest open connections. Right when durations vary wildly: most dispatch calls take 40 ms, a report export 12 seconds.

Uneven work
4

Least response time

Least connections plus a latency term, so an idle but garbage collecting server stops winning. A cold cache looks identical to a sick one.

Latency sensitive
5

IP hash

Hash the client address so a client keeps its backend. Breaks quietly behind carrier NAT, where thousands of users share one address and one backend takes them all.

Crude affinity
6

Consistent hashing

Hash on a key you choose, such as tenant ID, on a ring that survives adding a node without reshuffling. The only one worth learning the maths for.

Cache locality

So which do you actually pick? For the Pune team, least connections, because their export endpoint is fifty times slower than their reads and round robin parks a long export behind a short one. That is the whole analysis. If your durations are uniform, round robin is fine and you should stop thinking about it. The trade off I am accepting is real: least connections makes distribution harder to read on a graph at 2 AM, since the split is no longer a flat line. I will take an ugly graph over a queued export.

Load Balancer vs Reverse Proxy: The Difference That Trips People Up

Every load balancer is a reverse proxy. Not every reverse proxy is a load balancer. The confusion survives because Nginx, HAProxy, Envoy and Traefik all do both jobs, so the same config file is either one depending on how many servers you listed.

Aspect Load balancer Reverse proxy
Core job Choose between many backends Sit in front of a backend and speak for it
Why you added it Capacity and failover TLS, caching, path routing, hiding internals
Health checks Essential, and the source of most outages Optional, often absent
Typical software AWS ALB or NLB, HAProxy, Envoy Nginx, Caddy, Cloudflare, Apache httpd
Can one box be both? Yes, usually. Nginx terminating TLS for one Django app is a reverse proxy. Add a second server line to the upstream block and it became a load balancer.

Care about this for buying decisions. If your problem is "I need HTTPS and clean paths to two internal services", a reverse proxy on one small instance will do. If it is "a deploy takes the site down for ninety seconds", you need health checks, and a proxy in front of a single server will not save you. A third thing gets folded in wrongly: an API gateway, which adds auth, rate limiting and quotas on top, as our guide to AI gateways covers.

Layer 4 vs Layer 7: Types of Load Balancer You Will Meet

Layer 4 works at TCP and UDP. It sees addresses and ports, forwards packets, never parses HTTP, and so is fast, cheap and unable to route on a URL path. AWS Network Load Balancer is the interview example, and what you reach for with gRPC streams, MQTT from IoT devices, or a Postgres read pool.

Layer 7 terminates the connection and routes on method, path, host, header or cookie, which is how /api/* and /static/* reach different target groups from one address. AWS Application Load Balancer is the reference implementation, and its target groups, listener rules and health checks are examined directly in SAA-C03, which 360DT's live AWS Solutions Architect and DevOps course builds and breaks in class rather than describing on a slide. Pick Layer 7 unless you have a reason not to, usually a non HTTP protocol or a need for the client IP to arrive untouched.

The four ALB numbers worth memorising

Defaults, not recommendations. Three of the four are worth changing on day one.

30 s
Default health check interval
150 s
Before a new target gets traffic, 30 s times a healthy threshold of 5
60 s
Default idle timeout, the usual cause of a 504
$0.0225
Per ALB hour in US East (Ohio), plus $0.008 per LCU hour

AWS documented target group defaults and published Elastic Load Balancing pricing for US East (Ohio), checked 29 September 2026. Indian regions price differently.

Both self hosted options moved recently enough that stale tutorials will mislead you. Nginx shipped 1.30.5 on its stable branch on 15 September 2026, and the 1.30 branch brought cookie based session persistence, Early Hints and Multipath TCP into the open source build, features that used to mean paying for NGINX Plus. HAProxy 3.2 is the current LTS line, with 3.2.25 released on 28 September 2026 and security support to 1 April 2030. For a balancer you will not think about for three years, HAProxy 3.2 LTS is the defensible pick.

Also read: What is Kubernetes? covers where a cluster takes this job over through Services and Ingress.

Where You Will Meet Load Balancing in Real Work

The zero downtime deploy. Where load balancing first earns its keep, and not about traffic volume at all. With one server, a deploy means a gap. With two target groups, you register the new version, wait for health checks, shift the listener and drain the old one, and nobody sees anything. That is as much CI/CD work as networking, so if the deploy half is unfamiliar, start with how a CI/CD pipeline works.

Serving a model behind an endpoint. A model leaving the notebook needs several replicas with a balancer in front, because GPU inference is exactly the uneven workload least connections exists for. Serving, autoscaling and rollout sit inside the AI-300 objectives that 360DT's MLOps Engineer course works through live.

Routing across model providers. A pipeline that calls one hosted model and falls back to a second on a rate limit is load balancing with different words on the boxes: health check becomes error rate, algorithm becomes a cost and latency policy. Students build that layer in 360DT's AI Engineer course alongside their RAG and agent work.

The interview. It shows up in the architecture round of nearly every cloud and DevOps interview in India, usually as "walk me through what happens when a target fails a health check". The certifications overview shows which exams test it formally. On Azure, Application Gateway and Front Door are the AZ-305 equivalents, covered in the Azure Solutions Architect and DevOps course.

What Usually Goes Wrong: Health Checks, Timeouts and Sticky Sessions

Here is the desk warning. Nobody gets paged for choosing round robin over least connections. People get paged because a health check returns 200 while the app is broken, or because one timeout is shorter than the one beside it.

What you see What is actually happening Fix
Burst of 502s for 30 seconds after every deploy The balancer kept sending traffic to a container already shutting down Enable connection draining and handle SIGTERM by finishing in flight requests before exiting
504 on the report export, exactly at 60 seconds ALB's default idle_timeout.timeout_seconds of 60 fired before your backend replied Raise the idle timeout, or better, make the export asynchronous and return a job ID
Health check green, users get errors Your check hits /, which returns a static page and never touches the database Add a /healthz that pings the database with a 1 second timeout and returns 503 when it cannot
Users randomly logged out after scaling up Sessions live in each server's local memory, so server two never heard of that user Move sessions to Redis, using sticky cookies only as a stopgap
Intermittent 502s under normal load Backend keepalive is shorter than the balancer's idle timeout, so it reuses a connection the server just closed Set backend keepalive higher than the balancer's idle timeout, never lower

The AWS defaults deserve a second look, because the arithmetic is unkind: a 30 second interval with a healthy threshold of 5 puts about 150 seconds between an instance being ready and the balancer trusting it. During a spike driven autoscaling event, that is a long time to be down a server. Changing a timeout takes one command:

aws elbv2 modify-load-balancer-attributes \
  --load-balancer-arn arn:aws:elasticloadbalancing:ap-south-1:123456789012:loadbalancer/app/dispatch/abc123 \
  --attributes Key=idle_timeout.timeout_seconds,Value=120
The honest caveat

Load balancing will not fix a slow application, and it is oversold as if it might. If your bottleneck is one unindexed query on a single Postgres primary, a second app server and a balancer buy you the ability to overwhelm that database twice as fast; requests queue somewhere new, that is all. A single server at 30 percent CPU serving slow responses means the problem is downstream, and a balancer is an expensive distraction from it.

Sticky sessions deserve the same scepticism. It is genuinely useful that Nginx open source can now issue a session cookie without a paid licence, and genuinely a sign your app keeps state it should not. Use it to survive two weeks, then move sessions to Redis and take it out.

How to Learn Load Balancing Properly

Reading about it plateaus fast. What builds the skill is running the local setup above, then rebuilding it with a real ALB, two target groups and a deliberately broken health check, so you watch a target leave rotation and return. Do it once and the interview answer writes itself.

Live course

Build the load balancer, break it, and fix it live in class

Live online·Sat–Sun, 8–11 PM IST·80+ hrs·Rs 29,999

A live weekend program over 12 weeks that prepares you for both AWS Solutions Architect Associate (SAA-C03) and AWS DevOps Engineer Professional (DOP-C02). Includes hands on projects, mentor support and placement guidance.

Explore the course
AWS Solutions Architect & DevOps Engineer Course (SAA-C03 + DOP-C02)

To sample the teaching first, the free webinars cover cloud architecture at this level, and a free demo class puts you in a live session for an evening.

Frequently asked questions

What is load balancing in simple words?

It is a traffic officer for your servers. One machine owns the public address, tracks which backends are currently healthy, and hands each request to one of them. You get a steadier service, and you can lose a server without losing the site.

How does a load balancer work step by step?

It accepts the connection, because DNS points at the balancer rather than a server. It discards backends that failed recent health probes. It applies an algorithm such as round robin or least connections to the healthy list. Then it proxies the response back.

What is the difference between a load balancer and a reverse proxy?

A reverse proxy speaks for backends, usually to terminate TLS, cache or route paths, and one backend is enough. A load balancer chooses between several and needs at least two. Every load balancer is a reverse proxy, so the distinction is why you deployed it.

Is load balancing the same as auto scaling?

No, and they are commonly confused. Auto scaling changes how many servers exist. Load balancing decides which existing server gets the next request. They pair in practice, because a new instance is useless until something routes traffic to it, but either runs without the other.

What are Layer 4 and Layer 7 load balancers?

Layer 4 balances at TCP or UDP level, forwarding packets by address and port without reading the payload, which makes it fast and protocol agnostic. AWS Network Load Balancer is the common example. Layer 7 reads the HTTP request and routes on path, host, header or cookie.

Which certification covers load balancing in depth?

On AWS, SAA-C03 examines ALB and NLB choice, target groups, listener rules and health checks, and DOP-C02 pushes into blue green and canary deploys. On Azure, AZ-305 covers Application Gateway and Front Door. Both are taught live in 360DT's AWS and Azure programs.

In your position I would run the local Nginx exercise tonight and the broken ALB health check this weekend, in that order. Config syntax is the easy half and you will forget it anyway. What stays with you is having watched a target drop out of rotation and come back, because that is what every interview question and every 2 AM page is really testing. When you want the cloud half taught properly, the AWS Solutions Architect and DevOps course is the direct next step, and a free webinar is the cheaper way to judge the teaching.

About this guide. 360 Digital Transformation is an Anthropic Partner. Other certification bodies, vendors and employers named here are not affiliated with us. Tools and versions change quickly; commands and figures cited were checked on 29 September 2026.

Learn it live with 360 Digital Transformation

Turn this guide into a skill employers can see

Live weekend cohortEMI available

AWS Solutions Architect & DevOps Engineer Course (SAA-C03 + DOP-C02)

Rs. 29,999Rs. 37,499 Save 20%

Tools and platforms you work with

  • Amazon Web Services
  • Terraform
  • Docker
  • Amazon EKS
  • Jenkins
  • GitHub Actions
  • Git
  • Linux
Add bonus modules
See the syllabus and batch dates

Other live courses on this career path