What limits VPN throughput, and how to measure it
VPN throughput is the rate at which a tunnel moves your data. The cipher is only one part of it. This guide explains each limit on VPN speed, shows how to measure it with iperf3, and counts the bytes that WireGuard adds.
The tunnel sets the packet size
The app writes a stream. The operating system cuts it into packets that fit the MTU of the tunnel.
Each packet has a fixed cost
The client encrypts each packet, adds headers, and makes a system call to send it. The gateway does the reverse.
The path sets the ceiling
The slowest link, the latency, and the packet loss between client and gateway limit the rate.
A relay adds a detour
When no direct path exists, each packet goes through a relay. The detour adds latency and a few bytes.
What VPN throughput is
VPN throughput is the amount of data that a tunnel carries in one second. People usually give it in megabits or gigabits per second. It is the number that a file transfer or a speed test shows.
Throughput is not the same as bandwidth. Bandwidth is the capacity of a link. Throughput is what you get after every device, queue, and protocol on the path takes its share. The slowest stage on the path sets the limit.
No device announces that limit. A protocol such as TCP finds it by experiment. The sender increases its rate until packets get lost, and then it slows down. For that reason, a VPN that drops or reorders packets gets a low VPN speed even on a fast link.
What limits the throughput of a tunnel
The cost of each packet
A VPN does work for each packet. It encrypts or decrypts the payload, adds headers, and updates checksums. This cost grows with the number of packets. Modern ciphers are fast, so encryption is rarely the only limit.
A second cost applies to each operation, such as a system call or a thread wake-up. A fast VPN moves many packets in one operation. The cost of the call is then shared between all packets in the batch.
One thread or many
A data path that runs on one thread can use one CPU core. When that core is full, throughput stops, no matter how many cores the machine has. A multi-threaded data path spreads the work across cores.
Kernel or user space
A VPN in the kernel avoids copies of each packet between the kernel and a program. A VPN in user space pays for those copies. Batches and segmentation offload can remove most of the difference. The location of the code matters less than the number of operations for each packet.
MTU and fragmentation
Each link has a maximum transmission unit (MTU). The tunnel adds headers, so the packet inside must be smaller than the packet outside. If the inner packet is too large, a router fragments the outer packet or drops it. Fragmentation costs throughput, and a silent drop stalls large transfers.
TCP inside TCP
Some VPNs carry traffic in a TCP connection. Your app also uses TCP. Now two layers retransmit the same lost data, and each one slows down for the other. Throughput falls hard on a link with packet loss. A tunnel that uses UDP does not have this problem.
Latency and packet loss
A TCP sender can only have a limited amount of data in flight. With a round trip of 20 ms, a window of 1 MB permits at most 400 Mbit/s. More latency lowers the ceiling. Packet loss lowers it again, because a loss-based congestion controller cuts its window after each loss.
Relays
If two peers cannot connect directly, a relay forwards the packets. The detour adds latency, and the relay has its own capacity.
The link itself
A tunnel cannot be faster than the internet connection of either end. Check the link first.
Count the overhead
WireGuard wraps each of your packets in a new packet. The wrapper has three parts.
- The outer IP header is 20 bytes for IPv4 and 40 bytes for IPv6.
- The UDP header is 8 bytes.
- The WireGuard header and the authentication tag are 32 bytes together.
The WireGuard overhead is therefore 60 bytes over IPv4, which is 20 + 8 + 32. Over IPv6, it is 80 bytes. On a link with an MTU of 1500, the largest inner packet is 1440 bytes over IPv4 and 1420 bytes over IPv6.
A TURN relay adds 4 more bytes. The sender puts a small channel header in front of each packet, and the relay removes it before it forwards the packet.
The WireGuard MTU that you set on the tunnel must leave room for these bytes on the smallest link of the path. A value that is too high causes fragmentation. A value that is lower than necessary only costs a little efficiency, so a careful value is the safe choice.
How to measure VPN throughput
A browser speed test measures the path to a test server on the internet. It does not measure your tunnel. Use iperf3 between two hosts that you control.
- Measure the link without the tunnel. Run
iperf3 -son one host andiperf3 -c HOSTon the other. This number is the ceiling. - Measure through the tunnel. Run the same test to the tunnel address of the server. The difference is the cost of the VPN.
- Test the two directions. Add
-Rto reverse the test. Upload and download use different code paths and can give different results. - Test direct and relayed paths. If your VPN can use a relay, measure the two cases. A user on a strict network gets the relayed number.
- Repeat the test. Run each test at least three times and use the median. One run can hit a busy moment.
- Watch the CPU. If one core is at 100 percent on either end, the CPU is the limit and not the network.
One TCP stream shows what one download gets. Use -P for parallel streams to see the total capacity. Write down the latency for each result, because the same tunnel gives different numbers at 5 ms and at 100 ms.
How to get more throughput
- Prefer a direct path. Find out why a connection is relayed, and fix the firewall rule that prevents the direct path.
- Put the gateway near the users. Lower latency raises the ceiling for each TCP stream.
- Set the MTU with care. Make sure that the inner packet and the overhead fit the smallest link.
- Use a UDP tunnel. Avoid TCP inside TCP where the network permits UDP.
- Give the gateway dedicated CPU cores. A shared or burstable core gives unstable results.
- Increase the socket buffers. Small UDP buffers drop packets during a burst, and each drop looks like packet loss to TCP.
- Add gateways. When one gateway is full, spread the users across more of them.
How Firezone handles throughput
Firezone is zero trust access built on WireGuard. The data plane is written in Rust and runs in user space. Traffic goes directly between the Client and the Gateway when a direct path exists, and through a relay when it does not.
Gateway numbers from the sizing guide
- A typical Gateway can push 2 Gbps or more of peer-to-peer WireGuard traffic. That number is for a 4-core Linux machine with a recent kernel and less than 10 ms of round-trip latency.
- Gateways scale with CPU cores up to 4 cores. They use up to 4 GB of RAM for packet buffers.
- One Gateway on a 2-core VM with dedicated cores can serve up to 1,000 Clients, if the link is fast enough.
- Relayed connections carry more overhead than direct connections.
The sizing guide says that the Gateway is frequently as fast as the kernel WireGuard module, or faster. It gives multi-threading and offload as the reasons. To scale past one Gateway, add Gateways to the Site. Firezone spreads Client connections across them.
The guide also recommends larger UDP buffers on Linux. Set net.core.wmem_max to 2 MB and net.core.rmem_max to 16 MB.
Client numbers from the benchmark post
The Firezone tunnel interface uses an MTU of 1280 on all platforms. This value leaves room for the WireGuard overhead on a normal 1500-byte path.
In the article about the macOS Client, Firezone measured 5.87 Gbit/s upload and 5.76 Gbit/s download. The test used two M1 Macs with a direct Thunderbolt link and one TCP stream in iperf3. The article explains the two changes that gave this result. Backpressure stops packet loss inside the Client, and batches lower the cost of each packet.
Throughput in a TLS-based VPN, kernel WireGuard, and Firezone
The three designs make different choices about the transport and the data path. Each choice changes where the limit is.
| TLS-based VPN | Kernel WireGuard | Firezone | |
|---|---|---|---|
| Transport | TCP 443, sometimes UDP | UDP | UDP |
| Avoids TCP inside TCP | PartialOnly in UDP mode | Yes | Yes |
| Where the data path runs | User space, in most products | The kernel | User space, written in Rust |
| Uses more than one CPU core | PartialDepends on the product | Yes | YesScales up to 4 cores |
| Overhead for each packet | Varies with the protocol and cipher | 60 bytes over IPv4 | 60 bytes over IPv4, 4 more through a relay |
| Direct path between peers behind NAT | NoTraffic goes through the VPN server | NoNeeds a reachable port | YesRelay when no direct path works |
| Works on a network that blocks UDP | YesOn TCP 443 | No | No |
The table describes the usual design of each category and gives no benchmark for other products. A specific product can be different. Measure on your own hardware before you decide.
Common questions
How much does a VPN slow down my connection?
It depends on the design of the VPN, the CPU, and the path. A tunnel that uses UDP on a direct path with a modern cipher can be close to the speed of the link. A tunnel on TCP, a relayed path, or a busy CPU core can cost much more. Measure it with iperf3.
What is the WireGuard overhead for each packet?
WireGuard adds 60 bytes to each packet over IPv4 and 80 bytes over IPv6. The count is the outer IP header, 8 bytes of UDP header, and 32 bytes of WireGuard data.
What MTU should I use for WireGuard?
Use the MTU of the smallest link on the path, minus the overhead. On a 1500-byte path, the result is 1440 for IPv4 and 1420 for IPv6. Many tools use 1420 as the default. Firezone uses 1280, which is the minimum MTU of IPv6.
Is WireGuard faster in the kernel than in user space?
Not always. The kernel avoids some copies of each packet. A user space program can get the same result with batches, more threads, and segmentation offload. The Firezone sizing guide says that its Gateway is frequently as fast as the kernel module, or faster.
Why is my VPN slow only for uploads or only for downloads?
The two directions use different code paths, buffers, and sometimes different links. Test each direction with iperf3 and its -R option. A problem in one direction usually points to packet loss on the sender side.
Does a relay make a VPN slower?
Yes, in most cases. Each packet takes a longer route, and the relay adds a small header. Firezone uses a relay only when a direct path is not possible.