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

Aug 13th, 2023: added Yet-another-bench-script benchmarking tool.
Sept 27th, 2021: Added link to a great list of command-line benckmark scripts.
June 17th, 2019: Added instructions for network speed test using speedtest-cli script.
Nov 2nd, 2016: Included 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 downloads and can quickly alert you to any performance bottlenecks and indicate if there’s a need for additional benchmarks using more complex tools.

Are you hosted on a Cloud, VPS, or Dedicated server and struggle with performance issues? When raising these issues to your web host, do they always seem to blame everything on your so-called “heavy” website? If you are tired of being hung out to dry, let’s do something about it. To get started, let’s try to identify or eliminate your web host/server from the bad-performance equation using ‘dd’ commands to benchmark your storage, memory and CPU performance.

The screenshot below shows a few dd commands being run on a tiny but under load (6GB RAM) StackLinux VPS. If you’re interested in super-fast SSD-based VPS hosting, you can request an invite here.

benchmark your VPS: disk, ram and cpu

Now, let’s look into the ‘dd’ command 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 zeroes. We will also instruct ‘dd’ to sync this to disk and ensure that writes do not remain in memory (RAM), which would not give accurate write speed results if memory buffer is used (we will leave that for a later test).

UPDATE: Check out yabs.sh. A simple bash script to estimate Linux server performance using fio, iperf3, & Geekbench. You can run it immediately with:

curl -sL yabs.sh | bash

or

wget -qO- yabs.sh | bash

 

Using ‘dd’ to benchmark storage write performance.

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

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 look something like this from Stacklinux’s 3GB VPS:

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

You’ll want this to be above 400 MB/s.

 

Using ‘dd’ to benchmark storage read performance

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

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

Now that cache is deleted, we can test the read performance of that ‘diskbench’ file using:

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

This 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 memory-buffered cache. So let’s test read speeds using 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 a couple of times 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 hosts. In addition, more extensive tests can be performed using fiobonnie++, or IOzone.

 

Using ‘dd’ to benchmark CPU performance

Suppose you would like to verify CPU speed and # of cores. Use the following commands:

lscpu

‘lscpu’ gathers CPU architecture information from sysfs and /proc/cpuinfo. The report includes the number of CPUs, threads, cores, etc. There is also information about the CPU caches 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 using:

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

The results:

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. Lower than that should prompt you to perform more accurate tests using BYTEmark or even unixbench. To sum things up, 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 for testing internet bandwidth

speedtest cli

speedtest-cli is a command-line interface for testing internet bandwidth using speedtest.net. Issue the following commands to download and run the network speed test script:

wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli

or

curl -Lo speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli
./speedtest-cli

or for usage/help use:

./speedtest-cli -h

 

For reference, here’s a cut-an-paste of results as 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 ~]#

Tags: , , , , ,



Top ↑