Enable HTTP/2 multiplexing on relay-directory hop#1655
Conversation
530deba to
4bb5d84
Compare
Coverage Report for CI Build 27794494492Coverage decreased (-0.01%) to 85.213%Details
Uncovered Changes
Coverage Regressions1 previously-covered line in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
|
I was under the impression that multiplexing would have been much more complicated than a dependency update and a 4-line change (excluding tests). This approach seems like the right one. Some way to benchmark and stress test simulated network activity might be something we want sooner than later. @pseudozach mentioned load testing and benchmarks last week. |
thank you for taking the time to read my various posts on this. |
Under BIP-77 the directory only sees peer relays, and each waiting receiver is a long-poll the relay holds open. The relay's outbound client and the directory's ACME server path negotiated HTTP/1.1 only, which carries one request per connection at a time. A single busy relay therefore pinned one directory file descriptor per concurrent long-poll and could exhaust the descriptor limit on its own. HTTP/2 multiplexes concurrent requests over a single connection, decoupling in-flight requests from connection (descriptor) count. Offer h2 on the relay's hyper-rustls client, which negotiates via ALPN and falls back to HTTP/1.1 for gateways that do not support it, and advertise h2 in the ACME server's ALPN, since tokio-rustls-acme otherwise sets only the acme-tls/1 challenge protocol.
4bb5d84 to
a86a499
Compare
|
I've removed the integration tests since the intention was just to demo that this change collapses the number of connections. I think this is mergeable as-is |
|
fwiw I did a quick load test against payjoin-mailroom to see the impact of this HTTP/2 multiplexing change on FD usage using h2load
Baseline (before this PR, current master): Observed: With this PR: Observed: So for the same 1000-request workload, multiplexing stopped FD growth which kinda makes sense but I thought it's good to prove it/see it regardless. |
The relay's outbound client and the directory's ACME server now negotiate HTTP/2, so a relay's concurrent forwarded requests multiplex over one connection instead of pinning one directory file descriptor each.
Note that HTTP/2 over TLS is selected by ALPN during the TLS handshake. So multiplexing only reaches the mailroom if the process that the relay's TLS connection terminates against negotiates h2. payjo.in runs direct ACME on port 443, so this change is sufficient to multiplex relay -> directory in production with no proxy change.
The
multiplexing_testsare more of a demo than real unit tests so I'm leaving this PR in draft with those included until we agree on an approach, then I think these can be dropped.co-authored by Claude Opus 4.8
Pull Request Checklist
Please confirm the following before requesting review:
AI
in the body of this PR.