Linux Commands

How to Use Sysbench for Linux Performance Testing?

Sysbench is an open-source and multi-purpose benchmark utility that evaluates the parameter features tests for CPU, memory, I/O, and database (MySQL) performance. This tool is important to benchmark the MySQL parameters especially when running a load of the intensive database. It is a freely available command-line tool that provides an uncomplicated and direct way to test your Linux system.

This article will provide you the details about the Sysbench command-line tool. We will discuss how to test the performance of Linux OS components through the sysbench utility as well. We have implemented all commands on the latest available Ubuntu 20.04 system.

Install Sysbench Tool 

The sysbench utility can directly be installed from the official Ubuntu repository by running the following command:

$ sudo apt install sysbench

Enter “Y” and then press “Enter” to proceed further with the installation.

Perform CPU Benchmarking Using sysbench Tool

To evaluate the CPU performance, use the following command for CPU benchmarking:

$ sysbench --test=cpu run

The complete report statistics will be displayed on the terminal, but the important thing here is the “total time” that will be displayed under the “General statistics” to test CPU performance.

You can also explore CPU benchmark options using the following command:

$ sysbench --test=cpu help

The command parameters can be modified based on your requirements. For example, use the following to benchmark the CPU performance:

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

Benchmark Memory Using the sysbench Tool

To test the Memory performance, type the following basic command on the terminal:

$ sysbench --test=memory run

Memory performance can be tested by examining the two parameters, “Total Operations” and data amount transferred.

To test more memory options, use the following command:

$ sysbench --test=memory help

Benchmark I/O Using the sysbench Tool

The I/O performance test is a little bit different from the CPU and memory test. In file I/O testing, you need to create a test file that is much larger than your RAM size. The value you can set ”150 GB” is good. The general sequential write I/O performance test can be done using the following command:

$ sysbench --test=fileio --file-test-mode=seqwr run

Explore more options by using the following command to perform the I/O benchmark:

$ sysbench --test=fileio --file-test-mode=seqwr help

There are many options shown on the terminal. Just set the values of the parameters based on your requirements and test the performance of the I/O of your Linux system.

Once the performance test is completed, delete the test file by using the following command:

$ sysbench --test=fileio --file-total-size=100G cleanup

Conclusion

In this tutorial, we have described how to install sysbench utility on a Linux system and how to test the performance of your CPU, memory, and I/O of your system. Try all the above options to get more accurate performance results. Using this tool, you can also test the performance of databases.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.