CentOS Performance Test latest tool-sysbench

Source: Internet
Author: User

Sysbench is an open-source multi-threaded performance testing tool that can perform performance tests on CPU, memory, thread, IO, and database. The database currently supports MySQL, Oracle, and PostgreSQL. This article only briefly demonstrates the usage of several tests. We will use sysbench to perform a series of tests on MySQL in the future. Specific parameter settings must be adjusted according to different test requirements.

Compile and install

# Wget-c http://sourceforge.net/projects/sysbench/files/sysbench/0.4.12/sysbench-0.4.12.tar.gz/download

# Tar zxvf sysbench-0.4.12.tar.gz

# Cd sysbench-0.4.12

#./Configure & make install

To test Oracle/PostgreSQL, add the-with-oracle or-with-pgsql parameter to configure.

Parameters

[Root @ localhost sysbench] #./sysbench

Test cases:
Sysbench [general-options]… -Test = <test-name> [test-options]… Command

General options:
-Num-threads = N indicates the number of test threads created. The default value is 1.
-Max-requests = the maximum number of N requests. The default value is limit. 0 indicates no limit.
-Max-time = N: Maximum execution time, in seconds. The default value is 0.
-Forced-shutdown = STRING is forcibly interrupted when the value of max-time is exceeded. The default value is off.]
-Thread-stack-size = SIZE: the stack size of each thread. The default value is 32 KB.
-Init-rng = [on | off] whether to initialize the random number generator at the beginning of the test. The default value is off.
-Test = STRING indicates the name of the test project.
-Debug = [on | off]: whether to display more debugging information. The default value is off.
-Validate = [on | off] perform a verification check if possible. The default value is off.

Test items:
Fileio-File I/O test
Cpu-CPU performance test
Memory-Memory functions speed test
Threads-Threads subsystem performance test
Mutex-Mutex performance test (mutex performance test)
Oltp-OLTP test

Command: prepare (preparations before test) run (formal test) cleanup (delete test data after test) help version

See 'sysbench-test = <name> help' for a list of options for each test. view more options for each test item.

[Root @ localhost bin] #./sysbench-test = fileio help
-File-num = N: Number of test files created. The default value is 128.
-File-block-size = N indicates the size of the file block during the test. The default value is 16384 (16 K)
-File-total-size = SIZE: total size of the test file. The default value is 2 GB.
-File-test-mode = STRING file test mode {seqwr (sequential write), seqrewr (sequential read/write), seqrd (sequential read), rndrd (random read ), rndwr (random write), rndrw (random read/write )}
-File-io-mode = STRING file operation mode {sync (synchronous), async (asynchronous), faw.map (fast map ing), slowmmap (slow map ing )}. The default value is sync.
-File-extra-flags = STRING use an extra flag to open the file {sync, dsync, direct }. Empty by default
-File-fsync-freq = N: the frequency at which fsync () is executed. (0-do not use fsync ()). The default value is 100.
-File-fsync-all = [on | off] fsync is executed every time a write operation is completed. The default value is off.
-File-fsync-end = [on | off] fsync is executed at the end of the test. The default value is on.
-File-fsync-mode = method used by STRING for synchronization {fsync, fdatasync }. The default value is fsync.
-File-merged-requests = N If yes, the maximum number of I/O requests to be merged (0-Indicates not merging ). The default value is 0.
-File-rw-ratio = N read/write ratio during the test. The default value is 1.5.

[Root @ localhost bin] #./sysbench-test = cpu help
-Cpu-max-prime = N maximum number of prime generators. The default value is 10000.

[Root @ localhost bin] #./sysbench-test = memory help
-Memory-block-size = SIZE: the size of the memory block during the test. The default value is 1 K.
-Memory-total-size = SIZE: total size of data transferred. The default value is 100 GB.
-Memory-scope = STRING memory access range {global, local }. The default value is global.
-Memory-hugetlb = [on | off] is allocated from the HugeTLB pool memory. The default value is off.
-Memory = STRING memory operation type. {Read, write, none} is write by default.
-Memory-access-mode = STRING Storage access mode {seq, rnd} is seq by default.

