# Load Balancer vs Reverse Proxy: Who Spreads Traffic and Who Guards the Door

> A load balancer picks which server gets each request. A reverse proxy stands in front of servers. Learn what each does, where they overlap, and how to choose.

**In short:** A load balancer picks which server gets each request, while a reverse proxy stands in front of your servers and handles what happens to a request on its way.

From "System design", a free course by Venkat R. Murty: https://designervenkat.online/learn/system-design/lb-vs-reverse-proxy

## What You Will Learn

Most websites start on a single server. As visitors grow, one machine is no longer enough, and you need a clear way to direct traffic. Two tools come up again and again here: the load balancer and the reverse proxy. Beginners often mix them up, partly because one program can play both roles. This lesson explains what each one does, where they overlap, and how to choose between them.

- **Client:** The program that asks for something, such as a web browser or a phone app.
- **Backend:** A server that does the real work, such as running your app code. Behind a proxy, it is sometimes called an origin server.
- **Load balancer:** A tool that picks which backend gets each incoming request or connection.
- **Reverse proxy:** A server placed in front of backends. It receives client requests and forwards them on.
- **HTTPS:** The encrypted form of web traffic, so others on the network cannot read it.
- **SSL termination:** The front server decrypts HTTPS traffic, so the backends receive plain requests.
- **Caching:** Keeping a copy of a response so that the next request can use the copy.
- **Compression:** Shrinking a response before sending it, using a method such as gzip.
- **Single point of failure:** One part whose breakdown stops the whole service.
- **Horizontal scaling:** Adding more machines of the same kind to share the work.
- **Failover:** Sending work to healthy servers when one server fails.

## What Does a Load Balancer Do?

A load balancer sits in front of several servers. For each incoming request or connection, it decides which server should handle it. Think of a traffic officer at a busy junction who points each car down a free road.

- **More capacity:** Adding servers behind the balancer lets the group grow as demand grows. Each new machine takes a share of the work.
- **Higher availability:** If one server stops answering, the balancer can stop sending it new requests, so visitors reach the healthy servers instead.
- **Even spread:** The balancer tries to keep any single server from becoming the bottleneck that slows everyone down.

A load balancer only pays off when there is more than one backend. With one server, there is nothing to choose between, so the balancer adds a hop and no benefit.

## What Does a Reverse Proxy Do?

A reverse proxy is a server that stands in front of your backends. Clients send their requests to the proxy, and the proxy forwards them on. Visitors usually never learn the real address of the backend. The word reverse describes the direction: the proxy works for the servers, while a forward proxy works for the users.

- **One front door:** Clients use one public address, and the proxy routes each request to the right backend.
- **SSL termination:** The proxy decrypts HTTPS, so the backend can handle plain requests. This job is often done on the proxy itself.
- **Caching:** The proxy keeps copies of content that many visitors ask for, such as images and static files. A stored copy can be sent back without calling the backend.
- **Compression:** The proxy can shrink responses before they travel to the visitor, which saves bandwidth and time.
- **Security:** Because the backend address stays private, attackers cannot reach it directly.

A reverse proxy is useful even with one server. It manages the traffic going to that server, so you do not need a second machine before you gain its benefits.

## How Do They Overlap and Differ?

The two tools are easy to confuse because they sit in the same place in a system. Both stand between clients and backends, and the same software often does both jobs. The sub-topics below separate the shared ground from the real differences.

### Where They Overlap

Both tools sit between clients and backends, so both see every request coming in. Both can hide servers and handle HTTPS. That shared position is why the labels blur.

Many products do both jobs. NGINX is a common example. It can forward requests to one server, or it can spread them across a named group of servers. AWS ELB is better known as an example of a dedicated load balancer.

### Where They Differ

The difference is about purpose. A reverse proxy cares what happens to a request on its way: changing it, caching it, or checking it. A load balancer cares where the request goes, meaning which server answers it.

A simple test is to count your backends. A proxy can earn its place with a single backend, while spreading work only makes sense across several.

## Worked Example: One NGINX, Two Roles

Here is a small web app that shows the idea in action. At the start, the app runs on one Node.js server. NGINX sits in front of it and does three jobs: HTTPS, gzip compression of text, and cached static files such as images and style sheets. At this stage NGINX is only a reverse proxy.

1. **Point NGINX at the one server:** NGINX listens on the public address. The proxy_pass setting names the backend, and every request is forwarded to the Node.js server.
2. **Let NGINX handle HTTPS:** The certificate lives on NGINX. Visitors connect to it over HTTPS, NGINX decrypts the traffic, and it sends plain requests to Node.js. That is SSL termination.
3. **Compress and cache at the front:** It also keeps copies of static files, so repeat visitors receive them without waking Node.js.
4. **Traffic grows, so add servers:** The team starts two more Node.js servers that run the same code. Now there are three identical backends.
5. **Group the backends:** An upstream block is the NGINX section that names a group of backends. The proxy_pass line now points at the group name instead of one machine.
6. **Let the same NGINX spread requests:** When no method is set, NGINX uses round-robin, which sends each new request to the next server in turn. The same NGINX now works as a load balancer too.

Here is the simplified final setup. The caching lines are left out to keep it short.

```
upstream app_servers {
    server 10.0.0.11:3000;
    server 10.0.0.12:3000;
    server 10.0.0.13:3000;
}

server {
    listen 443 ssl;
    server_name example.com;
    ssl_certificate /etc/ssl/example.crt;
    ssl_certificate_key /etc/ssl/example.key;
    gzip on;

    location /static/ {
        root /var/www/example;
    }

    location / {
        proxy_pass http://app_servers;
    }
}
```

