This is a performance issue and a proposal to enhance performance / throughput.
Problem
ProxyServer::handle_http_request opens a fresh TcpStream::connect and performs a new Hyper HTTP/1.1 client handshake for every incoming request. This disables keep‑alive reuse and adds per‑request connection overhead (DNS resolution, TCP handshake, HTTP handshake).
- File:
src/lib.rs
- Function:
ProxyServer::handle_http_request
Impact
- Throughput is limited by connection setup rather than request handling.
- Higher latency under load.
- Increased CPU usage and ephemeral port churn.
Proposed fix
Introduce outbound connection reuse:
- Maintain a persistent HTTP client connection to the target service.
- Prefer HTTP/2 upstream when available to multiplex requests.
- Avoid
TcpStream::connect per request.
Acceptance criteria
- Outbound connections are reused across multiple requests (observable via logs).
- Nice to have: throughput improves in a load test vs. current baseline.
- No regression in proxy correctness (headers, attestation metadata, error handling).
Notes
The current code creates the outbound connection here:
src/lib.rs → ProxyServer::handle_http_request (TcpStream::connect, http1::Builder::handshake).
This is a performance issue and a proposal to enhance performance / throughput.
Problem
ProxyServer::handle_http_requestopens a freshTcpStream::connectand performs a new Hyper HTTP/1.1 client handshake for every incoming request. This disables keep‑alive reuse and adds per‑request connection overhead (DNS resolution, TCP handshake, HTTP handshake).src/lib.rsProxyServer::handle_http_requestImpact
Proposed fix
Introduce outbound connection reuse:
TcpStream::connectper request.Acceptance criteria
Notes
The current code creates the outbound connection here:
src/lib.rs→ProxyServer::handle_http_request(TcpStream::connect,http1::Builder::handshake).