How to check CPU, RAM, Disk performance on Linux

Estimated reading: 7 minutes 188 views

During the years of providing VPS services, we have noticed that many customers when registering for VPS or Server services have the same question: is my VPS fast? Is my server fast? How to know that?

Recently, VPS service providers have sprung up like mushrooms, and the comparison demand of customers is increasing because they want to choose for themselves VPS/servers with the best performance in the price range.

To meet this need, we have released a technically in-depth VPS performance testing tool for customers to have an overview of their VPS and make the best choice

1. CPU Speed

Currently, there are many tools to test CPU speed, but we only use the sysbench tool in this article

Step 1: Install sysbench

  • On Debian/Ubuntu, sysbench can be installed as follows:
# apt install sysbench
  • On CentOS and Fedora, it can be installed from the EPEL repository.
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
# yum -y install epel-release
# yum -y update

Then install sysbench with yum:

# yum install sysbench

Step 2: CPU Benchmark

This command will ask the system to perform 1 prime number calculation up to x times, x times will be specified by the –CPU-max-primes parameter. All calculations performed are 64-bit integers. This command handles only 1 thread.

# sysbench --test=cpu --cpu-max-prime=20000 run

The command below is similar to the one below, only processing a single thread.

# sysbench --test=cpu --cpu-max-prime=20000 --num-threads=1 run

To test with 4 concurrent threads we can use the following command

# sysbench --test=cpu --cpu-max-prime=20000 --num-threads=4 run

Here is the test result on 1 of our VPS:

In the printed result we will be interested in 3 parameters:

  • Total time: 10.0053s
  • Avg time: 5.65ms
  • Max time: 11.76ms

Based on the test results we will be interested in these 3 numbers, if your VPS or server has a lower number, the faster the CPU’s processing performance is.

2. RAM speed

We will continue to use the sysbench tool to test the processing speed of memory

  • Test read speed from RAM

This command will perform a read of 100GB from the buffer (specified by the –memory-total-size parameter) with a read of 1KB (specified by the–memory-block-size parameter) and only 1 processing thread.

# sysbench --test=memory --memory-block-size=1K --memory-scope=global --memory-total-size=100G --memory-oper=read run

In the printed results, we only need to care about 2 bolded parameters because these are the 2 parameters that represent the reading speed from the memory buffer, the higher this parameter the better.

  1. Total operations: 27618261 (2759745.59 per second)
  2. 26970.96 MiB transferred (2695.06 MiB/sec)
  • Test write speed from RAM

This command will write 100GB to the buffer (specified by the –memory-total-size parameter) with each write being 1KB (specified by the –memory-block-size parameter) and only 1 processing thread.

# sysbench --test=memory --memory-block-size=1K --memory-scope=global --memory-total-size=100G --memory-oper=write run

In the printed results, we only need to care about 2 bolded parameters because these are 2 parameters that represent the speed of writing to the memory buffer, the higher this parameter the better.

  1. Total operations: 25457276 (2544907.96 per second)
  2. 24860.62 MiB transferred (2485.26 MiB/sec)

3. Disk performance:

Currently, there are two types of hard drives on the market: traditional HDD and SSD. SSDs have much faster read and write speeds than HDDs. However, not every server using HDD will give poor performance, just as SSDs are better. Normally, we perform the test via the dd command, writing a data file to the hard drive. This command is very popular because it is installed by default on most OS versions of Linux and displays information that is intuitive and easy to understand.

# dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync

However, this test is not really effective and has many problems:

  • The command performs single-task operations and sequential writes. If you run a web and database server on a VPS, this number is meaningless because most applications do not perform sequential writes but sequential random reads.
  • Writing data to the system may be affected by caching on the server. Some providers even optimize the returned results.
  • The statement performs the measurement in a very short period of time (several seconds). This test period is not enough to reach a consistent conclusion.
  • This command only tests the write speed of the hard drive, not the read speed while most websites read (access, read news) more than write (write, edit news).

Thus, to test VPS hard drive performance, the dd command is not the best command and covers all the information.

Therefore, in this article, we will introduce a more accurate method of checking hard drive performance through IOPS and Latency parameters using Fio and IOPing tools.

Step 1: Measure IOPS with Fio

+ Install FIO on Centos using the following command:

# yum install -y epel-release && yum install -y fio

+ Install FIO on Ubuntu/Debian using the following command:

# apt update && apt install -y fio
  • Simultaneously check random read & random write
# fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=TGS --filename=TGS --bs=4k --iodepth=64 --size=4G --readwrite=randrw --rwmixread=75

This is the command used to test the IOPS of the hard drive. This statement will create a 4GB file and test it according to the mechanism of reading and writing 4KB files simultaneously with a rate of 75%/25% (for every 3 read requests, there will be 1 write request) with 64 concurrent executions at a time. point. The 3:1 ratio is very popular with today’s databases.

This is the result after the system runs completely:

As can be seen, the VPS test can simultaneously perform 29.0k read tasks and 9704 write tasks per second.

Normally, under light load, VPS with SSD hard drive can reach 40000 reads and 10000 writes while non-SSD uses 500 reads and 200 writes.

  • Check random read
# fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=TGS --filename=TGS --bs=4k --iodepth=64 --size=4G --readwrite=randread

This is the result after the system runs completely

As can be seen, the VPS test can perform 51.5k reads in 1 second. Typically, SSD hard drives can do 50,000 reads in 1 second while non-SSD hard drives are approximately 2000.

  • Check random write
# fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=TGS --filename=TGS --bs=4k --iodepth=64 --size=4G --readwrite=randwrite

This is the result after the system runs completely

As can be seen, the VPS test can perform 35.3k writes in 1 second. Typically, SSD hard drives can do 50000 writes in 1 second while non-SSD hard drives are approximately 2000.

Step 2: Latency measurement with IOPing

Finally, we conduct a hard drive performance test by testing the Latency latency of each request independently using the IOPing tool. Setting:

# apt update && apt install -y ioping

After installation is complete, check the delay of each request with the following command (test 10 requests):

# ioping -c 10 .

Result:

As can be seen, the VPS test has an average latency of 675.6 us = 0.6756 ms. For systems with stable operation, a parameter fluctuation of less than 1.0 ms is fine.

4. How to Benchmark a Linux Server

  • Method 1: Test with Geekbench 5

Geekbench 5 is a cross-platform benchmark test. Geekbench 5 allows you to compare system performance across devices, operating systems, and processor architectures.

# wget https://cdn.geekbench.com/Geekbench-5.4.5-Linux.tar.gz --no-check-certificate
# tar xf Geekbench-5.4.5-Linux.tar.gz
# cd Geekbench-5.4.5-Linux/
# ./geekbench5

You will see the console state what is being tested and the outcomes whilst the testing is underway. Once it has finished it will display a URL to check the results.

  • Method 2: Test with YABs

YABS (Yet Another Benchmark Script) is a benchmark script. It allows you to benchmark your Linux VPS with a single line/command and produces beautiful, readable output.

How to use: Run either command on your VPS

# curl -sL yabs.sh | bash

or

# wget -qO- yabs.sh | bash

Example output:

Note: For VPS, the test results will change depending on the time because the VPS operates on a shared resource environment.

Good Luck!

Leave a Comment