Repository navigation
Design HTTP 3
Status: first version implemented (phases 1-4, GSO from 5); see HTTP/3 · Builds on: HTTP/2, TLS 1.3 handshake · Date: 2026-12-02
HttpArena scores an HTTP/3 family (baseline-h3, static-h3: 64 QUIC connections, 64 streams each, port
8443) with its own composite and medals, and the overall composite adds it to H/1.1, H/2, gRPC and WebSocket.
An entry without it scores 0 there. Twelve experimental entries have it; the leader (valk) does 8.2M req/s on
baseline-h3 and 1.0M on static-h3.
- No third-party code (ROADMAP principle 2, AGENTS.md). There is no QUIC in V's stdlib and mbedtls has no QUIC API, so QUIC (RFC 9000), its TLS mapping (RFC 9001), loss recovery and congestion control (RFC 9002), HTTP/3 (RFC 9114) and QPACK (RFC 9204) are viltrum's own.
- Crypto is what viltrum already has: the hs13 handshake (X25519, RSA-PSS, the key schedule on mbedtls' SHA-256
and HKDF) and the own AES-128-GCM (
aesgcm.h). New: one AES block for header protection (the GCM context already holds the key schedule). - Same worker model: QUIC runs on the epoll workers beside TCP, through the same router and
Ctx.
Server only. What h2load-h3 (ngtcp2 + quictls) and curl send, and nothing past it:
| In | Out (answered with a connection close or dropped) |
|---|---|
QUIC v1, TLS_AES_128_GCM_SHA256, X25519, RSA certificate (hs13's set) |
other versions (Version Negotiation is sent), other suites and groups |
| Initial, Handshake and 1-RTT packets; key update started by the client | 0-RTT, Retry, connection migration, preferred address |
| ACK, CRYPTO, STREAM, MAX_DATA, MAX_STREAM_DATA, MAX_STREAMS, RESET_STREAM, STOP_SENDING, PING, PADDING, CONNECTION_CLOSE, HANDSHAKE_DONE, NEW_CONNECTION_ID (one spare) | DATAGRAM, unidirectional streams other than HTTP/3's control and QPACK streams |
| QPACK with the static table only: the decoder announces capacity 0, the encoder never inserts | the dynamic table (a client may not use it when we announce 0) |
| HTTP/3 requests through the router, responses with trailers, files | server push, CONNECT, WebTransport |
| Piece | What |
|---|---|
engine/quic.h, engine/quic_linux.c.v
|
packet protection: Initial secrets, HKDF labels (quic key, quic iv, quic hp), header protection, AEAD seal/open on viltrum_gcm; RFC 9001 Appendix A vectors in tests. Also the UDP batch (recvmmsg, sendmmsg with UDP_SEGMENT) |
engine/hs13.h (QUIC mode) |
hs13 without its record layer: the ClientHello from CRYPTO frames, the quic_transport_parameters extension both ways, ALPN h3; ServerHello in an Initial, EncryptedExtensions to Finished in Handshake packets |
engine/quic_conn_linux.c.v |
connections keyed by our 8-byte connection ID; packet parse, frames, streams, flow control, ACK ranges, loss detection, PTO and NewReno (RFC 9002), idle timeout; per-worker pools of streams and send buffers |
http2/qpack.v |
QPACK static encode and decode beside HPACK, sharing its integers, strings, Huffman code and Fields
|
engine/h3_linux.c.v |
requests: decoded fields become an HTTP/1.1 head as on HTTP/2, so parse_head checks them and the same Ctx runs; the response head goes out as QPACK (memoized by head text), the body and a file as one DATA frame |
First-version shortcuts, each marked shortcut: in the code: no key update (such packets are dropped), no
draining period on close, NEW_CONNECTION_ID ignored, the client's control and QPACK streams read and dropped,
deferred, streamed and WebSocket responses answered 501, no Alt-Svc, no response trailers.
Memory: a finished stream goes back to a per-worker pool at once and keeps a 1 KiB send buffer; larger buffers (16, 64, 256 KiB) are lent while a response sends and pooled by size, a few MiB per worker at most. A connection stops serving new requests while 512 KiB of answers wait unsent, so its memory follows what the network takes rather than what was asked.
Sockets: each worker binds a UDP socket with SO_REUSEPORT on the TLS listener's port. The kernel picks the
socket by the 4-tuple, so without migration every packet of a connection reaches the worker that owns it.
Reads with recvmmsg, writes with sendmmsg and UDP GSO (UDP_SEGMENT) for a run of full packets; a
response of several packets goes in one call. Buffers are lent per event, as for TCP (Phase 8): a quiet
connection keeps its keys, its stream table and the ranges it must acknowledge, nothing else.
Listener: Listener{ addr, http2: true, http3: true, tls: ... } also answers QUIC on the same port number and
announces it with Alt-Svc: h3=":port" on its HTTP/1.1 and HTTP/2 responses.
Each ends green, in its own PR.
- Packet protection and Initial keys, header protection, varints, packet number encoding; RFC 9001 Appendix A as tests.
- The handshake over CRYPTO frames, transport parameters, ACKs, the handshake done with
h2load-h3and curl on hostlab (a QUIC-capable curl or ngtcp2's own client, in a container). - Streams, flow control, loss recovery, congestion control, idle timeout, connection close; a loss test (packets dropped on purpose) in the engine tests.
- HTTP/3 and QPACK;
baseline-h3andstatic-h3validate in HttpArena; h3spec in the spec column. - Throughput: batching, GSO, ACK frequency, the allocation gate for an HTTP/3 request.
scripts/udp_lossy_proxy.py LISTEN TARGET LOSS [REORDER] sits between a client and the server and drops
and reorders datagrams both ways (standard library only; no tc/netem, which would touch every service on
lo). With h2load --alpn-list=h3 through it, baseline-h3 and static-h3 finish every request at 2%, 5%
and 10% loss with reordering, 64 handshakes included. It found a stream that never finished when a late ACK
for a copy sent again left an acked range below tx_base (the client stopped at its MAX_STREAMS), now a
test in engine/quic_linux_test.v.
- Size: about as much code as HTTP/2 and TLS together. Phases 1-3 are the transport alone.
- A loopback benchmark hides congestion-control bugs that show on real networks: phase 3's loss test covers them before 4 is released.
- The UDP receive buffer is the queue under load:
SO_RCVBUFis raised as far as the host allows, and drops are counted in the stats.