Sysbench  is a benchmarking tool  which allows you to measure  system characteristics  such as  CPU, file IO, and MySQL performance.  Sysbench can be executed use as single threaded or multi threaded using the --num-threads parameter default is single threaded

Sysbench command line options

The table below summaries the options/parameters available for sysbench.  This information was obtained  from the sysbench man page (man sysbench)

 

Option Description Default value
--num-threads The total number of worker threads to create 1
--max-requests Limit for total number of requests. 0 means unlimited 10000
--max-time Limit for total execution time in seconds. 0 (default) means unlimited 0
--thread-stack-size Size of stack for each thread 32K
--init-rng Specifies if random numbers generator should be initialized from timer before the test start off
--report-interval Periodically report intermediate statistics with a specified interval in seconds. Note that statistics produced by this option is per-interval rather than cumulative. 0 disables intermediate reports 0
--test Name of the test mode to runAvailable testsfileio           File I/O test
cpu              CPU performance
memory    Memory functions speed tests
threads     Threads subsystem performance
mutex       Mutex performance test
oltp            OLTP test
Required
--debug Print more debug info off
--validate Perform validation of test results where possible off
--help Print help on general syntax or on a test mode specified with –test, and exit off
--verbosity Verbosity level (0 – only critical messages, 5 – debug) 4
--percentile SysBench measures execution times for all processed requests to display statistical information like minimal, average and maximum execution time. For most benchmarks it is also useful to know a request execution time value matching some percentile (e.g. 95% percentile means we should drop 5% of the most long requests and choose the maximal value from the remaining ones). This option allows to specify a percentile rank of query execution times to count 95
--validate Perform validation of test results where possible off

Note that numerical values for all size options (like --thread-stack-size in this table) may be specified by appending the corresponding multiplicative suffix (K for kilobytes, M for megabytes, G for gigabytes and T for terabytes).

Installation of sysbench 0.4.12 on Ubuntu

root@ubuntu:~# apt-get install sysbench
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following NEW packages will be installed sysbench
0 to upgrade, 1 to newly install, 0 to remove and 0 not to upgrade.
Need to get 0 B/56.7 kB of archives.
After this operation, 170 kB of additional disk space will be used.
Selecting previously unselected package sysbench.
(Reading database … 94265 files and directories currently installed.)
Preparing to unpack …/sysbench_0.4.12-1.1_amd64.deb …
Unpacking sysbench (0.4.12-1.1) …
Processing triggers for man-db (2.6.7.1-1ubuntu1) …
Setting up sysbench (0.4.12-1.1) …

root@ubuntu:~# sysbench –version=on
sysbench 0.4.12
root@ubuntu:~#

Installation of sysbench 0.5 (Reference from http://nilinfobin.com/2014/08/how-to-install-sysbench-0-5-on-debian-7)

1) Install pre-requisites packages

apt-get install automake
apt-get install autoconf
apt-get install libtool
apt-get install libmysqlclient-dev
apt-get install libssl1.0.0 libssl-dev
apt-get install make

2) Install bzr package using apt-get install bzr unless already installed

apt-get install bzr

3) Download the source from https://code.launchpad.net/~sysbench-developers/sysbench/0.5 using bzr branch lp:sysbench command

root@ubuntustage:~# bzr branch lp:sysbench
 You have not informed bzr of your Launchpad ID, and you must do this to write to Launchpad or access private data. See "bzr help launchpad-login".
Branched 132 revisions.

4)  change dir to sysbench and run autogen.sh

 root@ubuntustage:~# 
root@ubuntustage:~# cd sysbench
root@ubuntustage:~/sysbench# ./autogen.sh
./autogen.sh: running `aclocal -I m4' 
configure.ac:27: warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
m4/extensions.m4:2: ACX_USE_SYSTEM_EXTENSIONS is expanded from...
configure.ac:27: the top level
configure.ac:27: warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
m4/extensions.m4:2: ACX_USE_SYSTEM_EXTENSIONS is expanded from...
configure.ac:27: the top level
./autogen.sh: running `libtoolize --copy --force' 
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `config'.
libtoolize: copying file `config/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
./autogen.sh: running `autoheader' 
configure.ac:27: warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
m4/extensions.m4:2: ACX_USE_SYSTEM_EXTENSIONS is expanded from...
configure.ac:27: the top level
./autogen.sh: running `automake -c --foreign --add-missing' 
configure.ac:27: warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
m4/extensions.m4:2: ACX_USE_SYSTEM_EXTENSIONS is expanded from...
configure.ac:27: the top level
./autogen.sh: running `autoconf' 
configure.ac:27: warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
m4/extensions.m4:2: ACX_USE_SYSTEM_EXTENSIONS is expanded from...
configure.ac:27: the top level
Libtoolized with: libtoolize (GNU libtool) 2.4.2
Automade with: automake (GNU automake) 1.14.1
Configured with: autoconf (GNU Autoconf) 2.69
root@ubuntustage:~/sysbench#

5)  Run ./configure

root@ubuntustage:~/sysbench# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... no
checking whether make supports nested variables... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
.....
config.status: creating sysbench/tests/threads/Makefile
config.status: creating sysbench/tests/mutex/Makefile
config.status: creating sysbench/tests/db/Makefile
config.status: creating sysbench/scripting/Makefile
config.status: creating sysbench/scripting/lua/Makefile
config.status: creating sysbench/scripting/lua/src/Makefile
config.status: creating config/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
root@ubuntustage:~/sysbench# 

6)  Run make

root@ubuntustage:~/sysbench# make
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash /root/sysbench/config/missing aclocal-1.14 -I m4
configure.ac:27: warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
m4/extensions.m4:2: ACX_USE_SYSTEM_EXTENSIONS is expanded from...
configure.ac:27: the top level
configure.ac:27: warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
m4/extensions.m4:2: ACX_USE_SYSTEM_EXTENSIONS is expanded from...
....

make[2]: Leaving directory `/root/sysbench/sysbench'
make[1]: Leaving directory `/root/sysbench/sysbench'
make[1]: Entering directory `/root/sysbench'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/root/sysbench'
root@ubuntustage:~/sysbench#

