Benchmarks
Everything below runs on one machine over loopback, so it measures the cost Tunnex adds, not a network.
Run it yourself with bench/run.sh: it starts the upstream (bench/upstream.py),
a server with bench/server.yaml and a client, then drives the load with
bench/bench.py (httpx), once with the inspector recording and once with --no-inspect.
bench/run.sh # this checkout
TUNNEX=/path/to/venv/bin/tunnex NO_UI=--no-dashboard bench/run.sh # a 26.10.10 release from PyPI
Current client vs. the last release (2026-10-14)
Same server (this branch), same upstream, client on Python 3.12, 16-thread laptop under desktop load. Ranges are over three runs; loopback numbers move by ±15 % between runs, so compare ranges, not single values.
| Metric | 26.10.10.22 (PyPI) | This branch |
|---|---|---|
| Small GET, p50 latency | 1.6–1.9 ms | 1.5–1.9 ms |
| Small GET, p99 latency | 2.2–3.6 ms | 2.5–3.4 ms |
| Throughput, 50 in flight, inspector recording | 297–306 req/s | 297–304 req/s |
Throughput, 50 in flight, --no-inspect |
517–650 req/s | 485–540 req/s |
| Download 50 MB | 5.1–6.2 Gbit/s | 4.5–5.9 Gbit/s |
| Upload 20 MB | 0.05–0.07 s | 0.04–0.06 s |
| SSE, first of 10 events, inspector recording | 17–18 ms | 15–20 ms |
SSE, first of 10 events, --no-inspect |
5 ms | 4 ms |
Two regressions were found with this runner and fixed before the release:
sniffiowas missing. It used to arrive with theanthropicdependency, which is gone. Without it httpcore retries a failedimport sniffioon every pooled request — a path search on each call, about 30 % of client throughput. It is now a direct dependency.- Local connection churn. The local HTTP pool allowed 100 connections but kept only 20 idle, so every burst above 20 closed and reopened connections to the local service (724 connects per 6 000 requests instead of ~100). Idle connections are now kept up to the pool size.
What remains is a 10–15 % lower request rate in the --no-inspect, 50-in-flight case. The forwarding
hot path (mux, framing, WebSocket options, HTTP forwarder) is the same code as in the release, client CPU
per request is the same, and the gap is inside run-to-run spread for every other metric; it is tracked
but not explained yet.
Protocol v1 vs. v2 (2026-10, historical)
Measured when the binary protocol replaced JSON + Base64 frames (v1 is commit 6c09d8a), Python 3.10 on
both sides, the v1 rate limiter disabled.
| Metric | Direct (no tunnel) | v1 | v2 (inspector on) | v2 (--no-inspect) |
|---|---|---|---|---|
| Small GET, p50 latency | 0.59 ms | 6.23 ms | 1.99 ms | 1.85 ms |
| Small GET, p99 latency | 1.23 ms | 8.33 ms | 4.27 ms | 4.29 ms |
| Throughput, 50 in flight | 779 req/s ¹ | 216 req/s | 290 req/s | 357 req/s |
| Download 50 MB | 7.5 Gbit/s | fails: HTTP 500 after 60 s ² | 4.2 Gbit/s | 3.9 Gbit/s |
| Upload 20 MB | 0.02 s | fails: HTTP 500 | 0.05 s | 0.04 s |
| SSE, first of 10 events (200 ms apart) | 15 ms | 2015 ms (buffered) | 4 ms | 4 ms |
| Wire overhead on bodies | — | +33 % (Base64) + JSON | 8-byte header per ≤64 KiB frame | same |
¹ The load generator's own ceiling on this machine; a tunnel adds two more Python HTTP hops. ² v1 sent a whole response as one WebSocket message; anything above ~750 KB hit the 1 MiB message limit, the connection closed with code 1009 and every request in flight on the tunnel failed with it.
What v2 changed:
- Streaming end to end. Bytes are forwarded as they arrive in both directions, so server-sent events, LLM token streams, long polling and large files work; the first SSE event arrives in milliseconds.
- Multiplexing with per-stream flow control. A slow download does not block other requests on the same tunnel, and memory per stream is bounded by its window (512 KiB).
- No size limits on request or response bodies.
- Capture cost. Recording every request for the local inspector costs ~20 % of peak request rate; writes are batched (one SQLite transaction per ≤500 requests) and long responses appear as pending after one second.