Skip to content
learn
  1. Learn
  2. High Level System Design
  3. Computer and Network Foundations

System Design HLD-01.05

HTTP/1.1, HTTP/2 and HTTP/3

Anatomy of an HTTP request, status codes, keep-alive, and how HTTP/2 multiplexing and HTTP/3 over QUIC fight head-of-line blocking.

Beginner 14 min Last reviewed

The big idea

HTTPHyperText Transfer Protocol: the request and response protocol browsers, apps and APIs use to fetch and send data on the web. is the language of the web. A client sends a request ("GET me /cart"), the server sends back a response ("200 OK, here it is"). Every web page, mobile app API and most service-to-service calls speak it.

The messages have barely changed in 30 years. What has changed is how they are carried. A modern page needs dozens of files, and the way a protocol version moves many requests over the network decides whether the page appears in half a second or three. HTTP/1.1, HTTP/2 and HTTP/3 are three answers to the same question: how do you send many requests at once without one slow or lost response holding up the rest?

Picture a single-lane checkout. HTTP/1.1 is one cashier per lane, one customer at a time, and browsers open six lanes. HTTP/2 lets one cashier serve everybody's items interleaved, but if one item's barcode will not scan, the whole lane stops. HTTP/3 gives every customer an independent sub-lane, so a jammed scan only stops its owner.

How it works

Step 1: A request and a response

A request has a methodThe action requested: GET reads, POST creates, PUT replaces, PATCH updates part, DELETE removes., a path, headers and an optional body:

GET /cart HTTP/1.1
Host: shop.example.com
Accept: application/json
Cookie: session=8f3a...

The response has a status code, headers and a body:

HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: private, max-age=0

{"items": [{"sku": "A12", "qty": 2}]}

Step 2: Status codes say what happened

The first digit tells the client what kind of outcome it got:

  • 2xx success: 200 OK, 201 Created, 204 No Content.
  • 3xx redirect: 301 Moved Permanently, 304 Not Modified (use your cached copy).
  • 4xx client error: 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 429 Too Many Requests. The client should change something before retrying.
  • 5xx server error: 500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable. The server failed; a retry later might work.

The difference between 4xx and 5xx matters in system design: retrying a 4xx is pointless, while 5xx errors are what your alerts and error budgets count.

Step 3: Three ways to carry many requests

HTTP/1.1, HTTP/2 and HTTP/3 carrying several requests when one packet is lost Three lanes of packets on the wire between a browser and a server. HTTP/1.1: two of up to six connections, each carrying one file at a time. HTTP/2: one TCP connection with frames from streams 1 to 5 interleaved; after a lost packet every following frame is red because it must wait. HTTP/3: the same interleaving over QUIC; after the loss only stream 3, the stream that lost data, waits. HTTP/1.1: up to 6 connections, one file at a time on each HTTP/2: one TCP connection, streams interleaved HTTP/3: one QUIC connection over UDP, independent streams Browser Server a a a b b c d d e e e f Browser Server s1 s2 s3 lost s1 s2 s4 s5 Browser Server s1 s2 s3 lost s1 s2 s3 s4 TCP delivers in order: everything after the gap waits QUIC orders per stream: only stream 3 waits Figure 1. Packets on the wire. HTTP/1.1 sends one file at a time per connection. HTTP/2 interleaves streams on one TCP connection, so after a lost packet every frame waits (red). HTTP/3 over QUIC keeps streams independent: only stream 3 waits (gold).

HTTP/1.1 sends one request per connection at a time and waits for the full response before the next. Keep-aliveReusing one TCP connection for several requests one after another, instead of opening a new connection each time. reuses the connection, saving handshakes, but responses still queue. Browsers work around it by opening about six connections per host, each paying its own handshake and slow start.

HTTP/2 opens one connection and splits every request and response into small frames labelled by stream, then interleaves them. Dozens of requests are in flight at once, and repeated headers are compressed. But everything rides one TCP connection, and TCP delivers bytes in order. If one packet is lost, every stream waits for its retransmission, even streams whose data already arrived.

