openvpn.is
English
简体中文繁體中文EnglishРусскийفارسی

HomeBlogSpeed

A narrow bridge makes a queue

Why OpenVPN does not fill your line and how to speed it up: UDP, AES-GCM, DCO kernel acceleration, no compression, mssfix, and how to measure.

Compiled on

The bridge is this wide and no wider
The bridge is this wide and no wider Mikra72, CC0

Slow OpenVPN is seldom slow encryption. It is packets being carried back and forth between the kernel and the program.

Slow has to be measured first. 80 out of 300 Mbps and pages that do not load are different problems. Write down three numbers.

Measure, do not guess

Three tests
iperf3 -c server-public-ip    # without the tunnel
iperf3 -c 10.9.0.1            # through the tunnel
top                           # how much CPU openvpn takes
ResultThe limit
Slow without the tunnel tooThe line
Slow in the tunnel, one core at 100%CPU
Slow in the tunnel, CPU idleLoss, MTU or TCP in TCP
A car on a narrow road: single-threaded and TCP is a one-lane road
A car on a narrow road: single-threaded and TCP is a one-lane road Eric Jones, CC BY-SA 2.0

What helps, biggest first

  1. TCP to UDPThe largest difference on lossy lines
  2. Turn on DCOData stays in the kernel; automatic with 2.7 and a new kernel
  3. AES-GCMMuch faster than old CBC on processors with AES instructions
  4. No compressionTraffic is mostly encrypted already; it also harms security
  5. mssfix 1360When pages stop halfway or large files stall
One at a time

Is DCO in use

In the server log
sudo journalctl -u openvpn-server@server | grep -i dco

Linux has the ovpn module since kernel 6.16. The Windows community edition uses the ovpn-dco driver by default, and wintun was dropped in 2.7. comp-lzo, old ciphers or TAP mode fall back to the slow path.

A queue of cars: enable DCO and AES-GCM to get it moving
A queue of cars: enable DCO and AES-GCM to get it moving Philip Mallis, CC BY-SA 2.0

Very slow on a router

Old routers have no AES instructions. Use CHACHA20-POLY1305, or move OpenVPN to a small PC.

Three numbers

NumberHow
A: without VPNA speed test
B: to the server, no tunneliperf3 -c public-ip -R
C: to the server, in the tunneliperf3 -c 10.9.0.1 -R

B far below A: the line to the server. C near B: the tunnel is fine. C far below B: read on.

C far below B

Both ends
top -d 1

One core full with openvpn is the processor's limit; the data channel uses one thread. If it is not full, look for loss and MTU:

Through the tunnel
ping -n 100 10.9.0.1
ping -f -l 1400 10.9.0.1

Turning on DCO

Both ends 2.6 or later, AES-GCM or CHACHA20, no compression, tun mode, and the ovpn kernel module or ovpn-dco:

Linux server
uname -r
modinfo ovpn 2>/dev/null | head -3
sudo journalctl -u openvpn-server@server | grep -iE "dco|data channel offload"

DCO device tun0 opened means yes. disabling data channel offload names the option that prevents it; remove that option.

Compression slows things down

Pages and videos are compressed already. Worse, compressed lengths leak contents. Remove comp-lzo and compress on both sides.

Ciphers

ProcessorFastest
Computers of the last ten yearsAES-GCM
Old routers without AESCHACHA20-POLY1305
BF-CBC anywhereReplace it

grep -o -m1 aes /proc/cpuinfo prints aes if it is there.

The server is in the wrong place

A single download slows with latency. A nearer server beats any parameter. Many parallel connections hide this, which is why speed tests look good and video does not.

Would another protocol be faster?

On the same line WireGuard usually is. If the line is slow, nothing helps.

AdLuoboyunTo compare with another line: take 1 GB of trial traffic and test within 24 hours; Alipay, WeChat and crypto accepted.Take it and compare
Do larger buffers help?

Systems adjust them now. Most sndbuf advice on the web is out of date.

sndbuf and rcvbuf?

Set to 0 or removed; the old numbers are ten years out of date.

Phones are slower?

OpenVPN 3 on phones has no kernel acceleration; tens to a bit over a hundred Mbps is normal.

How much faster is WireGuard?

Two or three times when the processor is the limit, nothing when the line is.

Walk on

Nearby gates

Signposts: OpenVPN slow, OpenVPN DCO, OpenVPN speed up, OpenVPN MTU