[Root @ localhost bin] #./sysbench-test = threads help
-Thread-yields = N: The number of threads each request generates. The default value is 1000.
-Thread-locks = N number of locks for each thread. The default value is 8.

[Root @ localhost bin] #./sysbench-test = mutex help
-Mutex-num = the total size of the N Array mutex. The default value is 4096.
-Mutex-locks = N the number of mutex locks for each thread. The default value is 50000.
-Mutex-loops = N: number of empty cycles of internal mutex locks. The default value is 10000.

[Root @ localhost bin] #./sysbench-test = oltp help
Oltp options:
-Oltp-test-mode = STRING Execution mode {simple, complex (advanced transactional), nontrx (non-transactional), sp }. The default value is complex.
-Oltp-reconnect-mode = STRING reconnect mode {session (no reconnect is used. Each thread is disconnected only at the end of the test), transaction (reconnect after each transaction ends), and query (reconnect after each SQL statement is executed ), random (select the above reconnection mode randomly for each transaction )}. The default value is session.
-Oltp-sp-name = STRING name of the stored procedure. Empty by default
-Oltp-read-only = [on | off] read-only mode. The Update, delete, and insert statements cannot be executed. The default value is off.
-Oltp-skip-trx = [on | off] omitting the begin/commit statement. The default value is off.
-Oltp-range-size = N query range. The default value is 100.
-Oltp-point-selects = N number of point selects [10]
-Oltp-simple-ranges = N number of simple ranges [1]
-Oltp-sum-ranges = N number of sum ranges [1]
-Oltp-order-ranges = N number of ordered ranges [1]
-Oltp-distinct-ranges = N number of distinct ranges [1]
-Oltp-index-updates = N number of index update [1]
-Oltp-non-index-updates = N number of non-index updates [1]
-Oltp-nontrx-mode = STRING Query type for non-transaction execution modes {select, update_key, update_nokey, insert, delete} [select]
-Oltp-auto-inc = [on | off] whether AUTO_INCREMENT is enabled. The default value is on.
-Oltp-connect-delay = N is connected to the database in milliseconds. The default value is 10000.
-Oltp-user-delay-min = N: minimum waiting time for each request. The Unit is ms. The default value is 0.
-Oltp-user-delay-max = N the maximum waiting time for each request. The Unit is ms. The default value is 0.
-Oltp-table-name = name of the table used in the STRING test. The default value is sbtest.
-Oltp-table-size = N number of records in the test table. The default value is 10000.
-Oltp-dist-type = Random Number of STRING distribution {uniform (even distribution), Gaussian (Gaussian distribution), special (spatial distribution )}. The default value is special.
-Oltp-dist-iter = number of iterations of N generation. The default value is 12.
-The percentage of oltp-dist-pct = N is treated as 'special (for special distribution ). The default value is 1.
-Percentage value of oltp-dist-res = N 'special. The default value is 75.

General database options:
-Db-driver = STRING specifies the database driver ('help' to get list of available drivers)
-Db-ps-mode = STRING report usage mode {auto, disable} [auto]

Compiled-in database drivers:
Mysql-MySQL driver

Mysql options:
-Mysql-host = [LIST,...] MySQL server host [localhost]
-Mysql-port = N MySQL server port [0, 3306]
-Mysql-socket = STRING MySQL socket
-Mysql-user = STRING MySQL user [sbtest]
-Mysql-password = STRING MySQL password []
-Mysql-db = STRING MySQL database name [sbtest]
-Mysql-table-engine = STRING storage engine to use for the test table {myisam, innodb, bdb, heap, ndbcluster, federated} [innodb]
-Mysql-engine-trx = STRING whether storage engine used is transactional or not {yes, no, auto} [auto]
-Mysql-ssl = [on | off] use SSL connections, if available in the client library [off]
-Myisam-max-rows = N max-rows parameter for MyISAM tables [0, 1000000]
-Mysql-create-options = STRING additional options passed to create table []

Test

1. CPU Test

[Root @ localhost bin] #./sysbench-test = cpu-max-prime = 20000 run

