Benchmarking Self-Hosted VPN Nodes: From Single-Thread to Multi-User Concurrency Analysis
Test Environment and Configuration
The tests were conducted using two Alibaba Cloud ECS instances, one as server and one as client, each with 2 vCPUs, 4 GB RAM, and a 5 Mbps bandwidth cap, running Ubuntu 22.04 LTS. The server deployed both WireGuard and OpenVPN. The client used iperf3 and flent for network performance testing. Tools included iperf3 (single/multi-thread throughput), flent (latency and throughput mixed tests), and netperp (concurrent connections).
Single-Thread Performance Baseline
Single-thread scenarios simulate typical personal user patterns such as web browsing and file downloads. Results:
- WireGuard: TCP throughput stable at 4.8 Mbps (near bandwidth limit), UDP throughput 4.9 Mbps, latency increase ~2 ms.
- OpenVPN (UDP mode): TCP throughput 4.2 Mbps, UDP throughput 4.5 Mbps, latency increase ~5 ms.
- OpenVPN (TCP mode): TCP throughput 3.1 Mbps, UDP throughput 3.5 Mbps, latency increase ~8 ms.
WireGuard shows clear performance advantages in single-thread scenarios, mainly due to its lean kernel-space implementation and lower encryption overhead.
Multi-User Concurrency Analysis
Simulated 10, 50, and 100 concurrent users, each running one iperf3 TCP stream. Results:
- 10 concurrent: WireGuard total throughput 4.7 Mbps, average per stream 0.47 Mbps; OpenVPN (UDP) total 4.0 Mbps, average 0.40 Mbps.
- 50 concurrent: WireGuard total 4.5 Mbps, average 0.09 Mbps; OpenVPN (UDP) total 3.2 Mbps, average 0.064 Mbps.
- 100 concurrent: WireGuard total 4.2 Mbps, average 0.042 Mbps; OpenVPN (UDP) total 2.1 Mbps, average 0.021 Mbps.
WireGuard maintains higher total throughput under multi-user loads, while OpenVPN degrades significantly as concurrency increases, mainly limited by user-space process scheduling and encryption context switching.
Latency and Jitter Tests
Using flent for RRUL (Realtime Response Under Load) tests, measuring ICMP latency distribution under background traffic:
- No VPN: average latency 1.2 ms, jitter 0.3 ms.
- WireGuard: average 3.5 ms, jitter 1.1 ms.
- OpenVPN (UDP): average 6.8 ms, jitter 2.5 ms.
- OpenVPN (TCP): average 12.4 ms, jitter 5.6 ms.
WireGuard significantly outperforms OpenVPN in latency and jitter control, making it especially suitable for real-time applications like VoIP and online gaming.
Optimization Recommendations
- Protocol selection: Prefer WireGuard unless legacy client compatibility is required.
- Kernel tuning: Increase net.core.rmem_default and wmem_default to 262144 to boost throughput.
- Multi-core utilization: WireGuard supports multi-queue; bind different CPU cores to handle different tunnels.
- QoS configuration: Use the tc tool to prioritize VPN traffic and ensure real-time flow performance.
Conclusion
Self-hosted VPN node performance is significantly affected by protocol implementation, concurrency model, and system tuning. WireGuard excels in both single-thread and multi-user scenarios, making it the current preferred choice for self-hosted VPNs. OpenVPN offers compatibility advantages but has performance bottlenecks. It is recommended to select and optimize based on actual user scale and business type, using test data for guidance.