Workspace

QUIC and HTTP/3

3 day streakD

QUIC and HTTP/3

QUIC rebuilds TCP's job in user space on top of UDP, with TLS built in and streams in the transport. Learn what that changes, what it costs, and when not to use it.

DepthLesson 5 of 622 min

QUIC is a transport protocol that runs over UDP. It provides what TCP provides, reliability, ordering and congestion control, plus what TLS provides, and it knows about streams. HTTP/3 is HTTP semantics mapped onto QUIC streams.

What QUIC changes

  1. 01
    One handshake, not two

    Transport and TLS 1.3 handshakes combine. A new connection needs 1 round trip before the request, against 2 for TCP plus TLS.

  2. 02
    Streams in the transport

    Loss is recovered per stream. A lost packet stalls only the streams whose data it carried.

  3. 03
    Connection IDs

    Connections are identified by an ID, not the 4-tuple. A phone moving from Wi-Fi to cellular keeps its connection.

  4. 04
    Never-reused packet numbers

    A retransmission gets a new packet number, so an ACK always says which transmission arrived. RTT measurement becomes unambiguous.

  5. 05
    Encrypted headers

    Almost all of the header is encrypted. Middleboxes cannot inspect or depend on it, so the protocol can keep evolving.

Figure 5.1

Changing networks mid-download

TCP: the 4-tuple is the connection

  1. Streaming from 10.0.0.5:51000 on Wi-Fi
  2. Phone switches to cellular: new address 100.64.3.9
  3. Server has no connection for the new 4-tuple: reset
  4. Client reconnects: TCP + TLS handshakes, slow start
  5. Request is sent again; tokens 1–900 are generated again or lost
token 900 ✓
── network change ──
ECONNRESET
reconnect … 3 RTT
answer restarts

QUIC: the connection ID is the connection

  1. Packets carry destination connection ID 7f3a…
  2. Phone switches to cellular: new address, same ID
  3. Server matches the ID to the existing connection
  4. Path validation: PATH_CHALLENGE and PATH_RESPONSE
  5. Stream continues from token 901
token 900 ✓
── network change ──
path validated (1 RTT)
token 901 ✓ token 902 ✓
A phone leaves Wi-Fi at token 900. With TCP, the 4-tuple changes, the connection breaks, and the client must reconnect and re-request. With QUIC, packets from the new address carry the same connection ID, and the server validates the new path and continues.

What it costs

  • CPU. QUIC runs in user space with less hardware offload than TCP, so CPU cost per byte is usually higher. Kernel-bypass and UDP segmentation offload narrow the gap.
  • Blocked UDP. Some enterprise and hotel networks block or throttle UDP. Clients must fall back to TCP, and race both to avoid waiting.
  • Tooling. Encrypted headers that block middleboxes also block your packet captures. Use qlog, QUIC's structured event log, and qvis to visualise it.
  • 0-RTT replay. As with TLS 1.3, early data can be replayed. Accept it only for idempotent requests.

QPACK

HPACK assumes headers arrive in order, which TCP guaranteed. QUIC streams arrive independently, so HTTP/3 uses QPACK: dynamic-table updates travel on a dedicated stream, and a request referencing an entry the decoder has not yet received must wait. That is the last place head-of-line blocking survives in HTTP/3, and encoders can trade compression for avoiding it.

How a client finds HTTP/3

A client cannot assume a server speaks QUIC. It learns from an Alt-Svc: h3=":443" response header on an HTTP/2 connection, or before connecting from an HTTPS DNS record. Browsers then race QUIC against TCP and use whichever connects first, remembering failures.

SituationBetter defaultWhy
Mobile users, long or lossy pathsHTTP/3Independent stream recovery, 1-RTT setup, connection migration
Service to service inside one regionHTTP/2Loss is near zero, CPU and tooling are cheaper
Browser to CDNBoth, racedLet the client pick what works on its network
Long-lived streaming to phonesHTTP/3 or resumable streamsSurvive network changes (Module 6)
Go deeperWhy build a transport on UDP at all?

TCP lives in operating system kernels, and changing it needs billions of devices to update. Worse, firewalls and NATs inspect TCP headers and drop anything unfamiliar, which is how TCP Fast Open stalled. UDP is a thin, universally forwarded wrapper. A transport built on it can live in an app or a library and change every release.

Encryption is the second half of the trick. Because QUIC encrypts nearly every header field, middleboxes cannot build features that depend on them, so they cannot freeze the protocol. Designers sometimes call this “greasing”: deliberately sending unused values so nobody can assume they never appear.

Where you will meet it

Video and apps

Large apps that ship their own networking stacks use QUIC to their own servers and see the biggest gains on poor mobile networks.

Internal services

Most service meshes and gRPC deployments stay on HTTP/2 inside the data centre.

Proxying with MASQUE

MASQUE tunnels UDP and IP traffic over HTTP/3, used by privacy relays such as iCloud Private Relay.

Words to know

QUIC
A UDP-based transport with built-in TLS 1.3 and streams.
Connection ID
QUIC's identifier for a connection, independent of IP address and port.
QPACK
HTTP/3 header compression adapted for out-of-order streams.
Alt-Svc
A response header advertising that a service is also available another way, such as HTTP/3.

Check yourself

Answer out loud before you open each one.

When would you not use HTTP/3 between internal services?

When loss is near zero, so its main benefit disappears, while CPU cost, offload and tooling are worse.

How does QUIC survive a network change?

Connections are identified by connection IDs, not addresses and ports, so packets from the new path still match.

Why do clients race QUIC against TCP?

UDP may be blocked or throttled. Racing avoids waiting on a QUIC attempt that will never succeed.

Try it

Run curl --http3 -sI https://cloudflare.com (with an HTTP/3-enabled curl) and look at the first line. Then check Alt-Svc in curl -sI --http2 output for the same site.

A good place to start

Explore a pattern

A little guidance

Start with a pattern, read through a problem, and mark it solved when the idea clicks. Save anything you want to revisit.

New tutorials are added one at a time. Your bookmarks and solved checkmarks stay in this browser.

Explore the roadmap