Card 01/ 10

ConceptDifficulty: Beginner2 min

Three Servers That Sit in Front of Yours

A load balancer, a reverse proxy and an API gateway, each built for one job.

A load balancer, a reverse proxy and an API gateway are all servers that receive a reader's request and forward it to a server behind them. What separates them is what they forward to, and why. A load balancer spreads requests across copies of one server; a reverse proxy stands in front of one origin and works for it; an API gateway routes each request to one of many different services.

Three intermediaries, three kinds of thing behind them

Behind a load balancer, every server is the same: copies running the same code. The balancer's job is to keep each copy busy without overloading any, and to stop sending requests to a copy that has failed.

Behind a reverse proxy is one origin, the server that holds the real application. The proxy does work so the origin does not have to: it handles TLS, Transport Layer Security, the encryption behind https; it caches responses; it compresses them. The client never learns where the origin is.

Behind an API gateway are different services, each owning a part of the product. The gateway reads the path of each request, sends /orders to one service and /users to another, and applies the rules every call needs, such as checking who the caller is, in one place.

One product, three roles. The names describe jobs, not products. NGINX can balance load, act as a reverse proxy, and route paths like a gateway, all from one configuration. When you name the part in a design, name the job it does there, because that is what tells a reader why it exists.

What the rest of the topic covers. Each of the three has its own card, followed by a comparison that puts them side by side and a practice card that asks you to choose.

So when a design needs something in front of its servers, ask what is behind it (copies, one origin, or many services), and the answer names the part.

← → move through sections and cards