Want to benchmark that new server you just you just bought, or make sure you’re getting the most out of it? You can use the following tools or scripts
Want to benchmark that new server you just you just bought, or make sure you’re getting the most out of it? You can use the following tools or scripts to measure or monitor the performance of your machine.
dd is a command on whose primary purpose is to convert and copy a file, we can use this command to get information on write speed of a hard disk. The command to run it is:
dd bs=1M count=512 if=/dev/zero of=test conv=fdatasync; unlink test
This creates a file named ‘test’ with all zeroes in it. The flag conv=fdatasync tells dd to sync the write to disk before it exits. Without this flag, dd will perform the write but some of it will remain in memory, not giving you an accurate picture of the true write performance of the disk.
An example test ran on a vps is below:
root@unixio [~]# dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync; unlink test 16384+0 records in 16384+0 records out 1073741824 bytes (1.1 GB) copied, 4.6417 s, 231 MB/s
Wget is a network utility to retrieve files from the web, and can be used to measure the network speed of a server. Simply run the command below on your server:
wget -O /dev/null http://cachefly.cachefly.net/100mb.test
This command uses wget to download a 100 megabyte large file from CacheFly’s servers. The output is set to go to /dev/null, which means it simply discards anything it downloads.
An example output of the above is below:
root@unixio [~]# wget -O /dev/null http://cachefly.cachefly.net/100mb.test --2013-06-11 16:10:27-- http://cachefly.cachefly.net/100mb.test Resolving cachefly.cachefly.net... 18.104.22.168 Connecting to cachefly.cachefly.net|22.214.171.124|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 104857600 (100M) [application/octet-stream] Saving to: “/dev/null” 100%[======================================>] 104,857,600 87.8M/s in 1.1s 2013-06-11 16:10:28 (87.8 MB/s) - “/dev/null” saved [104857600/104857600]
This test should be ran three times, and the middle result used to give a measure of the download speed.
ioping is a disk I/O latency measuring tool which shows disk latency in a similar way to how ping shows network latency between servers.
To run the command and show the disk latency in the current directory:
root@unixio [~]# ioping . 4096 bytes from . (ext4 /dev/sda3): request=1 time=0.2 ms 4096 bytes from . (ext4 /dev/sda3): request=2 time=0.2 ms 4096 bytes from . (ext4 /dev/sda3): request=3 time=0.3 ms 4096 bytes from . (ext4 /dev/sda3): request=4 time=12.7 ms 4096 bytes from . (ext4 /dev/sda3): request=5 time=0.3 ms ^C --- . (ext4 /dev/sda3) ioping statistics --- 5 requests completed in 4794.0 ms, 364 iops, 1.4 mb/s min/avg/max/mdev = 0.2/2.8/12.7/5.0 ms
To measure the disk seek rate (iops, avg):
root@unixio [~]# ioping -R /dev/sda --- /dev/sda (device 465.8 Gb) ioping statistics --- 186 requests completed in 3004.6 ms, 62 iops, 0.2 mb/s min/avg/max/mdev = 6.4/16.0/26.8/4.7 ms
It can also be used to measure the sequential speed in mb/s of a disk.
root@unixio [~]# ioping -RL /dev/sda --- /dev/sda (device 465.8 Gb) ioping statistics --- 837 requests completed in 3004.1 ms, 292 iops, 72.9 mb/s min/avg/max/mdev = 2.0/3.4/28.9/2.0 ms
df is a Unix command to report disk space usage by filesystem, we can use it to show how much disk space we have left on the server and how much has been used. To do this run the command below, and the output will display the disk space status of the filesystem.
An example of the output is below; as you can see the main partition is 15GB big, and 1.7GB of space has been used (11%) leaving 13GB free.
[root@dev ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/simfs 15G 1.7G 14G 11% / none 128M 4.0K 128M 1% /dev
CPU info command
There are a few commands you can use to find out information about the CPU in your server. The nproc command outputs the number of processor units available to your machine.
root@unixio [~]# nproc 2
/proc/cpuinfo stores a wide range of CPU statistics for a server such as number of CPUs, the amount of threads, cores, sockets, and NUMA nodes available, also information about CPU caches, CPU family, model, and much more. This information can be read using the cat command as seen below.
[root@dev ~]# cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 13 model name : QEMU Virtual CPU version (cpu64-rhel6) stepping : 3 cpu MHz : 3300.022 cache size : 4096 KB ...
Information for each CPU is displayed, this is separated by a blank line. Additionally, you can use the lscpu command to output this information in a much more human-readable format.
ServerBear makes it easy to benchmark Linux servers & compare performance metrics (Disk IO, IOPS, FIO, Network Performance & UnixBench). It’s a no hassle all-in-one benchmarking tool, all you have to do is execute a command and it will benchmark your system.
LEB Bench Script
If you’re looking for a quick and easy way to get stats on your system, a lot of users (including myself) still use the Linux server info script from akamaras which is a useful thing to have on your server.
An output of what you can expect to see is below:
root@unixio [~]# sh bench.sh CPU model : QEMU Virtual CPU version (cpu64-rhel6) Number of cores : 2 CPU frequency : 3300.022 MHz Total amount of ram : 498 MB Total amount of swap : 1023 MB System uptime : 11 days, 1:19, Download speed : (75.3MB/s) I/O speed : 224MB/s
This one isn’t a benchmarking tool, however can be useful. Htop is an interactive system-monitor process-viewer for Linux which shows a list of running processes on a server. It is seen as a replacement for top, and has additional features such as a cleaner and easier to read interface, a full sortable list of processes running. Htop also provides information about processor, swap and memory status so it’s useful if you want to view what the current memory usage is or process cpu consumption.