mysqlslap

You are viewing an old version of this article. View the current version here.

mysqlslap is a tool for load-testing MariaDB. It allows you to emulate multiple concurrent connections, and run a set of queries multiple times.

It returns a benchmark including the following information:

  • Average number of seconds to run all queries
  • Minimum number of seconds to run all queries
  • Maximum number of seconds to run all queries
  • Number of clients running queries
  • Average number of queries per client

Syntax

mysqlslap [options]

Options

The following variables can be set while passed as commandline options to mysqlslap, or set in the [mysqlslap], [client], [client-server] or [client-mariadb] sections in your my.cnf file.

OptionDescription
-a, --auto-generate-sqlGenerate SQL where not supplied by file or command line.
--auto-generate-sql-add-autoincrementAdd an AUTO_INCREMENT column to auto-generated tables.
--auto-generate-sql-execute-number=numSet this number to generate a set number of queries to run.
--auto-generate-sql-guid-primaryAdd GUID based primary keys to auto-generated tables.
--auto-generate-sql-load-type=name Specify test load type: mixed, update, write, key, or read; default is mixed.
--auto-generate-sql-secondary-indexes=numNumber of secondary indexes to add to auto-generated tables.
--auto-generate-sql-unique-query-number=numNumber of unique queries to generate for automatic tests.
--auto-generate-sql-unique-write-number=numNumber of unique queries to generate for auto-generate-sql-write-number.
--auto-generate-sql-write-number=numNumber of row inserts to perform for each thread (default is 100).
--commit=numCommit records every X number of statements.
-C, --compressUse compression in server/client protocol.
-c name, --concurrency=nameNumber of clients to simulate for query to run.
--create=nameFile or string to use create tables.
--create-schema=nameSchema to run tests in.
--csv[=name]Generate CSV output to named file or to stdout if no file is named.
-# , --debug[=options]This is a non-debug version. Catch this and exit.
--debug-checkCheck memory and open file usage at exit.
-T, --debug-infoPrint some debug info at exit.
--default-auth=nameDefault authentication client-side plugin to use.
-F name, --delimiter=nameDelimiter to use in SQL statements supplied in file or command line.
--detach=numDetach (close and reopen) connections after X number of requests.
-e name, --engine=nameComma separated list of storage engines to use for creating the table. The test is run for each engine. You can also specify an option for an engine after a `:', like memory:max_row=2300
-?, --helpDisplay help and exit.
-h name, --host=nameConnect to host.
-i num, --iterations=numNumber of times to run the tests.
--no-dropDo not drop the schema after the test.
-x name, --number-char-cols=nameNumber of VARCHAR columns to create in table if specifying --auto-generate-sql.
-y name, --number-int-cols=nameNumber of INT columns to create in table if specifying --auto-generate-sql.
--number-of-queries=numLimit each client to this number of queries (this is not exact).
--only-printDo not connect to the databases, but instead print out what would have been done.
-p[password], --password[=password]Password to use when connecting to server. If password is not given it's asked from the tty.
--plugin-dir=nameDirectory for client-side plugins.
-P num, --port=numPort number to use for connection.
--post-query=nameQuery to run or file containing query to execute after tests have completed.
--post-system=namesystem() string to execute after tests have completed.
--pre-query=nameQuery to run or file containing query to execute before running tests.
--pre-system=namesystem() string to execute before running tests.
--protocol=nameThe protocol to use for connection (tcp, socket, pipe, memory).
-q name, --query=nameQuery to run or file containing query to run.
-s, --silentRun program in silent mode - no output.
-S name, --socket=nameThe socket file to use for connection.
--sslEnable SSL for connection (automatically enabled with other flags).
--ssl-ca=nameCA file in PEM format (check OpenSSL docs, implies --ssl).
--ssl-capath=nameCA directory (check OpenSSL docs, implies --ssl).
--ssl-cert=nameX509 cert in PEM format (implies --ssl).
--ssl-cipher=nameSSL cipher to use (implies --ssl).
--ssl-key=nameX509 key in PEM format (implies --ssl).
--ssl-crl=nameCertificate revocation list (implies --ssl).
--ssl-crlpath=nameCertificate revocation list path (implies --ssl).
--ssl-verify-server-certVerify server's "Common Name" in its cert against hostname used when connecting. This option is disabled by default.
-u, --user=nameUser for login if not current user.
-v, --verboseMore verbose output; you can use this multiple times to get even more verbose output.
-V, --versionOutput version information and exit.

Examples

Create a table with data, and then query it with 40 simultaneous connections 100 times each.

mysqlslap 
 --delimiter=";" 
 --create="CREATE TABLE t (a int);INSERT INTO t VALUES (5)"
 --query="SELECT * FROM t"
 --concurrency=40
 --iterations=100

Benchmark
	Average number of seconds to run all queries: 0.010 seconds
	Minimum number of seconds to run all queries: 0.009 seconds
	Maximum number of seconds to run all queries: 0.020 seconds
	Number of clients running queries: 40
	Average number of queries per client: 1

Using files to store the create and query SQL. Each file can contain multiple statements separated by the specified delimiter.

mysqlslap
 --create=define.sql
 --query=query.sql
 --concurrency=10
 --iterations=20
 --delimiter=";"

Benchmark
	Average number of seconds to run all queries: 0.002 seconds
	Minimum number of seconds to run all queries: 0.002 seconds
	Maximum number of seconds to run all queries: 0.004 seconds
	Number of clients running queries: 10
	Average number of queries per client: 1

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.