SysBench is a modular, cross-platform and multi-threaded benchmark tool for evaluating OS parameters that are important for a system running a database under intensive load. Benchmark CPU, File I/O and Memory in CentOS Server.
Current features allow to test the following system parameters:
- file I/O performance
- scheduler performance
- memory allocation and transfer speed
- POSIX threads implementation performance
- database server performance
Install SysBench on CentOS 7
# yum install epel-release -y
# yum install sysbench -y
General syntax
The general syntax for SysBench is as follows:
sysbench [common-options] --test=name [test-options] command
CPU workload
You can benchmark your CPU performance as follows, The benchmark can be configured with the number of simultaneous threads and the maximum number to verify if it is a prime.
# sysbench --test=cpu --cpu-max-prime=20000 run sysbench 1.0.6 (using system LuaJIT 2.0.4) Running the test with following options: Number of threads: 1 Initializing random number generator from current time Prime numbers limit: 20000 Initializing worker threads... Threads started! General statistics: total time: 10.0018s total number of events: 3652 Latency (ms): min: 2.67 avg: 2.74 max: 13.85 95th percentile: 2.81 sum: 10000.00 Threads fairness: events (avg/stddev): 3652.0000/0.00 execution time (avg/stddev): 10.0000/0.00
Verify the the Total time statistics.
File IO workload
Before you do the file IO benchmark, you should confirm your drive and mount it if it is additional drive. Here using fileio, you will need to create a set of test files to work on. It is recommended that the size is larger than the available memory to ensure that file caching does not influence the workload too much.
# time sysbench --test=fileio --file-total-size=48G --file-num=24 prepare sysbench 1.0.6 (using system LuaJIT 2.0.4) 24 files, 2097152Kb each, 49152Mb total Creating files for the test... Extra file open flags: 0 Creating file test_file.0 Creating file test_file.1 Creating file test_file.2 Creating file test_file.3 Creating file test_file.4 Creating file test_file.5 Creating file test_file.6 Creating file test_file.7 Creating file test_file.8 Creating file test_file.9 Creating file test_file.10 Creating file test_file.11 Creating file test_file.12 Creating file test_file.13 Creating file test_file.14 Creating file test_file.15 Creating file test_file.16 Creating file test_file.17 Creating file test_file.18 Creating file test_file.19 Creating file test_file.20 Creating file test_file.21 Creating file test_file.22 Creating file test_file.23 51539607552 bytes written in 594.02 seconds (82.74 MiB/sec). real 9m54.175s user 0m0.162s sys 0m51.073s
You can tell the sysbench which kind of workload you want to run: sequential reads, writes or random reads, writes, or a combination.
We are going to use random read/write is used (rndrw) for example testing. Once you generated the files using above command, try to run the following commands.
# sysbench fileio --file-total-size=48G --file-num=24 --file-test-mode=rndrw --time=1800 --file-rw-ratio=1 --threads=16 --max-requests=0 run sysbench 1.0.6 (using system LuaJIT 2.0.4) Running the test with following options: Number of threads: 16 Initializing random number generator from current time Extra file open flags: 0 24 files, 2GiB each 48GiB total file size Block size 16KiB Number of IO requests: 0 Read/Write ratio for combined random IO test: 1.00 Periodic FSYNC enabled, calling fsync() each 100 requests. Calling fsync() at the end of test, Enabled. Using synchronous I/O mode Doing random r/w test Initializing worker threads... Threads started! File operations: reads/s: 233.63 writes/s: 233.63 fsyncs/s: 112.14 Throughput: read, MiB/s: 3.65 written, MiB/s: 3.65 General statistics: total time: 1800.0621s total number of events: 1042957 Latency (ms): min: 0.00 avg: 27.61 max: 300.08 95th percentile: 101.13 sum: 28798434.80 Threads fairness: events (avg/stddev): 65184.8125/349.16 execution time (avg/stddev): 1799.9022/0.02
Once completed, you can check the “Throughput” and “File operations” result to get the details.
After the benchmark, you can delete the 50GB test file from the server using the below command.
#sysbench --test=fileio --file-total-size=50G cleanup
You can also do some workload using sysbench.
the memory workload
the mutex workload
the threads workload