mysqlslap is an official MySQL starting from version 5.1.4 provides stress testing tools. By simulating multiple concurrent clients to access MySQL to perform stress testing, while providing a detailed "high-load MySQL attack" data performance report. Good contrast and can be complicated by the pressure difference between the plurality of storage engine performance under the same environment. By mysqlslap -help option available available Here is a list of some of the main parameters, a more detailed description refer to the official manual. If the system is carrying or using the installation package mysql rpm, mounted MySQL-client-side package have mysqlslap tool.
Below is run mysqlslap -a -c mysql connections when the test process 500 -i 10 -uroot -p123456
Use the following syntax:
# mysqlslap [options]
Common parameters [options] Description:
--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. The value can be: read, key, write, update and mixed (default).
--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
--number-of-queries = N queries overall test (× number of concurrent client queries per customer)
--query = name, -q use a custom test script execution, for example, call a custom stored procedure or sql statement to execute the test.
--Create-schema represents the self-test library name defined test schema, MySQL is the schema database.
After submitting a --commint = how many DML N.
--compress, -C if both the server and client support compression, compression of information transmission.
--concurrency = N, -c N represents concurrency, i.e. the number of clients simultaneously performing analog select. You can specify multiple values, or values comma --delimiter parameter specified as delimiter. For example: - concurrency = 100,200,500.
--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.
--iterations = N, -i N the number of tests performed iteratively, representing different concurrent environment to be in, how many times each test run.
--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.
Description:
During the testing process required to generate the test table, insert test data, this mysqlslap can automatically generate default generate a mysqlslap the schema, if it already exists delete. Can --only-print to print the actual testing process, leaving no trace in the database after the entire test is completed.
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