Sysbench 0.4.12: multi-threaded system evaluation benchmark

Number of threads: 1

Doing CPU performance benchmark

Threads started!
Done.

Maximum prime number checked in CPU test: 20000
Test execution summary:
Total time: 31.9364 s
Total number of events: 10000
Total time taken by event execution: 31.9334
Per-request statistics:
Min: 3.18 ms
Avg: 3.19 ms
Max: 3.60 ms
Approx. 95 percentile: 3.20 ms

Threads fairness:
Events (avg/stddev): 10000.0000/0.00
Execution time (avg/stddev): 31.9334/0.00

2. Test the number of threads

Thread-locks is smaller than the number of threads divided by 2. The less lock, the longer the processing time.

#./Sysbench-test = threads-num-threads = 512-thread-yields = 100-thread-locks = 2 run

Sysbench 0.4.12: multi-threaded system evaluation benchmark
Run the test with following options: Number of threads: 512
Doing thread subsystem performance test

Thread yields per test: 100 Locks used: 2

Threads started!

WARNING: Operation time (0.000000) is less than minimal counted value, counting as 1.000000

WARNING: Percentile statistics will be inaccurateDone.

Test execution summary:

Total time: 4.1759 s

Total number of events: 10000

Total time taken by event execution: 2038.5959

Per-request statistics:

Min: 0.00 ms

Avg: 203.86 ms

Max: 2735.47 ms

Approx. 95 percentile: 829.60 ms
Threads fairness:

Events (avg/stddev): 19.5312/8.26

Execution time (avg/stddev): 3.9816/0.04

3,Disk I/O performance test

First, generate the required test file. The total file size is 3 GB, 16 concurrent threads, and the random read/write mode. After execution, a pile of small files will be generated in the current directory.

#./Sysbench-test = fileio-num-threads = 16-file-total-size = 3G-file-test-mode = rndrw prepare

Sysbench 0.4.12: multi-threaded system evaluation benchmark

128 files, 24576Kb each, 3072 Mb total

Creating files for the test...

Start test:

#./Sysbench-test = fileio-num-threads = 16-file-total-size = 3G-file-test-mode = rndrw run

Sysbench 0.4.12: multi-threaded system evaluation benchmark

Running the test with following options: Number of threads: 16

Extra file open flags: 0

128 files, 24 Mb each

3 Gb total file size

Block size 16 KB

Number of random requests for random IO: 10000

Read/Write ratio for combined random IO test: 1.50

Periodic FSYNC enabled, calling fsync () each 100 requests

. Calling fsync () at the end of test, Enabled.

Using synchronous I/O modeDoing random r/w test

Threads started!

WARNING: Operation time (0.000000) is less than minimal counted value, counting as 1.000000

WARNING: Percentile statistics will be inaccurateDone.

Operations receivmed: 6004 Read, 3996 Write, 12800 Other = 22800 TotalRead 93.812 Mb Written 62.438 Mb Total transferred 156.25 Mb (6.472 Mb/sec) 414.21 Requests/sec executed

Test execution summary:

Total time: 24.1426 s

Total number of events: 10000

Total time taken by event execution: 164.4243

Per-request statistics:

Min: 0.00 ms

Avg: 16.44 ms

Max: 821.08 ms approx. 95 percentile: 102.40 ms
Threads fairness:

Events (avg/stddev): 625.0000/63.99 e

Xecution time (avg/stddev): 10.2765/0.62

Cleaning site

#./Sysbench-test = fileio-num-threads = 16-file-total-size = 3G-file-test-mode = rndrw cleanup

Sysbench 0.4.12: multi-threaded system evaluation benchmark

Removing test files...

4. Memory Test

The following parameters specify that the entire test process is to transfer 1 GB of data in the memory, and the size of each block is 8 KB.

./Sysbench-test = memory-num-threads = 64-memory-block-size = 8192-memory-total-size = 1G run

Sysbench 0.4.12: multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 64

Doing memory operations speed test

Memory block size: 8 K

Memory transfer size: 1024 M

Memory operations type: writeMemory scope type: globalThreads started! (Last message repeated 1 times)

