HTTP/1.1, HTTP/2 and HTTP/3
Learn what really changed from HTTP/1.1 to HTTP/2 and HTTP/3, so you can pick settings for clients, load balancers and timeouts with care.
Updated since you finished it. We changed this lesson after you marked it done. Your progress is kept.
What broke
A shopping app loads its home screen with about forty small API calls. The API runs on HTTP/1.1. On slow networks, the screen takes many seconds to fill, because requests wait in line for free connections.
The team turns on HTTP/2 at the load balancer. Now all forty calls share one connection. On office Wi-Fi, the home screen is much faster, and everyone is happy.
Then support tickets arrive from users on trains. Sometimes the whole screen freezes for a second or two, and then everything appears at once. The team checks the servers, and they answered fast.
The cause was one lost packet. HTTP/2 sends every request over one TCP connection. TCP hands data to the app only in order. So one lost packet stalls every request on that connection, even requests the loss did not touch 6. The fix was to also offer HTTP/3 for clients that can use it.
This story is made up. But the behaviour is real and written in the standards.
The idea in simple words
HTTP has two parts:
- Semantics: what a message means. Methods like GET and POST, status codes like 404, and headers. RFC 9110 says all three major HTTP versions rely on the same semantics 1.
- Wire format: how those messages travel. This is the part each version changes.
So your handler code does not change when the version changes. What changes is speed, how many connections you hold, and what happens when packets are lost.
- HTTP/1.1 sends text messages over TCP. It cannot mix requests on one connection, so clients open several connections to work in parallel 6.
- HTTP/2 uses binary frames instead of text, over one TCP connection. Many requests run at the same time, each in its own stream 3 10.
- HTTP/3 keeps the idea of streams, but runs on QUIC, over UDP. A lost packet blocks only the streams it carried 6 10.
The key idea. Each new HTTP version keeps the same meaning and fixes the waiting of the version before. HTTP/2 removes waiting between requests. HTTP/3 removes waiting caused by TCP itself.
How it works
Step through three requests, A, B and C, with one lost packet. Use Next and Back, or the ← and → keys.
- HTTP/1.1: a connection carries one request at a time, so the browser opens three TCP connections for requests A, B and C. That costs three handshakes.
- Packet B1 is lost. Only connection B waits for TCP to send it again. A and C finish, because they use other connections.
- HTTP/2: all three requests share one TCP connection. Each request is a stream, and their frames are mixed into one ordered byte stream.
- Packet B1 is lost. TCP cannot see streams, so it holds C1, A2 and C2 until B1 arrives again. All three requests wait. This is head-of-line blocking.
- HTTP/3: the three requests use one QUIC connection over UDP. QUIC knows about streams, and keeps each stream in order on its own.
- Packet B1 is lost. QUIC still hands A and C to the app. Only stream B waits for B1 to be sent again.
HTTP/1.1: one request at a time
HTTP/1.1 connections are persistent by default. One connection can serve many requests, one after another 2. This is keep-alive, and it saves a new TCP handshake for each request.
Pipelining lets a client send several requests without waiting. But the server must send the responses in the same order 2. So one slow response still blocks the rest 3. In practice, clients open several connections to one server instead 3. RFC 9112 asks clients to limit how many they open, because each one uses server resources. It gives no fixed maximum 2.
Many connections also make congestion control work less well, because TCP does not share it across connections 6.
HTTP/2: many streams, one TCP connection
HTTP/2 cuts each message into binary frames 3. Each request and response pair gets its own stream, and frames from many streams mix on one connection 3. This is called multiplexing. RFC 9113 says clients should not open more than one HTTP/2 connection to a given host and port 3.
Each side tells the other how many streams it may open at once. RFC 9113 recommends at least 100, so that parallel work is not limited 3.
HPACK. Requests to one server repeat the same headers again and again, which wastes bandwidth 4. Before HPACK, SPDY compressed headers with DEFLATE. The CRIME attack showed that this could leak secrets 4. HPACK instead keeps tables of headers that both sides already know. A header can then be sent as a small index 4.
Server push. HTTP/2 added an optional way for a server to send responses the client did not ask for yet 3. It did not work out well. RFC 9113 itself says push is hard to use well, because the server must guess what the client will ask for 3. Only 1.25% of HTTP/2 sites used it. Studies had mixed results, with no clear overall gain and often worse performance 5. Chrome announced that it would turn push off by default in version 106. The post suggests 103 Early Hints and preload instead 5.
What HTTP/2 did not fix. TCP still sees one ordered stream of bytes. RFC 9113 says plainly that TCP head-of-line blocking is not addressed 3. A lost packet stalls every stream, even streams the loss did not touch 6. See TCP/IP and the network stack for why TCP works this way.
HTTP/3: streams that do not block each other
HTTP/3 maps each request and response to its own QUIC stream. If one stream is blocked or loses a packet, other streams still make progress 6. QUIC does not keep any order between bytes on different streams 7.
Two other changes matter:
- Faster setup. QUIC includes TLS 1.3. RFC 9114 says this gives security like TLS over TCP, with faster connection setup 6. See TLS and secure connections for the handshake.
- Connection migration. A QUIC connection has connection IDs, not only an address and port. These IDs let a connection survive a change of address 7. Only the client can start a migration, and only after the handshake is confirmed 7.
HPACK assumes data arrives in order, which QUIC does not promise across streams. So HTTP/3 uses a new format, QPACK 6.
How a client picks a version
ALPN. In the TLS handshake, the client sends a list of protocols it supports. The server picks one. This adds no extra round trips 8. HTTP/2 over TLS uses the name h2 3, and HTTP/3 uses h3 6.
Alt-Svc. The URL is still https://, so the client needs a sign that the server also speaks HTTP/3. The server can send one in a response header, like Alt-Svc: h3=":443"; ma=86400 6 11. The ma value is how many seconds the client may remember this. Without it, the default is 24 hours 9. The URL and origin do not change 11.
Alt-Svc is only a hint. The client may try QUIC after it sees one 6. If UDP is blocked, RFC 9114 tells clients to use HTTP over TCP instead 6. So keep TCP serving too.
What changes for backend engineers
- Load balancers often split the versions. An AWS Application Load Balancer can accept HTTP/2 from browsers. By default it still sends requests to your servers over HTTP/1.1 12. You can choose HTTP/2 or gRPC per target group, only behind an HTTPS listener. With HTTP/2 chosen, requests that arrive as HTTP/1.1 fail 12.
- One connection means less spread. An HTTP/2 client should open only one connection per host and port 3. Behind a layer 4 balancer, all its requests then reach one server. See Load balancing.
- Closing gracefully. HTTP/2 has a GOAWAY frame. Its last stream ID tells the client which requests the server may have acted on 3. The rest were not processed, so they can be retried on a new connection 3. In HTTP/1.1, a side that wants to time out should close the connection gracefully 2.
- Retries. Idempotent requests can be retried automatically after a connection fails 2. Others should not be, unless the client knows the first try was not applied 1. See Idempotency, retries and timeouts.
Trade-offs
| Option | Requests per connection | A lost packet blocks | Good fit |
|---|---|---|---|
| HTTP/1.1 | One at a time. Clients open several. 6 | Only that connection. | Simple service calls, old clients, debugging by hand. |
| HTTP/2 | Many streams on one TCP connection. 3 | All streams on the connection. 6 | Browsers and APIs with many small requests, gRPC. |
| HTTP/3 | Many streams on one QUIC connection. 6 | Only streams with data in that packet. 10 | Users on phones and lossy networks. |
| Server push | Extra responses the client did not ask for. 3 | Not relevant. | Avoid. Chrome turned it off by default. Use 103 Early Hints or preload. 5 |
Simple rule: for users on the internet, serve HTTP/2, and add HTTP/3 at the edge if your CDN or load balancer supports it. Inside your data center, the version matters less than reusing connections.
At work: how a senior uses this
- When someone says "HTTP/2 will make it faster", ask: "Faster for which clients, on which network?" Measure before and after.
- Know which version each hop speaks: client to CDN, CDN to load balancer, load balancer to server. They often differ.
- Check stream limits on both sides. A low stream limit on one HTTP/2 connection makes extra requests wait in a queue.
- During deploys, make sure servers send GOAWAY and drain, so clients move to a new connection without errors.
- Retry only idempotent requests after a connection drops. Use an idempotency key for payments.
- When you turn on HTTP/3, also watch QUIC errors and UDP traffic. Keep TCP working as the fallback.
With AI
What to ask the agent
"Here is our nginx config. Which HTTP versions does it serve to clients, and which does it use to our upstream servers? Show the exact lines."
"Our Go service calls another service over HTTP/2. Explain how the client reuses connections, and what happens to in-flight requests when the server sends GOAWAY."
"Write a load test that compares HTTP/1.1 and HTTP/2 with 2% packet loss. Explain what I should expect and why."
What to check yourself
- Every setting the agent names exists in your server or library version. Check the docs.
- The agent does not suggest HTTP/2 server push. Chrome turned it off by default 5.
- Claims like "HTTP/3 is always faster" are tested on your own traffic, with loss and without.
- Retries are added only for idempotent requests.
- The agent knows that the load balancer may speak a different version to your servers than to clients.
Check yourself
Your progress is saved only in this browser. Export it to keep it safe.
You have finished 5 lessons. Your progress lives only in this browser. Export a copy so you don’t lose it.
Go deeper
Show 12 sources and related lessons
- Fielding, Nottingham and Reschke (eds.), RFC 9110: HTTP Semantics (IETF, 2022) (opens in a new tab)
Methods, status codes and headers. Section 1.2 says all three HTTP versions share these semantics. - Fielding, Nottingham and Reschke (eds.), RFC 9112: HTTP/1.1 (IETF, 2022) (opens in a new tab)
Section 9 covers persistent connections, pipelining, how many connections to open, and timeouts. - Thomson and Benfield (eds.), RFC 9113: HTTP/2 (IETF, 2022) (opens in a new tab)
Section 1 says why HTTP/2 exists. Frames, streams, SETTINGS, GOAWAY and connection rules follow. - Peon and Ruellan, RFC 7541: HPACK: Header Compression for HTTP/2 (IETF, 2015) (opens in a new tab)
Section 1 explains why headers needed a new, safer compression format. - Barry Pollard, “Remove HTTP/2 Server Push from Chrome”, Chrome for Developers blog, 2022 (opens in a new tab)
Why Chrome turned off server push, with usage numbers and the suggested alternatives. - Bishop (ed.), RFC 9114: HTTP/3 (IETF, 2022) (opens in a new tab)
Section 1 compares the three versions. Section 3.1 explains how a client finds an HTTP/3 server. - Iyengar and Thomson (eds.), RFC 9000: QUIC: A UDP-Based Multiplexed and Secure Transport (IETF, 2021) (opens in a new tab)
QUIC streams, and section 9 on connection migration. - Friedl, Popov, Langley and Stephan, RFC 7301: TLS Application-Layer Protocol Negotiation Extension (IETF, 2014) (opens in a new tab)
How client and server agree on "h2" or "http/1.1" inside the TLS handshake. - Nottingham, McManus and Reschke, RFC 7838: HTTP Alternative Services (IETF, 2016) (opens in a new tab)
The Alt-Svc header, and how long a client may remember it. - MDN Web Docs, “Evolution of HTTP” (opens in a new tab)
A short history from HTTP/0.9 to HTTP/3, in plain words. - MDN Web Docs, “Alt-Svc header” (opens in a new tab)
Examples of the header, with the ma and persist parameters. - AWS, Elastic Load Balancing User Guide, “Target groups for your Application Load Balancers” (opens in a new tab)
The "protocol version" setting, which decides if the load balancer talks HTTP/1.1, HTTP/2 or gRPC to your servers.
Related: TCP/IP and the network stack · TLS and secure connections · WebSockets, SSE and long polling · Load balancing · CDNs and HTTP caching · RPC and gRPC (coming soon)
- TCP/IP and the network stack: handshakes, packet loss and head-of-line blocking.
- TLS and secure connections: how ALPN fits into the handshake.
- WebSockets, SSE and long polling: long-lived connections on top of HTTP.
- CDNs and HTTP caching: where HTTP/3 is often turned on first.