Dual-Stack Xray: Cloudflare CDN vs. Direct REALITY
Following up on
dropping Caddy for direct Xray
:
after a quick detour evaluating kernel WireGuard (where macOS gVisor and iOS
NetworkExtension userspace netstacks capped out around ~370 Mbps against a
fast European VM vs. ~1 Gbps over CDN + VLESS), I stayed on Xray and added a
direct VLESS + REALITY + XTLS-Vision inbound alongside the existing
Cloudflare CDN + VLESS + XHTTP (H2) + TLS 1.3 stack in the same xray
process.
The question I wanted to answer with real measurements: does REALITY + Vision’s
zero-copy Linux splice(2) path beat Cloudflare’s split-TCP + private backbone
on European links, and how much CPU and RAM does each stack actually cost? The
dual-stack setup lives on the
reality branch
while my VPS setup scripts
on main stay on single-stack Cloudflare
CDN.
Dual-Stack Architecture
Direct REALITY: Client → Xray (:443, REALITY + Vision) → Internet
Cloudflare CDN: Client → Cloudflare (:443) → Origin Rule → Xray (:8443, XHTTP/H2) → Internet
- Single
xrayprocess: adding a second inbound shares the Go runtime and adds ~1–5 MiB at idle. - Zero cert churn: Cloudflare Origin CA certs are bound to hostnames, not
ports, so the same 15-year wildcard cert moves straight to
:8443. A free Cloudflare Origin Rule rewrites:443 → :8443so clients still hit:443on Cloudflare, while UFW restricts:8443to Cloudflare IP ranges and opens:443globally for REALITY.
Benchmark: NetCup 2c/4G VM (Vienna, 2.5 Gbps NIC)
Tested from a Mac mini in Switzerland through two local Xray SOCKS clients
against a NetCup VM in Vienna (AMD EPYC-Genoa, 2 vCPUs, 4 GB RAM, Debian 13, 2.5
Gbps NIC, GOMEMLIMIT=2112MiB), capping the test conservatively at 45% of
2-core host CPU (= 90% of 1 core) and <504 MiB RSS. Downloads used CacheFly EU
(TLSv1.3 + h2, 1,360 MB total proxied). Here TTFB (Time to First Byte,
curl %{time_starttransfer}) measures end-to-end startup latency until the
first HTTP response byte arrives, HostPk is % of the full 2-core VM, and Xr*
is 1-core Irix % (100% = 1 full core).
| Test | Stack | Mbps | TTFB | HostPk | XrUsr | XrSys | XrAvg | XrPk | RSS | CgMem | MacCPU |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Google 204 (p50) | CDN | — | 164ms | — | — | — | — | — | — | — | — |
| Google 204 (p50) | REALITY | — | 160ms | — | — | — | — | — | — | — | — |
| DL 1×50 MB | CDN | 580.5 | 167ms | 31.5% | 12.6% | 27.3% | 40.0% | 43.0% | 51.6M | 25.1M | 33.4% |
| DL 1×50 MB | REALITY | 194.2 | 165ms | 9.1% | 1.8% | 1.9% | 3.7% | 3.7% | 51.1M | 31.7M | 6.3% |
| DL 2×75 MB | CDN | 734.3 | 220ms | 35.7% | 13.7% | 27.3% | 41.0% | 53.5% | 51.1M | 28.3M | 42.8% |
| DL 2×75 MB | REALITY | 497.1 | 158ms | 14.5% | 1.2% | 3.7% | 4.9% | 7.4% | 51.1M | 39.3M | 17.4% |
| DL 4×50 MB | CDN | 767.3 | 215ms | 37.7% | 11.0% | 23.3% | 34.3% | 53.1% | 51.2M | 30.5M | 50.4% |
| DL 4×50 MB | REALITY | 368.0 | 168ms | 14.3% | 0.7% | 4.0% | 4.7% | 7.4% | 51.6M | 54.0M | 21.6% |
| DL 8×35 MB | CDN | 811.5 | 241ms | 43.4% | 14.0% | 19.5% | 33.4% | 65.9% | 51.6M | 35.0M | 60.1% |
| DL 8×35 MB | REALITY | 371.6 | 179ms | 24.1% | 1.6% | 3.6% | 5.3% | 11.1% | 51.6M | 86.3M | 19.2% |
Three things stood out:
- CDN won decisively on throughput (1.5–3× faster across every tier): CDN
scaled cleanly to 811.5 Mbps (and 580.5 Mbps on a single 50 MB
stream), while REALITY peaked at 497.1 Mbps (
2×75 MB) and settled around ~370 Mbps at 4–8 streams. Server CPU was clearly not the bottleneck (REALITY averaged ~5% of 1 core with 0% steal). Instead, Cloudflare’s local Zurich POP keeps a warm persistent HTTP/2 congestion window on a short RTT leg and rides Cloudflare’s private backbone to Vienna, whereas every new REALITY stream pays cold TCP slow-start over the public ISP-to-Netcup peering path. - REALITY + Vision is ~5× more CPU-efficient per Mbps: normalized per 100
Mbps on this VM, CDN spent ~4.5–5.6% of 1 core (
~1.8%user +~3.2%sys) vs. REALITY’s ~1.0% of 1 core (~0.24%user +~0.74%sys) — and roughly half the Mac client CPU per Mbps. Even so, the server had plenty of headroom for CDN: 811.5 Mbps averaged only 33.4% of 1 core (43.4% peak across both cores). - Loaded TTFB and memory: fresh TTFB to Vienna was a wash (~160 ms on
both), but under 2–8 concurrent streams REALITY stayed 50–60 ms snappier
(
158–179 msvs.215–241 ms) because independent TCP sockets avoid head-of-line queueing inside a shared HTTP/2 tunnel. Xray RSS stayed pinned at ~51 MiB on both; cgroup memory peaked at 86 MiB on 8-stream REALITY from kernel socket/pipe buffers used bysplice(2)(vs. 35 MiB on CDN).
Takeaway
The common advice to “always use direct REALITY for maximum speed” didn’t hold
on Zurich ↔ Vienna — network path and warm split-TCP mattered more than kernel
splice(2):
- Pick CDN (
:8443) for highest sustained throughput on cross-border links (580–811 Mbps here) and whenever origin IP hiding matters (e.g., China mainland). - Pick REALITY (
:443) for CPU-constrained servers, mobile battery savings (~5× lower server CPU/Mbps, ~2× lower client CPU/Mbps), and snappier TTFB under concurrent browsing.