MySQL comes with performance stress testing tool mysqlslap

 mysqlslap from version 5.1.4 to start MySQL began stress testing tool provided by the official.

By simulating multiple concurrent client access concurrently performed stress tests MySQL, while providing a more detailed report SQL execution performance data, and the same contrast well plurality of concurrent storage engines (MyISAM, InnoDB, etc.) in the same environment difference in performance under pressure.

mysqlslap official description: http: //dev.mysql.com/doc/refman/5.6/en/mysqlslap.html

Common parameters [options] Detailed

--host = host_name, -h hostname (or IP address) is connected to a MySQL server host_name default native localhost

--user = username use MySQL connection services user_name, -u user_name

--password [= password], -p [password] is used to connect the service password MySQL

--create-schema represents the self-test library name defined test schema, MySQL is the schema database.
(When not specify which database, you may encounter an error mysqlslap: Error when connecting to server: 1049 Unknown database 'mysqlslap')

--query = name, -q test is performed using a custom script (script may be a string or SQL), for example, can be called from a stored procedure defined by the sql statement or perform tests.

--create create the required table SQL (SQL may be a string or script)

--concurrency = N, -c N represents concurrency, i.e. the number of clients simultaneously performing analog query. You can specify multiple values, or values ​​comma --delimiter parameter specified as delimiter. For example: - concurrency = 100,200,500 (100,200,500 respectively perform concurrent).

--iterations = N, -i N test iterations performed, to the representatives of different concurrent environment, how many times each test run; run multiple times in order to make the results more accurate.

--number-of-queries = N queries overall test (× number of concurrent client queries per customer)

--engine = engine_name, -e engine_name representative of the engine to be tested, there can be multiple, separated by delimiters. For example: - engines = myisam, innodb, memory.

--auto-generate-sql, -a table and automatic generation of test data, expressed mysqlslap own tool to generate SQL scripts to test the concurrent pressure.

--auto-generate-sql-load-type = type type test statement. To test environment is representative of a read or write operation, or a combination of both. Value comprises:. Read (scan tables), write (insert into tables), key (read primary keys), update (update primary keys), or mixed (half inserts, half scanning selects) the default values ​​are: mixed.

--auto-generate-sql-add-auto-increment representatives automatically add auto_increment columns of the table resulting from the 5.1.18 version began to support.

--number-char-cols = N, the number of character column -x N automatically generated test table contains default 1

--number-int-cols = N, the number of numeric columns -y N automatically generated test table contains default 1

After submitting a --commint = how many DML N.

--compress, -C if both the server and client support compression, compression of information transmission.

--only-print statements to print only a test without actually executed.

To disconnect and reconnect the --detach = N performs an N statement.

--debug-info, -T print information memory and CPU.

Test Example:

mysqlslap -uroot -p --socket /tmp/mysql3306.sock --concurrency=1 --iterations=1 --create-schema='test' --query='SELECT id,unionid,current_num,total_num FROM invite_join WHERE unionid="Cmo" AND active_id="3" AND is_deleted =0 ORDER BY id DESC LIMIT 1;' --number-of-queries=1000000

Examples of various test parameters (with the -p is behind mysql root password):

Single-threaded test. Testing done.
# mysqlslap -a -uroot -p123456
Multi-threaded test. -Concurrency used to simulate concurrent connections.
# mysqlslap -a -c 100 -uroot -p123456
Iterative testing. The need for multiple test is performed to obtain the average.
# mysqlslap -a -i 10 -uroot -p123456

# mysqlslap ---auto-generate-sql-add-autoincrement -a -uroot -p123456
# mysqlslap -a --auto-generate-sql-load-type=read -uroot -p123456
# mysqlslap -a --auto-generate-secondary-indexes=3 -uroot -p123456
# mysqlslap -a --auto-generate-sql-write-number=1000 -uroot -p123456
# mysqlslap --create-schema world -q "select count(*) from City" -uroot -p123456
# mysqlslap -a -e innodb -uroot -p123456
# mysqlslap -a --number-of-queries=10 -uroot -p123456

Test performance while different storage engines were compared:
# mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --iterations=5 --engine=myisam,innodb --debug-info -uroot -p123456

Perform a test, respectively 50 and 100 concurrent execution 1,000 Total queries:
# mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --debug-info -uroot -p123456

50 and 100, respectively, concurrent to get a test result (Benchmark), the more the number of concurrent, the longer the complete implementation of all queries. To make sure, you can be more iterative testing times:
# mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --iterations=5 --debug-info -uroot -p123456

Published 72 original articles · won praise 7 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_39399966/article/details/104717000