What is Sysbench?
Sysbench is designed for evaluating the performance of systems by executing CPU, memory, file I/O, and database benchmarks. It is highly customizable, and the results can be used for performance tuning, comparing different configurations, or validating hardware upgrades.
Installing Sysbench on CentOS and Ubuntu.
Step 1: Install Dependencies
Run the following command to install the required dependencies:
sudo yum install mysql-devel libtool automake autoconf
Step 2: Download Sysbench
For example, to download Sysbench from GitHub, you can use curl:
curl -LO https://github.com/akopytov/sysbench/releases/download/1.0.20/sysbench-1.0.20.tar.gz
If the .tar.gz file is downloaded, extract it:
tar -xzvf sysbench-1.0.20.tar.gz
cd sysbench-1.0.20/
Step 3: Build Sysbench from Source
./autogen.sh ; ./configure ; make -j ; make install
Step 4: Verify the Installation
sysbench --version
sysbench 1.0.20
Running the CPU Benchmark Test:
Sysbench provides a number of tests, but here, we will focus on testing the CPU performance. Sysbench’s CPU test calculates prime numbers up to a specified limit and reports the number of events processed during the benchmark run.
Here’s how you can run the benchmark on the CPU:
Running Sysbench CPU Test with 1 Thread:
sysbench --test=cpu --threads=1 --time=60 run
Sample Output:
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Prime numbers limit: 10000
Initializing worker threads...
Threads started!
CPU speed:
events per second: 2955.46
General statistics:
total time: 60.0002s
total number of events: 177333
Latency (ms):
min: 0.33
avg: 0.34
max: 0.39
95th percentile: 0.35
sum: 59978.41
Threads fairness:
events (avg/stddev): 177333.0000/0.00
execution time (avg/stddev): 59.9784/0.00
Running Sysbench CPU Test with 2 Threads:
sysbench --test=cpu --threads=2 --time=60 run
Sample Output:
CPU speed:
events per second: 5903.08
General statistics:
total time: 60.0002s
total number of events: 354195
Latency (ms):
min: 0.33
avg: 0.34
max: 1.29
95th percentile: 0.35
sum: 119915.68
Threads fairness:
events (avg/stddev): 177097.5000/89.50
execution time (avg/stddev): 59.9578/0.00
As you can see, with more threads, the events per second increase as well, which indicates better CPU utilization.
Running Sysbench CPU Test with 4 Threads:
Increasing the number of threads even more tests the system's scalability:
sysbench --test=cpu --threads=4 --time=60 run
Sample Output:
CPU speed:
events per second: 11819.27
General statistics:
total time: 60.0003s
total number of events: 709178
Latency (ms):
min: 0.33
avg: 0.34
max: 1.28
95th percentile: 0.35
sum: 239860.45
Threads fairness:
events (avg/stddev): 177294.5000/122.97
execution time (avg/stddev): 59.9651/0.00
Running Sysbench CPU Test with 8 Threads:
sysbench --test=cpu --threads=8 --time=60 run
Sample Output:
CPU speed:
events per second: 23637.61
General statistics:
total time: 60.0004s
total number of events: 1418301
Latency (ms):
min: 0.33
avg: 0.34
max: 1.28
95th percentile: 0.35
sum: 479730.48
Threads fairness:
events (avg/stddev): 177287.6250/42.17
execution time (avg/stddev): 59.9663/0.00
Running Sysbench CPU Test with 16 Threads:
sysbench --test=cpu --threads=16 --time=60 run
Sample Output:
CPU speed:
events per second: 47267.52
General statistics:
total time: 60.0004s
total number of events: 2836140
Latency (ms):
min: 0.33
avg: 0.34
max: 1.42
95th percentile: 0.35
sum: 959459.02
Threads fairness:
events (avg/stddev): 177287.6250/42.17
execution time (avg/stddev): 59.9662/0.00
Observations:
Threads and Performance: As the number of threads increases, the events per second increase proportionally. This shows how well your CPU can handle multi-threaded workloads.
Latency: The latency remains fairly constant across different thread counts, which suggests that the CPU's ability to process each event is relatively consistent.
Thread Fairness: The fairness remains stable, indicating that Sysbench is distributing tasks evenly across the threads.