Dev.to Security 🔐 Cybersecurity 👁 0 📖 4 min read

XHTTP vs TCP for VLESS + REALITY: we benchmarked both on five servers (and found our own mistake)

Last week we added a VLESS + XHTTP + REALITY inbound to every server, next to the classic VLESS + REALITY over TCP with Vision. Before telling users when to pick which, we wanted numbers: how much speed and latency does

Last week we added a VLESS + XHTTP + REALITY inbound to every server, next to the classic VLESS + REALITY over TCP with Vision. Before telling users when to pick which, we wanted numbers: how much speed and latency does XHTTP cost, and does it behave the way we assumed? It mostly performs the same. It does not behave the way we assumed.

The setup

  • Client: Xray-core 26.x on a server in a German datacenter.
  • Servers: five locations: Finland, the Netherlands, the UK, the US and Singapore. Same Xray build, same REALITY target per server for both transports.
  • Transports: VLESS + REALITY over raw TCP with xtls-rprx-vision, and VLESS + XHTTP + REALITY with the client forced to stream-one and to packet-up. The server runs mode: auto, so it accepts both.
  • Metrics: time to first byte through the tunnel to a speed-test endpoint (cold and warm), a 50 MB download and a 10 MB upload. Three runs per combination; the tables show medians.

This is datacenter to datacenter, single stream. Treat the numbers as relative, not as what you'd get on home Wi-Fi.

Throughput

Server TCP + Vision ↓ / ↑ XHTTP stream-one ↓ / ↑ XHTTP packet-up ↓ / ↑
Finland 524 / 164 526 / 162 530 / 146
Netherlands 1,001 / 89 675 / 172 678 / 173
UK 63 / 51 58 / 64 58 / 42
US 151 / 48 162 / 48 172 / 49
Singapore 80 / 25 78 / 25 85 / 27

Mbit/s, median of three runs.

On four of five servers the three options are within run-to-run noise. The interesting one is the Netherlands, the closest and fastest path: TCP + Vision hit about 1 Gbit/s down, XHTTP stopped around 675 Mbit/s. That fits how Vision works: once the inner TLS handshake is done, Xray can pass the data through with very little extra work per byte, while XHTTP always wraps it in HTTP/2 frames. You only notice the difference when the link is fast enough for CPU and framing to matter.

Upload went the other way on the same server, 89 vs 172 Mbit/s, and we couldn't reproduce a clear pattern there. Upload results on single runs were the noisiest numbers in the whole test.

Latency

Server TCP + Vision XHTTP stream-one XHTTP packet-up
Finland 187 ms 172 ms 216 ms
Netherlands 106 ms 120 ms 166 ms
UK 364 ms 239 ms 240 ms
US 539 ms 577 ms 588 ms
Singapore 816 ms 848 ms 810 ms

Time to first byte of a request through the tunnel, first request after the client starts; median of three runs.

stream-one is on par with TCP. packet-up adds 30 to 60 ms on the nearby servers and nothing measurable on the far ones, where the round trip dominates. That's expected: in packet-up the client sends upstream data as separate POST requests instead of one long request.

The part we got wrong

When we added XHTTP, we described it to users as the line to try "on networks that cut long connections". The idea was that it looks like ordinary web requests, so it should survive a network that kills long-lived streams.

So we counted TCP connections from the client to the server while running six parallel downloads, then ten quick requests in a row:

Transport During 6 parallel downloads After 10 sequential requests
TCP + Vision 6 connections 0 (each one closed when its request ended)
XHTTP stream-one 3 connections 3 (kept open and reused)
XHTTP packet-up 3 connections 3 (kept open and reused)

TCP + Vision opens one connection to the server per proxied connection and closes it when it's done. XHTTP multiplexes many proxied connections over a few HTTP/2 connections and keeps them open for reuse; Xray's XMUX settings decide how many and for how long. In other words, XHTTP creates fewer, longer-lived connections, not shorter ones. If a network kills long-lived connections, XHTTP gets no special protection. Xray will reconnect for new requests, but whatever was in flight on the killed connection drops.

What XHTTP really changes:

  • Traffic shape. The server sees HTTP/2 requests and responses instead of one raw stream per proxied connection. Some networks treat that differently from the TCP line, and when one is throttled or blocked the other often isn't.
  • Fewer handshakes. Six browser connections became three TLS sessions to the server instead of six. A network that watches how often one IP opens new TLS sessions sees less.
  • Flexible upstream. packet-up turns uploads into ordinary POST requests, which works through proxies and CDNs that don't support streaming uploads, at a small latency cost.

We've corrected the wording on our site.

How we configure it now

Server inbound (secrets shortened):

{
  "tag": "VLESS_XHTTP",
  "port": 443,
  "protocol": "vless",
  "settings": { "clients": [], "decryption": "none" },
  "streamSettings": {
    "network": "xhttp",
    "security": "reality",
    "realitySettings": {
      "target": "www.your-target.example:443",
      "serverNames": ["www.your-target.example"],
      "privateKey": "…",
      "shortIds": ["…"]
    },
    "xhttpSettings": { "path": "/your-random-path", "mode": "auto" }
  }
}

Client side, mode: auto is fine for a direct REALITY connection. Force packet-up only if something in the path doesn't handle streaming requests.

And the user-facing advice:

  1. VLESS + REALITY + Vision over TCP stays the default. Same or better speed, and the best result on fast links.
  2. XHTTP is the first fallback when the TCP line is blocked or throttled on a particular network. It costs almost nothing in speed.
  3. Don't sell XHTTP as a fix for connection resets. It doesn't do that by default.

The lesson for us was less about XHTTP than about testing our own descriptions. Fifteen minutes with ss -tn would have caught the wrong claim before it went on the website.

Disclosure: we run HorusVPN, a VPN for networks that block ordinary VPNs, and these are measurements from our own servers. Our previous post covers how we picked REALITY targets.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.