Your Web Host Doesn’t Want You to Read This: Benchmark Your VPS

September 27, 2021: Added link to a larger list of command-line benchmark scripts.
June 17, 2019: Additional instructions for a network speed test using the speedtest-cli script.
Nov 2, 2016: Includes quick dd commands to check cached vs uncached read performance.

This article will highlight using the ‘dd’ Unix command for a quick benchmark of your Linux server or VPS. ‘dd’ requires no download and can immediately alert you to any performance bottlenecks and indicate whether additional benchmarks are needed using more complex tools.

Are you hosted on a cloud, VPS, or dedicated server and are experiencing performance issues? When raising these issues to your web host, do they always blame everything on your so called “heavy” website? If you’re tired of hanging it up to dry, let’s do something about it. To get started, let’s try to identify or eliminate your web host/server from the poor-performance equation by using the ‘dd’ command to benchmark your storage, memory and CPU performance.

The screenshot below shows some dd commands running on a small but low load (6GB of RAM). stacklinux VPS. If you are interested in super-fast SSD-based VPS hosting, you can request an invite here,

Now, let us look at the ‘dd’ command that we will be using. ‘dd’ is a command on Unix and Unix-like operating systems (such as Linux) whose primary purpose is to convert and copy a file. We will use ‘dd’ to create a file named ‘diskbench’ with all zeros. We’ll also instruct ‘dd’ to sync it to disk and ensure that writes don’t stay in memory (RAM), which won’t give accurate write speed results if memory buffers are used (we’ll see this for later testing) will leave).

Using ‘dd’ to benchmark storage write performance.

To get started, you should change to the directory in which you have given read and write permissions. Or create a new directory and enter:

mkdir /home/bench/
cd /home/bench/

Make sure you have a few gigabytes of free storage space. Then use the following command to test the write speed of your storage:

dd if=/dev/zero of=diskbench bs=1M count=1024 conv=fdatasync

The results from a 3GB VPS on Stacklinux look something like this:

1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 0.553284 s, 1.9 GB/s

You want it to be above 400MB/s.

Using ‘dd’ to benchmark storage read performance

Now, delete the server’s buffer cache to measure ‘read’ speed directly from the hard drive:

echo 3 | sudo tee /proc/sys/vm/drop_caches

Now that the cache has been cleared, we can test the read performance of that ‘diskbench’ file:

dd if=diskbench of=/dev/null bs=1M count=1024

It outputs the following:

1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 0.425812 s, 2.5 GB/s

Using ‘dd’ to benchmark memory-buffered read performance

After running the above command, the data will be pushed to the memory-buffered cache. So let’s test the read speed using the memory buffer by repeating the previous command:

dd if=diskbench of=/dev/null bs=1M count=1024

which outputs the following:

1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 0.135034 s, 8.0 GB/s

You should run this test twice to find the average. Lastly, remember to delete the 1.1GB test file using this command:

rm diskbench

If your results point to poor read/write performance, you may want to upgrade hardware or switch your web host. In addition, more extensive testing can be done using fio, Bonnie++either iozone,

Using ‘dd’ to benchmark CPU performance

Let’s say you want to check CPU speed and # of cores. Use the following commands:

lscpu

‘lscpu’ collects CPU architecture information from sysfs and /proc/cpuinfo . The report includes the number of CPUs, threads, cores, etc. There is also information about CPU cache and cache sharing, family, model, bogomips, byte order, and stepping.

nproc

‘nproc’ prints the number of processing units (CPU cores) available.

Now, ‘dd’ can also be used for a simple CPU benchmark:

dd if=/dev/zero bs=1M count=1024 | md5sum

result:

1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 2.5454 s, 422 MB/s
cd573cfaace07e7949bc0c46028904ff -

For most modern CPUs, you’ll want to see a minimum of 300 MB/s. Using less than this should prompt you to test more precisely Bytemark or even unixbench, To summarize things, no matter your experience level, ‘dd’ can be used as a quick check into your web server’s storage, memory and CPU performance.

Using speedtest-cli to test internet bandwidth

fastest cli

speedtest-cli There is a command-line interface for testing Internet bandwidth using speedtest.net. To download and run the network speed test script, issue the following commands:

wget -O speedtest-cli 
chmod +x speedtest-cli

either

curl -Lo speedtest-cli 
chmod +x speedtest-cli
./speedtest-cli

or for use/help use:

./speedtest-cli -h

For reference, here’s a cut-a-paste of the results I tested on an 8GB DigitalOcean droplet:

[root@droplet ~]# dd if=/dev/zero of=diskbench bs=1M count=1024 conv=fdatasync
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 2.51205 s, 427 MB/s
[root@droplet ~]# dd if=/dev/zero of=diskbench bs=1M count=1024 conv=fdatasync
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 2.84208 s, 378 MB/s
[root@droplet ~]# dd if=/dev/zero of=diskbench bs=1M count=1024 conv=fdatasync
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 2.09716 s, 512 MB/s
[root@droplet ~]# echo 3 | sudo tee /proc/sys/vm/drop_caches
3
[root@droplet ~]# dd if=diskbench of=/dev/null bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 1.55411 s, 691 MB/s
[root@droplet ~]# dd if=diskbench of=/dev/null bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 0.348052 s, 3.1 GB/s
[root@droplet ~]# dd if=diskbench of=/dev/null bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 0.202393 s, 5.3 GB/s
[root@droplet ~]# rm diskbench
rm: remove regular file `diskbench'? y
[root@droplet ~]# nproc
4
[root@droplet ~]# dd if=/dev/zero bs=1M count=1024 | md5sum
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 3.34115 s, 321 MB/s
cd573cfaace07e7949bc0c46028904ff -
[root@droplet ~]# dd if=/dev/zero bs=1M count=1024 | md5sum
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 3.17004 s, 339 MB/s
cd573cfaace07e7949bc0c46028904ff -
[root@droplet ~]# dd if=/dev/zero bs=1M count=1024 | md5sum
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 3.09961 s, 346 MB/s
cd573cfaace07e7949bc0c46028904ff -
[root@droplet ~]#

Leave a Comment