WARNING: Operation time (0.000000) is less than minimal counted value, counting as 1.000000

WARNING: Percentile statistics will be inaccurate (last message repeated 1 times) Done.

Operations completed MED: 131072 (416391.08 ops/sec)

1024.00 MB transferred (3253.06 MB/sec)

Test execution summary:

Total time: 0.3148 s

Total number of events: 131072

Total time taken by event execution: 17.5553

Per-request statistics:

Min: 0.00 ms

Avg: 0.13 ms

Max: 289.55 ms

Approx. 95 percentile: 0.00 ms
Threads fairness:

Events (avg/stddev): 2048.0000/4854.85

Execution time (avg/stddev): 0.2743/0.04

5. Mutex Test

Test mutex
[Root @ localhost] #./sysbench-test = mutex-num-threads = 1500-max-requests = 2000-mutex-num = 10240-mutex-locks = 100000

-Mutex-loops = 15000 run
Sysbench 0.4.12: multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1500

Doing mutex performance test
Threads started!
Done.
Test execution summary:
Total time: 74.0710 s
Total number of events: 1500
Total time taken by event execution: 5410.6925
Per-request statistics:
Min: 485.77 ms
Avg: 3607.13 ms
Max: 13770.44 ms
Approx. 95 percentile: 12489.67 ms

Threads fairness:
Events (avg/stddev): 1.0000/0.00
Execution time (avg/stddev): 3.6071/3.97

6. MySQL database Testing


First, you must create a default sbtest database, or use-mysql-db to specify an existing database.

Generate test data. The engine is myisam and the table size is 1000000 records.

[root@localhost ]# ./sysbench --test=oltp --mysql-table-engine=myisam --oltp-table-size=1000000 \--mysql-user=root --mysql-socket=/opt/mysql/run/mysql.sock prepare
sysbench 0.4.12: multi-threaded system evaluation benchmarkNo DB drivers specified, using mysqlCreating table 'sbtest'...Creating 1000000 records in table 'sbtest'...root@sbtest 11:42:18>desc sbtest.sbtest;+-------+------------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+-------+------------------+------+-----+---------+----------------+| id | int(10) unsigned | NO | PRI | NULL | auto_increment || k | int(10) unsigned | NO | MUL | 0 | || c | char(120) | NO | | | || pad | char(60) | NO | | | |+-------+------------------+------+-----+---------+----------------+

Run the test

[root@localhost ]# ./sysbench --test=oltp --mysql-table-engine=myisam --oltp-table-size=1000000 \--mysql-user=root --mysql-socket=/opt/mysql/run/mysql.sock run
sysbench 0.4.12: multi-threaded system evaluation benchmarkNo DB drivers specified, using mysqlRunning the test with following options:Number of threads: 1Doing OLTP test.Running mixed OLTP testUsing Special distribution (12 iterations, 1 pct of values are returned in 75 pct cases)Using "LOCK TABLES WRITE" for starting transactionsUsing auto_inc on the id columnMaximum number of requests for OLTP test is limited to 10000Threads started!Done.OLTP test statistics: queries performed: read: 140000 write: 50000 other: 20000 total: 210000 transactions: 10000 (336.64 per sec.) deadlocks: 0 (0.00 per sec.) read/write requests: 190000 (6396.11 per sec.) other operations: 20000 (673.27 per sec.)Test execution summary: total time: 29.7056s total number of events: 10000 total time taken by event execution: 29.6301 per-request statistics: min: 2.27ms avg: 2.96ms max: 43.88ms approx. 95 percentile: 3.36msThreads fairness: events (avg/stddev): 10000.0000/0.00 execution time (avg/stddev): 29.6301/0.00

Cleaning site

[root@localhost ]# ./sysbench--test=oltp --mysql-table-engine=myisam --oltp-table-size=1000000 \--mysql-user=root --mysql-socket=/opt/mysql/run/mysql.sock cleanup
sysbench 0.4.12: multi-threaded system evaluation benchmarkNo DB drivers specified, using mysqlDropping table 'sbtest'...Done.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.