The labs on this site need JavaScript to run. The same content is written out below.
Learn › Networking › HTTP
What differs between the versions when you fetch 30 files
Why it exists — As a single page grew to dozens of files, HTTP/1.1, which receives responses one after another, forced workarounds such as combining images into one or splitting content across several domains. HTTP/2 gives each request a numbered stream so that it no longer waits for the response before it, and HTTP/3 moved to QUIC over UDP so that streams are also handled separately at the transport level.
Where it's used today — The major browsers, CDNs, and nginx support HTTP/2, and HTTP/3 is also used by large sites and CDNs. Spring Boot turns on HTTP/2 with server.http2.enabled, but when nginx or a load balancer sits in front, it is common for that component to handle HTTP/2 and HTTP/3 with the browser and for the servers behind it to receive HTTP/1.1. gRPC, which servers use to call each other, also runs over HTTP/2.
A single web page is made of dozens of files (scripts, styles, images). HTTP/1.1 receives only one file at a time on a connection, so requests have to wait in line, while HTTP/2 mixes several requests on one connection. HTTP/3 changes even the transport layer below it.
Partly checked against real execution · The number of connections, the queuing, and the round trips of connection setup were run and checked with nginx 1.27 and Chromium, and HTTP/3 was really run. Packet loss was confirmed only with 6 files, and the times are assumed values
# application.yml
server.http2.enabled: false # browsers use HTTP/2 only over TLS (https)
# nginx
server {
listen 443 ssl;
...
}
<!-- Files requested by one page: 30 -->
This is a model built from assumed times. It assumes that it takes 100ms to receive one file, 200ms to retransmit a lost packet, and, to set up the connection, 30ms for HTTP/1.1 and HTTP/2 (the 6 connections of HTTP/1.1 are opened at the same time) and 15ms for HTTP/3. The real numbers depend on the network and the file sizes. The ratio of the connection setup times (2 to 2 to 1), the number of connections, and the queuing were checked by really running them. nginx 1.27.5 (http2 on, listen quic) and Chromium 151 (run without a window) were put on a Docker network, a delay was added so that one round trip takes 500ms (tc netem), and 6, 30, and 60 files of 1000 bytes were requested at the same time. Setting up the connection took 2 round trips for HTTP/1.1 and HTTP/2 (TCP and TLS 1.3) and 1 for HTTP/3 (QUIC). HTTP/1.1 received the files 6 at a time on 6 connections (30 files in five batches, and 60 files in ten batches in one run and eleven in another), and HTTP/2 (6, 30, and 60 files) and HTTP/3 (6 and 30 files) sent every request on 1 connection without waiting. However, with HTTP/2 the responses for 30 and 60 files arrived split over two or three round trips because of the TCP congestion window, so they did not finish in one go as in this model. Packet loss was produced by dropping one large packet from the server on the browser side (iptables). With 6 files, it was confirmed twice each that with HTTP/2 all 6 files finished one round trip late and that with HTTP/3 only 1 file finished late. In the loss combinations with 30 and 60 files, the number of late files differed from run to run (5 and 9 with 30 files on HTTP/1.1), and the runs that fetched 60 files over HTTP/3 and some of the other HTTP/3 runs failed, so these combinations could not be confirmed by running. The parts that were not confirmed follow the descriptions in the standards (RFC 9112, 9113, 9114, and RFC 9000 for QUIC). The 6 HTTP/1.1 connections to the same server is the value seen in Chromium, and it is known as the default of the major browsers.
Previous lab: HTTP messages and status codes · Next lab: Cookies
Struck-through text was removed from the first version of the code; highlighted text was added.