System Design Academy

Saving…

Lesson 5 of 10 in Module 10 of 54 lessons complete

HTTP

Module 1, lesson 5Concept10 min

Definition

HTTP

In plain English
HTTP is the set of rules browsers and servers use to format requests and responses.
Think of it like
It is like a standard order form that every restaurant agrees to read.

Stateless

In plain English
Stateless means each request carries everything the server needs, so the server does not have to remember earlier requests.
Think of it like
It is like a ticket counter where you show your booking reference each time.

Why it exists

Without a shared message format, every client and server pair would need its own rules. HTTP gives both sides common ways to describe an action, attach information and report the outcome.

Start with readable HTTP/1.1 messages. HTTP/2 and HTTP/3 pack messages differently but keep the same methods and status meanings.

Cookie

In plain English
A cookie is a small piece of data the browser stores and sends on later requests that match its scope.
Think of it like
It is like a cloakroom ticket you show to collect your coat.

A login cookie references saved login data. Any server with that data can answer. Each request stands alone, even when the app stores user information.

How it works

Method

In plain English
An HTTP method is the verb of a request that says what you want done, such as GET to read.
Think of it like
It is like choosing dine in or takeaway on an order form.

Header

In plain English
A header is a labelled field of extra information sent with a request or response.
Think of it like
It is like notes on the outside of an envelope.
A request and response; application/json denotes structured text data.
HTTP
GET /menu HTTP/1.1
Host: cafe.example
Accept: application/json

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 17

{"items":["tea"]}
MethodTypical actionSame intended effect when repeated?
GETReadYes; reading must not ask to change data
POSTCreate or submitNot guaranteed
PUTReplaceYes
PATCHChange partDepends on the change
DELETERemoveYes; response status can differ

Status code

In plain English
A status code is a three-digit number in the response that says how the request went.
Think of it like
It is like a parcel tracking status saying delivered, returned or lost.
FamilyCodes and meaning
2xx: success200 OK; 201 Created
3xx: redirect or reuse301 Moved Permanently; 304 Not Modified
4xx: problem with the request400 Bad Request; 401 Unauthorized; 403 Forbidden; 404 Not Found; 409 Conflict; 429 Too Many Requests
5xx: server failure500 Internal Server Error; 503 Service Unavailable

The client sends GET /menu to the server. The server returns 200 OK with JSON data.

The client initiates the HTTP request and receives a response.

The client sends GET /menu to the server. The server returns 200 OK with JSON data.

Examples

Borrow a drill

You browse drills and request a loan in a library of things.

Read with GET, submit with POST, and inspect the status before showing success. A conflict means the server understood the request but current inventory prevents it.

Exchange excerpts: browsing, creating a loan, and an already-loaned item conflict.
HTTP
GET /items?category=drills HTTP/1.1
Host: tools.example

HTTP/1.1 200 OK

POST /loans HTTP/1.1
Host: tools.example
Content-Type: application/json

{"itemId":"drill-7"}

HTTP/1.1 201 Created
Location: /loans/91

HTTP/1.1 409 Conflict

The insight

Methods and status codes form a vocabulary both sides already know.

Trade-offs

Pros

  • Reuse widely supported tools.
  • Inspect readable HTTP/1.1 exchanges.
  • Reuse cacheable responses.
  • Spread independent requests across servers.

Cons

  • Headers add extra data.
  • Ordinary exchanges need a client request.
  • Many small actions require many requests.

Use when

  • Serve web pages and public APIs.
  • Use familiar request and response behavior.

Avoid when

  • Tiny high-frequency messages dominate.
  • The server needs an ongoing push channel.

Quick check

A user who isn't logged in opens "My loans". Best status?
Why does statelessness help scaling?

Takeaways

  • HTTP = shared request/response format.
  • Methods say what, status codes say how it went.
  • Stateless application servers are easier to multiply.

Try the quick check above whenever you feel ready.

Previous: DNS