arthrop0d

Brief articles on varied topics.

HTTP/2 Streams, Frames, and HTTP/3 Head-of-Line Blocking

networkingweb development

HTTP/2 multiplexes many logical request-and-response exchanges over one TCP connection by splitting them into independently identified streams and small frames. HTTP/3 keeps the multiplexing model but moves it onto QUIC, a transport protocol that lets packet loss affect one stream without blocking delivery on every other stream.

The problem HTTP/2 was designed to solve

HTTP/1.1 commonly uses one TCP connection per request at a time, or a small pool of persistent connections. Browsers open several connections to the same server so that a slow response does not stop every other resource. That works, but it consumes connection and server resources, repeats connection setup, and limits how efficiently the client and server can share bandwidth.

HTTP/1.1 also has pipelining, where a client sends multiple requests before earlier responses finish. Responses must come back in request order, so a slow first response can hold up later responses. In practice, unreliable pipelining support made multiple connections the more common workaround.

HTTP/2 addresses this at the application protocol layer. Instead of treating a connection as one ordered sequence of complete responses, it lets one connection carry many concurrent streams.

Streams and frames

A stream is a logical, bidirectional conversation within an HTTP/2 connection: typically one request and its response. A stream has an integer identifier, so the receiver can tell which request a piece of data belongs to.

A stream is not sent as one large block. HTTP/2 divides its contents into frames, small protocol units with a type, a stream identifier, and a payload. Common frame types include:

Because every frame identifies its stream, the sender can interleave frames from different requests on the same connection:

HEADERS  stream 1   GET /index.html
HEADERS  stream 3   GET /app.js
DATA     stream 1   first part of the HTML
DATA     stream 3   first part of the JavaScript
DATA     stream 1   rest of the HTML

The receiver groups frames by stream and reconstructs each request or response independently. This is the useful meaning of multiplexing: the application sees several concurrent exchanges, while the network sees one connection carrying an interleaved sequence of protocol data.

HTTP/2 can also use stream priorities and flow control. Priorities express which streams should get attention first; flow control prevents a fast sender from overwhelming a receiver. These features help manage shared capacity, but they do not change the transport underneath.

Why TCP still creates head-of-line blocking

HTTP/2 normally runs over TCP. TCP presents applications with one reliable, ordered byte stream. If bytes 1 through 10,000 have been sent but bytes 4,000 through 4,500 are lost, TCP does not deliver bytes after that gap to HTTP/2 yet—even if those later bytes contain complete frames for unrelated streams.

This is head-of-line blocking: a missing item near the front prevents later items from being delivered. In this case, the blocked item is not necessarily an HTTP/2 stream. It is a missing range of TCP bytes, and all HTTP/2 streams sharing the connection are behind it.

Consider two responses sharing one connection:

TCP data:  [stream 1 frame][stream 3 frame][stream 1 frame][stream 3 frame]
                                      ^
                                  segment lost

The receiver may have the third and fourth pieces already, but TCP withholds them from HTTP/2 until the missing segment is retransmitted and placed in order. Stream 3 therefore waits even if stream 1 is the only stream whose bytes were lost.

This is why “one connection” is both HTTP/2’s efficiency advantage and its failure domain. A lost packet can briefly stall unrelated requests. The delay is especially visible on networks with high round-trip time, where retransmission takes longer. HTTP/2 has not failed to multiplex; the lower layer is enforcing its own ordered delivery rule.

You may encounter this indirectly in browser network timing, HTTP/2 performance investigations, or logs that identify a connection as h2. A page can show several requests in flight while many of them pause together after loss. Opening additional connections can sometimes reduce the shared stall, but it gives up part of HTTP/2’s intended efficiency.

How HTTP/3 changes the transport

HTTP/3 uses QUIC instead of TCP. QUIC runs over UDP, but “uses UDP” is not the important feature by itself. UDP provides datagrams; QUIC adds encrypted connections, reliable delivery, congestion control, and independently managed streams above those datagrams.

QUIC gives each stream its own ordered byte sequence. A QUIC packet can carry frames for one or more streams, and packets are numbered for acknowledgment and loss detection. If a packet carrying data for stream 1 is lost, QUIC retransmits the missing stream data. Data for stream 3 that arrives in later packets can be delivered to the application immediately; it does not have to wait for stream 1’s missing bytes.

The contrast is:

Transport Effect of losing data for one stream
HTTP/2 over TCP TCP withholds later bytes for every stream until the gap is repaired
HTTP/3 over QUIC The affected stream waits, while other streams can continue

HTTP/3 therefore removes this particular connection-level head-of-line blocking. It does not make loss free. QUIC still retransmits missing data, still shares congestion control across streams, and still has connection-level flow-control limits. A congested or disconnected path can slow every stream. The improvement is more precise: an ordered-delivery gap in one stream no longer forces unrelated streams to wait at the transport layer.

The overall model remains familiar—requests are multiplexed rather than assigned one connection each—but the transport now preserves independence between those requests where TCP could not.

← All articles