Notice what stayed the same. The public address, HTTPS, compression, and static files did not move. Only the backend list grew. That is why the two roles are so often combined in one tool.

## How Do You Choose?

Ask three questions. How many backends do you run? Do you need the same app on several machines? Do you need one front door with extra features? The answers point to one of three setups.

- **Reverse proxy alone:** Choose this when you have one application server, or when you need one entry point, SSL offloading (the same as SSL termination), caching, or protection.
- **Load balancer:** Choose this when you run several copies of the same app and need horizontal scaling or failover, which sends work to healthy servers when one fails.
- **Both together:** Choose this when public traffic needs proxy features and the backend group also needs spreading across servers.

> **Tip:** Start with a reverse proxy on your single server. Add a load balancer when a second interchangeable backend joins the system. Many tools let you grow from one role to the other with a config change.

## What Are the Costs and Risks?

Combining the two roles is common, but it has costs. Each layer is another program to configure, watch, and debug.

The bigger risk is a single point of failure. If one proxy or one balancer is the only way into your system, its failure stops everything. Give that layer a backup copy that can take over, or use a managed cloud service that runs redundant copies for you. Keeping the front layer alive is a topic for the failover lessons.

### Chaining Layers in Large Systems

Large sites often stack the roles in a line. Each layer keeps one clear job, which makes the system easier to reason about as it grows.

## Check Your Understanding

Try these short scenarios. Each one needs the difference between the two tools to answer.

**Quick check:** A team runs one application server. They want HTTPS handled in one place, static files cached, and the server's IP address hidden from the public. Which setup fits best?

A. A load balancer with no other tools
B. A reverse proxy in front of the one server
C. Three load balancers in a chain, with no proxy
D. Nothing, because the app server can handle all of this alone

**Answer:** B. All three needs are reverse proxy jobs, and one backend is enough for a proxy. A load balancer would have nothing to choose between.

**Quick check:** A shop runs four identical API servers. One server crashes at night, and customers should keep getting answers from the other three without any manual step. Which tool does this job?

A. A reverse proxy that only compresses responses
B. A forward proxy on each customer's laptop
C. A load balancer that stops sending requests to the failed server
D. A bigger disk on each API server

**Answer:** C. Choosing among several healthy backends and skipping a failed one is the load balancer's job. Compression and disk size do not route traffic around a failure.

**Quick check:** A team puts one reverse proxy in front of three app servers. The proxy machine fails, and the whole site goes down even though the three app servers are fine. What is the main lesson?

A. Reverse proxies should never be used with more than one server
B. The three app servers should be replaced with one larger server
C. The proxy became a single point of failure and needs a redundant copy
D. Caching caused the outage, so caching should be turned off

**Answer:** C. The healthy app servers were not the weak point. The one proxy in the only path was, so it needs a backup that can take over.

## Key Takeaways

A load balancer chooses among several servers, so it spreads work and helps with failures. A reverse proxy stands in front of your servers, hides them, and handles tasks such as HTTPS, caching, and compression. One server usually calls for a reverse proxy. Several interchangeable servers call for a load balancer. Many real systems use both, and the front layer must not become a single point of failure.

## Sources

- [Using nginx as HTTP load balancer (NGINX official documentation)](https://nginx.org/en/docs/http/load_balancing.html)
- [Module ngx_http_proxy_module (NGINX official documentation)](https://nginx.org/en/docs/http/ngx_http_proxy_module.html)
- [Load Balancer vs Reverse Proxy: Differences, Overlap & When to Use Each (Contabo)](https://contabo.com/blog/load-balancer-vs-reverse-proxy/)
- [Load balancer vs reverse proxy: the real difference (DEV Community)](https://dev.to/systemdesignsimple/load-balancer-vs-reverse-proxy-the-real-difference-1kf4)
- [Reverse Proxy vs Load Balancer Explained (Raff Technologies)](https://rafftechnologies.com/learn/guides/reverse-proxy-vs-load-balancer)
- [Load Balancer vs Reverse Proxy (Interview Prep Notes)](https://interviewprepnotes.com/compare/load-balancer-vs-reverse-proxy)
- [Reverse Proxy vs Load Balancer: What's the Difference? (100plus.tools)](https://100plus.tools/comparisons/reverse-proxy-vs-load-balancer)
- [Reverse Proxy vs Load Balancer: What's the Difference? (devwithtools)](https://devwithtools.org/blog/reverse-proxy-vs-load-balancer)
- [Reverse Proxy and Load Balancer: Understanding the Difference (StrongDM)](https://www.strongdm.com/what-is/reverse-proxy-vs-load-balancer)
- [Reverse proxy vs load balancer: stop mixing them up (DEV Community)](https://dev.to/dev_tips/reverse-proxy-vs-load-balancer-stop-mixing-them-up-before-prod-takes-the-hit-4c7a)
- [Reverse Proxy vs Load Balancer: Ultimate Showdown (CyberPanel)](https://cyberpanel.net/blog/reverse-proxy-vs-load-balancer)
- [Reverse Proxy vs Load Balancer: What's the Difference. (Rapid Seedbox)](https://www.rapidseedbox.com/blog/reverse-proxy-vs-load-balancer)
- [Nginx Reverse Proxy: How to Configure proxy_pass and Headers (Linuxize)](https://linuxize.com/post/nginx-reverse-proxy/)
- [Load Balancer vs Reverse Proxy: Key Differences, Use Cases, and Why You Need Both (TechByTechies)](https://techbytechies.com/load-balancer-vs-reverse-proxy-key-differences-use-cases-and-why-you-need-both/)
