HTTP & Load Balancing
The language of the web, and how production systems serve millions of users without falling over.
HTTP is the protocol your browsers, APIs, and microservices use to talk. Load balancing is how you take that traffic and spread it across many servers so no single one is overwhelmed. Together they’re the backbone of every web system you’ll operate.
🎯 Learning Objectives
By the end of this lesson you will:
- Understand the structure of an HTTP request and response
- Read HTTP status codes confidently
- Know what HTTPS adds and why it matters
- Understand load balancers and reverse proxies
Anatomy of an HTTP Request
Every request has a method, a path, headers, and sometimes a body:
GET /api/users/42 HTTP/1.1
Host: example.com
Authorization: Bearer <token>
Accept: application/jsonCommon methods:
| Method | Meaning |
|---|---|
| GET | Read data (no changes) |
| POST | Create something new |
| PUT / PATCH | Update existing data |
| DELETE | Remove data |
Status Codes — the Server’s Answer
The first thing you check when debugging an API is the status code:
| Range | Meaning | Common examples |
|---|---|---|
| 2xx | Success | 200 OK, 201 Created |
| 3xx | Redirect | 301 Moved, 304 Not Modified |
| 4xx | You made a mistake | 401 Unauthorized, 403 Forbidden, 404 Not Found |
| 5xx | Server made a mistake | 500 Internal Error, 502 Bad Gateway, 503 Unavailable |
💡 4xx vs 5xx
4xx means the client sent something wrong (bad URL, missing auth). 5xx means the server failed. This single distinction tells you which side to start debugging.
HTTPS — HTTP with Encryption
HTTPS is HTTP wrapped in TLS encryption. It gives you:
- Confidentiality — nobody can read the traffic in transit
- Integrity — nobody can tamper with it
- Authenticity — a certificate proves you’re talking to the real server
⚠ Certificates expire
An expired TLS certificate takes a site down instantly and loudly. Automate renewal (e.g. with Let’s Encrypt / cert-manager) and monitor expiry dates — this is a classic avoidable outage.
Load Balancers & Reverse Proxies
A load balancer sits in front of several identical servers and distributes incoming requests among them:
┌──▶ Server A
Client ──▶ Load ──┼──▶ Server B
Balancer└──▶ Server CWhy it’s essential:
- Scale — add more servers to handle more traffic
- High availability — if one server dies, traffic routes to the healthy ones
- Zero-downtime deploys — update servers one at a time behind the balancer
A reverse proxy (like Nginx) is closely related: it receives client requests and forwards them to backend services, often adding TLS termination, caching, and routing.
Common balancing strategies
| Strategy | How it picks a server |
|---|---|
| Round robin | Each request to the next server in turn |
| Least connections | The server with the fewest active connections |
| IP hash | Same client always goes to the same server |
💡 Health checks
A load balancer constantly pings each backend’s health endpoint. If a server fails the check, it’s pulled out of rotation automatically — this is what keeps a service “up” even when individual machines fail.
See It Yourself
Inspect a real HTTP response with curl:
curl -I https://example.com # headers + status only
curl -s -o /dev/null -w "%{http_code}\n" https://example.comThe 200 confirms success, and server: nginx reveals a reverse proxy in front of the app.
🧪 Hands-on Lab
Read HTTP Like an Engineer
- Fetch the headers of a website and note the status code
- Request a page that doesn’t exist and observe the 404
- Identify whether the site uses HTTPS and what server software it reports
🧠 Knowledge Check
A request returns a 503 status code. Where do you start looking?
What is the main benefit of putting a load balancer in front of multiple servers?
💼 Interview Preparation
Walk me through what happens when a user visits your website.
Summary
You’ve completed the Networking track: the client–server model, IP addresses and ports, DNS, and now HTTP, HTTPS, and load balancing. These fundamentals underpin every container, cluster, and cloud service you’ll work with next. On to containers with Docker.