Sysbench is an open-source multithreaded performance testing tool that performs performance testing in cpu/memory/thread/io/databases. The database currently supports Mysql/oracle/postgresql/drizzle, which mainly includes testing in the following ways:
- CPU Performance
- Disk IO Performance
- Scheduler performance
- memory allocation and transfer speed
- POSIX threading Performance
- Database performance (OLTP benchmark test)
machine configuration
[Email protected] ~]# Grep-ie ' memtotal| Memfree '/proc/meminfo memtotal: 8058060 kbmemfree: 2213240 kb[[email protected] ~]# grep "Processor"/ Proc/cpuinfo | Wc-l4[[email protected] ~]# uname-alinux localhost 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 19:59:55 UTC x86_64 x86_64 x86_64 gnu/linux[[email protected] ~]# cat/etc/redhat-release CentOS release 6.7 (Final)
First, installation
Official address: Https://github.com/akopytov/sysbench
Download method: Git clone https://github.com/akopytov/sysbench.git
Installation
./autogen.sh./configuremake && Make Install
The sysbench of the above command requires MySQL library support by default, if your machine has MySQL installed but no location specified (cannot find mysql_config under path), you must specify it at./configure With-mysql-includes and –with-mysql-libs
You can also use the –without-mysql command to cancel MySQL support
Simple description and function of command commands
Prepare: To prepare for the test, such as creating the necessary files on disk for the Fileis test, preparing the test data for the OLTP test run: Perform the complete test, you must specify the –-test option cleanup: Remove prepare prepared temporary data at the end of the test run Help: Shows the helpful information for different tests (depending on the –-test option), or you can use the Sysbench help command instead of –-test
Explanation of some parameters
--num-threads #创建测试线程的数目--max-requests #请求的最大数目, 0 means no limit--max-time #最大执行时间, unit seconds, 0 means no limit-- Thread-stack-size #每个线程的堆栈大小32K--init-rng #在测试开始之前指定是否需要初始化随机数发生器off--report-interval #隔多久打印一次统计信息 , it is important to note that statistics are statistics that are time-lapse rather than cumulative. Units per second, 0 means to turn off the function--test #指定测试项目名称Required--debug #是否显示更多的调试信息off--validate #在可能的情况下是否进行验证检查off--help #帮助信息off--verbosity #详细级别, 0-critical information, 5-debug Information--percentile #表示设定采样比例, default is 95%, that is, discard 1% long requests, in the remaining 99% to take the maximum value
Second, the CPU benchmark test
The CPU test uses a 64-bit integer to test the time required to calculate the prime number until a maximum, and the CPU test is mainly the addition of prime numbers, in the above example, the maximum prime number is specified as 20000, which can be adjusted according to the performance of the machine CPU, mainly see total Time spent
[Email protected] sysbench]# sysbench--test=cpu--cpu-max-prime=10000 runsysbench 0.5: multi-threaded system Evaluation benchmarkrunning the test with following options:number of Threads:1random number generator seed is 0 and would Be ignoredprimer numbers limit:10000threads started! General statistics: Total time: 14.5690s Total number of events: 10000 total time taken by event Execution:14.5616s Response Time: min: 1.40ms avg: 1.46ms Max: 10.59ms Approx. Percentile: 1.52msThreads Fairness: Events (Avg/stddev): 10000.0000/0.00 Execution Time (avg /stddev): 14.5616/0.00
Related options
SYSBENCH–TEST=CPU help--cpu-max-prime=n Maximum number of prime numbers generators. Default is 10000
Three, thread benchmark test
Thread-locks less than the number of threads divided by 2,lock, the longer the processing time
[Email protected] sysbench]# sysbench --test=threads--num-threads=800--thread-yields=100--thread-locks=10 Run Sysbench 0.5: multi-threaded system evaluation benchmarkrunning the test with following options:number of threads:800 Random number generator seed is 0 and would be ignoredthreads started! General statistics: Total time: 0.4644s Total number of events: 10000 total time taken by event execution:350.9839s Response Time: min: 0.04ms avg: 35.10ms Max: 456.96ms Approx. Percentile: 144.17msThreads Fairness: Events (Avg/stddev): 12.5000/6.45 Execution Time (avg/ StdDev): 0.4387/0.01
Related parameters
Sysbench--test=threads helpsysbench 0.5: multi-threaded System Evaluation Benchmark Threads options: -- Thread-yields=n How many threads each request produces. By default, the number of locks per thread is--thread-locks=n. Default is 8
Iv. File IO Benchmark test
Disk IO performance testing [mainly depends on requests per second (request) and overall throughput (total)
[[email protected] sysbench]# sysbench--test=fileio--num-threads=16--file-total-size=2g--file-test-mode= RNDRW preparesysbench 0.5:multi-threaded System Evaluation benchmark128 files, 16384Kb each, 2048Mb totalcreating files For the test ... Extra File Open flags:0creating file test_file.0creating file test_file.1 ... Creating file test_file.1272147483648 bytes written in 67.56 seconds (30.32 mb/sec). [[email protected] sysbench]# sysbench--test=fileio--num-threads=20--file-total-size=2g--file-test-mode= RNDRW runsysbench 0.5:multi-threaded System Evaluation benchmarkrunning the test with following options:number of thread S:20random number generator seed is 0 and would be ignoredextra file open flags:0128 files, 16Mb each2gb total file Sizeb Lock size 16KbNumber of Io requests:10000read/write ratio for combined random IO test:1.50periodic FSYNC enabled, Callin G Fsync () each of the requests. Calling Fsync () at the end of test, enabled.using synchronous I/O modedoing randomr/w testthreads started! Operations performed:5999 reads, 4001 writes, 12800 other = 22800 Totalread 93.734Mb written 62.516Mb total Transferre D 156.25Mb (19.3mb/sec) 1235.21 requests/sec executedgeneral statistics:total time:8.0958s Total number of events:10000 total time taken by event execution:1.4557s response Time:mi N:0.00MS avg:0.15ms Max: 1319.03ms approx. Percentile:0.02msthreads fairness:events (Avg/stddev): 500.0000/186.14 Execution Time ( Avg/stddev): 0.0728/0.29
Related parameters
Sysbench --test=fileio helpsysbench 0.5: multi-threaded System Evaluation benchmark FILEIO options: -- File-num=n The number of test files created. The default is the size of the file block when the--file-block-size=n test. The default is the total size of the 16384 (16K)--file-total-size=size test file. The default is 2G --file-test-mode=string file test mode {SEQWR (sequential write), SEQREWR (sequential read/write), SEQRD (sequential reading), RNDRD (Random Read), Rndwr (random Write), RNDRW ( Random read/write)} --file-io-mode=string file operation mode {sync (synchronous), async (async), Fastmmap (Fast map map), Slowmmap (slow map)}. By default, Sync --file-extra-flags=string uses an additional flag to open the file {sync,dsync,direct}. The default is the frequency of the empty--file-fsync-freq=n execution Fsync (). (0– does not use Fsync ()). The default is --file-fsync-all=[on|off] executes a fsync once per write operation. The default is off --file-fsync-end=[on|off] to execute fsync at the end of the test. The default is on--file-fsync-mode=string which method is used to synchronize {fsync, fdatasync}. The default is Fsync --file-merged-requests=n If possible, the maximum number of IO requests to merge (0– means not merging). The default is the read-write ratio of 0--file-rw-ratio=n tests. Default is 1.5
Five, Memory benchmark test
Test the continuous read and write performance of memory
[Email protected] sysbench]# sysbench--test=memory--memory-block-size=8k--memory-total-size=1g runsysbench 0.5: multi-threaded System Evaluation benchmarkrunning the test with following options:number of Threads:1random number G Enerator seed is 0 and would be ignoredthreads started! Operations performed:131072 (769179.70 ops/sec) 1024.00 MB transferred (6009.22 Mb/sec) General statistics: Total Time: 0.1704s total number of events: 131072 Total time taken by event execution:0.1387s response Time: min: 0.00ms avg: 0.00ms Max: 2.12ms approx. Percentile: 0.00msThreads Fairness: Events (Avg/stddev): 131072.0000/0.00 Execution Time ( Avg/stddev): 0.1387/0.00
Related parameters
Sysbench --test=memory helpsysbench 0.5: multi-threaded System evaluation benchmark Memory options: -- Memory-block-size=size the size of the memory block when testing. The default is 1K --memory-total-size=size The total size of the transmitted data. The default is 100G --memory-scope=string Memory Access range {global,local}. The default is Global --memory-hugetlb=[on|off] allocation from hugetlb pool memory. The default is the off --memory-oper=string memory operation type. {Read, write, none} default is write --memory-access-mode=string memory access method {Seq,rnd} default is seq
Six, mutual exclusion lock benchmark test
[Email protected] sysbench]# sysbench--test=mutex--num-threads=100--mutex-num=1000--mutex-locks=100000-- mutex-loops=10000 Run sysbench 0.5: multi-threaded system evaluation benchmarkrunning the test with following Options:number of threads:100random number generator seed is 0 and would be ignoredthreads started! General statistics: Total time: 4.9822s Total number of events: All time taken by event execution:474.6478s Response Time: min: 1601.28ms avg: 4746.48ms Max: 4981.76ms approx. Percentile: 4973.56msThreads Fairness: Events (Avg/stddev): 1.0000/0.00 Execution Time (avg/ StdDev): 4.7465/0.40
Related parameters
Sysbench --test=mutex helpsysbench 0.5: multi-threaded system evaluation benchmark mutex options: -- The total size of the mutex-num=n array mutex. The default is the number of 4096--mutex-locks=n per thread mutex. The default is the number of empty loops for the 50000--mutex-loops=n internal mutex. Default is 10000
VII. OLTP Benchmark Test
The complete process is divided into 3 stages: Prepare->run->cleanup, which is to prepare the data, test, clean up the test data, respectively
[[email protected] sysbench]# sysbench--mysql-socket=/var/lib/mysql/mysql.sock--oltp-table-size=100000-- Test=sysbench/tests/db/oltp.lua--mysql-user=root--mysql-password=123456--report-interval=5--num-threads=100-- oltp_tables_count=10--rand-type=uniform--percentile=99 runsysbench 0.5:multi-threaded System Evaluation BenchmarkRu Nning the test with following options:number of Threads:100report intermediate results every 5 second (s) Random number Gen Erator seed is 0 and would be ignoredthreads started! [5s] threads:100, tps:894.57, reads/s: 12790.38, writes/s: 3646.48, Response time:340.91ms (99%) [10s] threads:100 , tps:973.20, reads/s: 13608.42, writes/s: 3860.61, Response time:238.96ms (99%) OLTP test statistics:queries perform ed:read:140000 write:40000 Other: 20000 total:200000 transactions:100XX (932.07 per sec.) Deadlocks:0 (0.00 per Sec.) Read/write requests:180000 (16777.18 per sec.) Other operations:20000 (1864.13 per sec.) General Statistics:total time:10.7289s Total number of events:10000 Tota L Time taken by event execution:1067.3242s response time:min:9.75ms Avg:106.73ms max:450.30ms approx. Percentile:284.52msthreads fairness:events (Avg/stddev): 100.0000/4.15 Execution Time (AV G/stddev): 10.6732/0.05
Related parameters
Sysbench--TEST=OLTP helpsysbench 0.5:multi-threaded System Evaluation benchmark OLTP options:--oltp-test-mode=string Execution Mode {Simple,complex (Advanced transactional), Nontrx (non-transactional), SP}. The default is complex--oltp-reconnect-mode=string Reconnect mode {session (no reconnection is used.) Each thread disconnects only at the end of the test), transaction (reconnect after each transaction), and query (re-connect at the end of each SQL statement), random (select the above reconnection mode randomly for each transaction)}. The default is the name of the session--oltp-sp-name=string stored procedure. The default is empty--oltp-read-only=[on|off] read-only mode. The Update,delete,insert statement is not executable. The default is off--oltp-skip-trx=[on|off] to omit the Begin/commit statement. The default is the off--oltp-range-size=n query scope. The default is--oltp-point-selects=n number of point selects [ten]--oltp-simple-ranges=n number of simple ran GES [1]--oltp-sum-ranges=n number of sum ranges [1]--oltp-order-ranges=n number of ordered range s [1]--oltp-distinct-ranges=n number of distinct ranges [1]--oltp-index-updates=n number of index UPDA Te [1]--oltp-non-index-updates=n number of non-index updates [1]--oltp-nontrx-mode=string query type for non-transactional execution mode {Select, Update_key, Update_nokey, INSERT, delete} [select]--oltp-auto-inc=[on| OFF] auto_increment is turned on. The default is on--oltp-connect-delay=n after how many microseconds to connect to the database. The default is 10000--oltp-user-delay-min=n the minimum wait time per request. Unit is Ms. The default is 0--oltp-user-delay-max=n maximum wait time per request. Unit is Ms. The default is the name of the table used when the 0--oltp-table-name=string is tested. The default is the number of records for the Sbtest--oltp-table-size=n test table. The default is the random number of 10000--oltp-dist-type=string distributions {uniform (evenly distributed), Gaussian (Gaussian distribution), special (spatial distribution)}. The default is the number of iterations of the special--oltp-dist-iter=n generation. The default is a percentage of the--oltp-dist-pct=n value is considered ' special ' (for special distribution). The default is 1--oltp-dist-res=n ' special ' percent value. The default is the general database options:--db-driver=string Specifies the db driver (' Help ' to get list of available drivers)--db-ps-m Ode=string Compiling report usage pattern {auto, disable} [auto]compiled-in database Drivers:mysql-mysql drivermysql options:--my Sql-host=[list,...] Database address--mysql-port=n port number, default 3306--mysql-user=string user name--mysql-password=string password--mysql-db=string Test database name--mysql-table-engine=string database storage engine, default Innodb{myisam , innodb,bdb,heap,ndbcluster,federated}--mysql-socket=string the location of the socket file--mysql-engine-trx=string whether to use transactions, and storage Auto{yes,no,auto}--mysql-ssl=[on|off] Whether the client uses SSL connections, default off--myisam-max-rows=n MyISAM table maximum number of rows, default 1 000000--mysql-create-options=string Additional options passed to create TABLE []
Reference address
Https://launchpad.net/sysbench
Https://github.com/akopytov/sysbench
Use Sysbench for stress testing