Want a quick benchmark of the network link between two servers? Compare the private networking feature offered by your favorite cloud providers? Wondering how much overhead a VPN adds?
qperf. It’s a quick, easy way to check TCP and UDP bandwidth and latencies
between two servers.
On CentOS/RHEL 7,
qperf is available from the EPEL repository. Install it
The Ubuntu/Debian repositories do not have
qperf, so you’ll need to build it
from source. This is thankfully quite easy:
You need to run qperf on two machines. On the first one,
qperf is run
in a “server” mode and on the second one,
qperf can be invoked to run
qperf without any arguments starts it in server mode. On the second
node, invoke it with the IP of the first server, and the test(s) to run. The
tests we are interested in are:
- tcp_bw and udp_bw – the rate of transfer over TCP and UDP, reported at byte-level (MB/s) and packet-level (messages/sec)
- tcp_lat and udp_lat – the average per-hop time taken for a TCP or UDP packet
By default qperf runs each specified test for 2 seconds. Add a
-v flag to
get a verbose output. Here it is in action:
The above screencast shows the execution of the tcp_bw and tcp_lat tests. The first node (node1), with the IP 10.99.0.1, is running qperf in the server mode.
Here is a sample output of the UDP bandwidth and latency tests (you can list any or all tests in the same command line):
You can also see the CPU that qperf had to consume to send and receive the
data that it did. You can also see an even more detailed output with the
Instructing qperf to run the tests for a longer time, say 60s, reduces the
influence of outliers (qperf only reports averages, and no other stats). You can
do this by using the
-t NN flag, like so:
And finally, you can also choose the size of the message to be used for the
tests. (You can also make it repeat the test with increasing sizes using
-oo option.) Here is qperf being run with a 4 kB packet size:
Here are some examples of where qperf can be useful:
- How does the private networking feature offered by Digital Ocean compare to, say, Linode’s in terms of network throughput and latency?
- Your containers are talking to each other over a Weave overlay network – is this slowing things down?
- How much will adding encryption to a Weave network slow things down?
Interested in the answers to these questions? Let us know in the comments and we’ll try to do a blog post about them in the future.
Going from here
qperf is a handly little tool to have in your toolbox. Another similar
tool is iperf.
iperf actively measure your network link, there is another
class of tools that passively monitor network transfer rates, errors and the
like. Our own OpsDash is one of them.