flashbots / flashbots/attested-tls-proxy
Proxy server opens a new outbound TCP/HTTP connection per request (no reuse)
- Dominant language
- Rust
- Stars
- 6
- Forks
- 2
- Avg merge
- 13m
- Merged PRs (30d)
- 3
Description
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`).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.