HTTP/3 keeps HTTP/2's ideas but runs over QUICA transport protocol built on UDP that provides reliable, encrypted, multiplexed streams; each stream is ordered on its own. on UDP. QUIC orders each stream separately, so a lost packet only stalls the stream it belongs to. QUIC also combines the transport and TLS handshakes, so a new connection is ready about one round trip sooner, and it can survive a phone switching from Wi-Fi to mobile data.

Try it

This interactive needs JavaScript. The diagrams and text above cover the same idea.

Try this:

  1. Start with HTTP/1.1 and no loss. See the staircase: six requests at a time, the rest queue.
  2. Switch to HTTP/2. All requests start together and the page finishes much sooner.
  3. Now lose a packet under HTTP/2. Every asset from 4 onward turns red: head-of-line blocking. Switch to HTTP/3 and only asset 4 waits.

The timings are illustrative, built from a 40 ms round trip, so read the shapes rather than the exact numbers.

Going deeper

Choosing status codes for an API

Return 201 with a Location header when you create something, 204 when there is nothing to return, 409 Conflict when a write clashes with the current state, 422 for valid JSON that fails validation, and 429 with a Retry-After header when rate limiting. Clients, proxies and monitoring tools all make decisions based on these codes, so being precise pays off. API design is covered in REST API design .

Who speaks what

Browsers and CDNs support all three versions and pick the best one both sides offer. Inside data centers, service-to-service traffic often uses HTTP/2 because gRPC is built on it, while networks are reliable enough that HTTP/3's benefits are smaller. HTTP/3 helps most on the lossy, changing networks of mobile users.

Trade-offs

OptionWins whenLoses when
HTTP/1.1 Simplicity, debugging with plain text, very old clients and tools Pages with many assets: requests queue and connections multiply
HTTP/2 Many parallel requests over one connection on reliable networks, including gRPC Lossy networks, where one lost packet stalls every stream
HTTP/3 (QUIC) Mobile and lossy networks, fast connection setup, switching networks Networks that block UDP, and environments where TCP tooling is required

Common mistakes

  • Returning 200 OK with an error message in the body. Clients, caches and monitors then treat failures as success.
  • Retrying 4xx errors. The request is wrong; repeating it will not help. The exception is 429, which means "slow down", so wait as Retry-After says.
  • Still bundling everything into one giant file for HTTP/2. Multiplexing makes many small cacheable files cheaper than before.
  • Assuming HTTP/2 removed head-of-line blocking. It removed it at the HTTP level, but TCP still has it.

Check yourself

  1. A client sends a request with an invalid field. Which status family should the server return?

    Show answer

    C. 4xx The client made the mistake, so it is a 4xx, such as 400 or 422. Retrying unchanged will not help.

  2. What is the main improvement of HTTP/2 over HTTP/1.1?

    Show answer

    B. Many requests interleaved over one connection HTTP/2 multiplexes many streams over one TCP connection and compresses headers.

  3. On a lossy mobile network, why can HTTP/3 beat HTTP/2?

    Show answer

    B. A lost packet only blocks its own stream, not all streams QUIC orders each stream separately, so a loss no longer stalls every stream as TCP does.

  4. What does a 503 Service Unavailable tell a client?

    Show answer

    C. The server cannot handle it right now; retrying later may work 5xx means a server-side failure. 503 specifically signals temporary overload or maintenance.

Recap

  • HTTP requests have a method, path, headers and body; responses have a status, headers and body.
  • 2xx success, 3xx redirect, 4xx client error, 5xx server error. 5xx (and 429) may succeed later; other 4xx will not.
  • HTTP/1.1 queues one request at a time per connection; browsers open about six.
  • HTTP/2 multiplexes streams over one TCP connection, but a lost packet still blocks them all.
  • HTTP/3 runs over QUIC on UDP: independent streams and faster connection setup.

Get new lessons by email

Get new posts on backend and AI internals. No spam, unsubscribe anytime.

Your email is only used to send new posts. Privacy

Next up