SysBench is a modular, cross-platform and multi-threaded benchmark tool to check your server performance. In this tutorial, we will be benchmarking CPU, File I/O, MySQL performance.
SysBench is available on apt-get repository, use the following commands to install SysBench.
# sudo apt-get update # sudo apt-get install sysbench
I will be doing basic benchmark tests, I will recommend taking a look at this page if you would like to perform more advanced benchmarks.
The cpu is one of the most simple benchmarks in SysBench. In this mode, each request consists in calculation of prime numbers up to a value specified by the --cpu-max-primes option.
# sysbench --test=cpu --cpu-max-prime=20000 run
This command will output a lot of numbers which you can use to compare benchmarks with other systems. Most importantly take a look at the total time output.
This test mode can be used to produce various kinds of file I/O workloads. First, we need to prepare our test file, make sure that you choose a file size that is larger than your system RAM or the system will use RAM to cache the file.
# sysbench --test=fileio --file-total-size=50G prepare
Now run the benchmark using this command:
# sysbench --test=fileio --file-total-size=50G --file-test-mode=rndrw --init-rng=on --max-requests=0 run
The output of this command will show you the read/write speeds.
Now you can remove the test file that was created for benchmark:
# sysbench --test=fileio --file-total-size=50G cleanup
Before we benchmark MySQL database, make sure you have a database created for the benchmark, I have created database bench for this benchmark.
We need to prepare our database table and we will be adding 1,000,000 rows for this benchmark.
# sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=bench --mysql-user=root --mysql-password=userpassword prepare
Now let's run the benchmark by using the following command.
# sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=bench --mysql-user=root --mysql-password=userpassword --max-time=60 --oltp-read-only=on --max-requests=0 run
Take a look at the transactions value, most importantly will also show transactions per seconds.
Use the following command to remove the table that was created for the benchmark.
# sysbench --test=oltp --mysql-db=bench --mysql-user=root --mysql-password=userpassword cleanup