# ADR-0019: HTTP/3 (QUIC): supported, opt-in per listener

URL: https://scalws.com/docs/adr/0019-http3/
Source: `docs/adr/0019-http3.md` in the ScalWS repository

* Status: Accepted (2026-10-06), evaluation; shipped opt-in in the 1.0.0 packages (addendum 2026-11-07)
* Benchmark: `docs/benchmarks/2026-10-06-http3.md`

## Context
M10: evaluate HTTP/3 behind a feature flag. The Rust HTTP/3 stack is `quinn` (QUIC,
0.11, mature) with `h3`/`h3-quinn` (0.0.x, explicitly pre-1.0).

## Decision
* Cargo feature `http3` (scalws-http → scalws-server → scalwsd). Supported and opt-in: the
  packages are built with it since 1.0.0 (see the addendum; until then they contained no
  QUIC code), and every listener has `http3: false` unless the operator enables it. A
  build without the feature refuses `http3: true` at start with a clear error.
* `listener.http3: true` (TLS listeners only) binds a QUIC endpoint on the same port
  number over UDP. TLS: TLS 1.3 only, ALPN `h3`, no 0-RTT, **the listener's reloadable
  SNI resolver**: configured and ACME certificates rotate for QUIC too.
* Requests enter the same `RequestService` as HTTP/1.1/2 via `call_boxed` (the pipeline
  is generic over the request body type), so routing, limits, security rules, quotas,
  cache, telemetry and access logs are identical. Connection-specific headers are
  stripped from responses (RFC 9114 §4.2).
* Connections take a permit from the global connection limit and pass per-source
  admission; on shutdown the endpoint sends GOAWAY and in-flight requests drain.
  Transport: bidirectional streams per connection = `h2_max_concurrent_streams`, idle
  timeout = `idle_timeout`.
* TCP responses of such listeners advertise `Alt-Svc: h3=":<port>"; ma=86400`.

## Evaluation result
* Functionally complete for request/response traffic (integration test with a real
  QUIC + HTTP/3 client: GET, POST bodies, deny rules, SNI selection, Alt-Svc).
* Throughput ≈ 57 % of scalws's HTTP/2 on the same host (userspace QUIC + per-packet
  crypto) and ≈ 6× Caddy's HTTP/3; memory flat in a soak run including HTTP/3.
* A per-connection task set that kept completed requests (1.1 GiB after 10 s of load)
  was found by the benchmark and fixed before acceptance.

## Not implemented
WebSocket over HTTP/3 (extended CONNECT), 0-RTT, connection migration tuning, QUIC
metrics beyond handshakes, GSO/GRO tuning. Staying behind the feature until `h3`
reaches 1.0 or a production evaluation justifies default-on.

## Addendum (2026-11-07): shipped in the 1.0.0 packages, opt-in per listener

* **Built in.** Every release package is built with the feature: the glibc EL8 build behind
  the `.deb` and the `.rpm` and the static musl build behind the `.apk`
  (`scripts/release-build.sh`, `scripts/release-build-apk.sh`, which fail unless
  `scalwsd --features` lists `http3`). The controller's QUIC demux (`scalws-controller
  quic-lb`, the crate `scalws-quic-lb`, ADR-0039) was already in every
  `scalws-controller`. `cargo build`
  without `--features http3` still builds a scalwsd without QUIC code, which refuses
  `http3: true` as before.
* **Opt-in.** `http3` stays `false` by default. The packaged `scalws.yaml`, `scalwsctl site
  add` and the panel generators (cPanel, DirectAdmin) do not enable it; the operator
  sets `http3: true` on a TLS listener and reloads.
* **Firewall.** The package does not open UDP 443. The ufw profile `ScalWS` covers 80/tcp
  and 443/tcp only (before, it also listed 443/udp); `ScalWS HTTP3` is the separate profile
  for 443/udp. An upgrade narrows a `ScalWS` rule that an older package's first install
  added with 443/udp (`ufw app update ScalWS`): no older package could serve HTTP/3. The installation guide gives the commands for ufw, firewalld, nftables and
  awall.
* **Confinement.** The SELinux module binds UDP 443 as `http_port_t`; EL 8 and 9 label that
  port `reserved_port_t`, so `scalws_extra.cil` labels it `http_port_t` there (EL 10 and
  Fedora already do). The seccomp allowlist of `server.sandbox` (instances and demux) has
  every call quinn and quinn-udp make; a sandboxed scalwsd serving HTTP/3 is tested
  (`cmd/scalwsd/tests/sandbox.rs`). The out-of-box check `http3`
  (`tests/packaging/oobe-matrix.sh`) passed on
  AlmaLinux 8, 9 and 10, Rocky Linux 8 and 9, Oracle Linux 8 and 9, Fedora 44, Debian 12 and 13, Ubuntu 22.04, 24.04 and 26.04 (also upgrading from 1.0.0~rc.1-11 on Debian 13 and Ubuntu 24.04 and 26.04), openSUSE Leap 15.6 and 16.0, SLE BCI 15.7 and 16.0, and Alpine 3.24, and HTTP/3 under
  SELinux enforcing on AlmaLinux 8, 9 and 10 (`tests/vm/selinux-check.sh`).
  The systemd units and OpenRC's service sandbox restrict no address family and no socket
  call of the server.

Still not implemented: 0-RTT (off on purpose: replayable early data would need a per-route
idempotency policy), WebSocket over HTTP/3 (extended CONNECT), connection migration tuning
beyond routing by connection ID, QUIC metrics beyond handshakes, and HTTP/3 with `listen:
reuseport`. The `h3` crate is still 0.0.x; its version is pinned in `Cargo.lock` and updates
go through the HTTP/3 tests.
