Your 1 GB VPS Is Enough for a Proxy
Following up on tuning a 1 GB proxy VPS : Caddy was originally in the stack for automatic TLS certificate management and the flexibility to host a real website alongside the proxy. Since I don’t actually need to host a website on a proxy VPS — and under load Caddy was burning ~55–60% of both proxy CPU and RAM just to sit between Cloudflare and Xray — I dropped it altogether and let Xray terminate TLS 1.3 + HTTP/2 + XHTTP directly, along with a few remaining OS and runtime tweaks. Everything below is backported into my VPS setup scripts .
Architecture Change
Before: Client → Cloudflare → Caddy (:443) → h2c (@xray) → Xray → Internet
After: Client → Cloudflare → Xray (:443) → Internet
Dropping Caddy removes a second Go runtime/GC, internal h2c re-framing, and
the @xray Unix-socket IPC copy:
- 15-year ECC Cloudflare Origin CA cert (
/opt/xray/{cert,key}.pem, SSL modeFull (Strict)): a one-time wildcard cert reusable across all subdomains, eliminating ACME renewal and Let’s Encrypt CT-log subdomain leakage. - Non-root
:443with full systemd hardening: settingnet.ipv4.ip_unprivileged_port_start = 443letsUser=xraybind:443with zero capabilities andPrivateUsers=yesintact. - Tighter UFW rules:
:443/tcponly accepts Cloudflare’s published IPv4/IPv6 ranges, so direct IP scans are silently dropped.
Other Optimization Points
- Go runtime & scheduling: dynamic
GOMEMLIMITcomputed from actualMemTotal(reservingmax(448 MiB, 20%)for OS/kernel and an extra1 GiBfor Docker on ≥ 4 GB VMs),GOGC=200on ≥ 2 GB VMs, plusOOMScoreAdjust=-500,Nice=-5, andCPUWeight=200onxray.service. - Kernel, swap & I/O hygiene: persisted
nf_conntrackinmodules-load.d(fixing a boot-order skip ofnf_conntrack_max), cappedip_local_port_rangebelow60000, switchedzramfromzstdtolz4(lower CPU on burstable vCPUs) with tuned VM watermarks/dirty ratios, enablednoatimeon/, disabled UFW drop logging, removedlocate, and disabledman-db/e2scrub_all/multipathd. - Tested and left at default:
mode=stream-upandstream-onefail behind Cloudflare (which buffers POST bodies at the edge), and tuningxmux(maxConnections=4vs. default) showed only marginal tail-latency gains — somode=autoand defaultxmuxstayed untouched.
Results
Verified with A/B benchmarks on both identical OCI free-tier 1 GB VMs (1/8 OCPU,
50 Mbps NIC) and a NetCup 2c/4G VM constrained to 1 GB-equivalent conditions
(2,730 MiB mlock RAM ballast + 1 GB GOMEMLIMIT + 16 MB TCP caps) up to 500
Mbps:
| Metric (Caddy + Xray → Direct Xray) | Before | After | Delta |
|---|---|---|---|
| Proxy CPU at ~485 Mbps (1-core, NetCup) | 44.5% |
22.0% |
−51% (~2× CPU eff.) |
| Proxy CPU at ~48 Mbps cap (1-core, OCI) | 25.5% |
10.8% |
−58% |
| Peak RPS on 1/8 OCPU (OCI) | 78.4 rps |
118.0 rps |
+51% (at lower CPU) |
| Proxy RSS / private RAM at 485 Mbps | 123 / 67 MiB |
39 / 13 MiB |
−68% / −81% |
| Proxy RSS / private RAM under mixed load | 169 / 113 MiB |
48 / 21 MiB |
−72% / −81% (+107M free) |
| Unloaded / loaded p50 latency (NetCup) | 41 / 50 ms |
32 / 41 ms |
−21% / −19% |
Removing Caddy cut proxy CPU roughly in half and private RAM by 70–80% while simplifying the stack to a single hardened binary — leaving plenty of headroom even on a 1 GB VPS.