7)  Run make install

root@ubuntustage:~/sysbench# make install
Making install in doc
make[1]: Entering directory `/root/sysbench/doc'
Making install in xsl
make[2]: Entering directory `/root/sysbench/doc/xsl'
make[3]: Entering directory `/root/sysbench/doc/xsl'
..........
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/root/sysbench/sysbench/scripting'
make[3]: Leaving directory `/root/sysbench/sysbench/scripting'
make[2]: Leaving directory `/root/sysbench/sysbench/scripting'
Making install in .
make[2]: Entering directory `/root/sysbench/sysbench'
make[3]: Entering directory `/root/sysbench/sysbench'
 /bin/mkdir -p '/usr/local/bin'
  /bin/bash ../libtool   --mode=install /usr/bin/install -c sysbench '/usr/local/bin'
libtool: install: /usr/bin/install -c sysbench /usr/local/bin/sysbench
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/root/sysbench/sysbench'
make[2]: Leaving directory `/root/sysbench/sysbench'
make[1]: Leaving directory `/root/sysbench/sysbench'
make[1]: Entering directory `/root/sysbench'
make[2]: Entering directory `/root/sysbench'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/sysbench'
make[1]: Leaving directory `/root/sysbench'
root@ubuntustage:~/sysbench#

8)  Sysbench commands

Prepare-  Prepares the environment need for operations such as fileio and oltp

Run          –  Running the tests

cleanup   –  Remote the environment prepared in the prepare stage

Help          – Display help information

Version –  Display version number

8) Sysbench command line

sysbench [general-options]... --test=<test-name> [test-options]... command

Running Sysbench

1. Before starting the benchmark, we need to prepare the test data. Following command will generate a table consists of 20 million rows on a Database running locally

sysbench \
--db-driver=mysql \
--mysql-table-engine=innodb \
--oltp-table-size=20000000 \
--mysql-host=127.0.0.1 \
--mysql-port=3306 \
--mysql-user=test \
--mysql-password=password \
--test=/usr/share/sysbench/tests/db/oltp.lua \
prepare

Or we can generate 8 tables consists of 10M rows in parallel with 8 threads (total of 80M rows of data set):

sysbench \
--db-driver=mysql \
--mysql-table-engine=innodb \
--oltp-table-size=10000000 \
--oltp-tables-count=8 \
--num-threads=8 \
--mysql-host=127.0.0.1 \
--mysql-port=3306 \
--mysql-user=test \
--mysql-password=password \
--test=/usr/share/sysbench/tests/db/parallel_prepare.lua \
run

2. Start the benchmark:

sysbench \
--db-driver=mysql \
--num-threads=8 \
--max-requests=5000000 \
--oltp-table-size=20000000 \
--oltp-test-mode=complex \
--test=/usr/share/sysbench/tests/db/oltp.lua \
--mysql-host=127.0.0.1 \
--mysql-port=3306 \
--mysql-user=test \
--mysql-password=password \
run

Running sysbench to measure CPU performance

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

Running sysbench to measure  I/O performance

user $sysbench --test=fileio --file-total-size=128G prepare
user $sysbench --test=fileio --file-total-size=128G --file-test-mode=rndrw --max-time=300 --max-requests=0 run
user $sysbench --test=fileio --file-total-size=128G cleanup

 

 

References for the above info:

http://www.matteomattei.com/how-to-sysbench-on-debian-centos-ubuntu/

How to install sysbench 0.5 on Debian 7

http://blog.secaserver.com/2014/07/sysbench-0-5-ubuntu-14-04-trusty-percona-server-xtradb-cluster/

How to install sysbench 0.5 on Debian 7

http://manpages.ubuntu.com/manpages/trusty/man1/sysbench.1.html

Click to access practical_sysbench.pdf

https://wiki.gentoo.org/wiki/Sysbench#External_resources

Click to access sysbench-manual.pdf

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.