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.
Option | Description |
---|---|
-a , --auto-generate-sql | Generate SQL statements automatically when they are not supplied in files or via command options. |
--auto-generate-sql-add-autoincrement | Add an AUTO_INCREMENT column to auto-generated tables. |
--auto-generate-sql-execute-number=num | Specify how many queries to generate automatically. |
--auto-generate-sql-guid-primary | Add GUID based primary keys to auto-generated tables. |
--auto-generate-sql-load-type=name | Specify the test load type. The allowable values are read (scan tables), write (insert into tables), key (read primary keys), update (update primary keys), or mixed (half inserts, half scanning selects). The default is mixed. |
--auto-generate-sql-secondary-indexes=num | Number of secondary indexes to add to auto-generated tables. By default, none are added. |
--auto-generate-sql-unique-query-number=num | Number of unique queries to generate for automatic tests. For example, if you run a key test that performs 1000 selects, you can use this option with a value of 1000 to run 1000 unique queries, or with a value of 50 to perform 50 different selects. The default is 10. |
--auto-generate-sql-unique-write-number=num | Number of unique queries to generate for auto-generate-sql-write-number . |
--auto-generate-sql-write-number=num | Number of row inserts to perform for each thread (default is 100). |
--commit=num | Number of statements to execute before committing. The default is 0. |
-C , --compress | Use compression in server/client protocol if both support it. |
-c name , --concurrency=name | Number of clients to simulate for query to run. |
--create=name | File or string to use create tables. |
--create-schema=name | Schema 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-check | Check memory and open file usage at exit. |
-T, --debug-info | Print some debug info at exit. |
--default-auth=name | Default authentication client-side plugin to use. |
-F name , --delimiter=name | Delimiter to use in SQL statements supplied in file or command line. |
--detach=num | Detach (close and reopen) connections after X number of requests. |
-e name , --engine=name | Comma 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 |
-? , --help | Display help and exit. |
-h name , --host=name | Connect to host. |
-i num , --iterations=num | Number of times to run the tests. |
--no-drop | Do not drop the schema after the test. |
-x name , --number-char-cols=name | Number of VARCHAR columns to create in table if specifying --auto-generate-sql. |
-y name , --number-int-cols=name | Number of INT columns to create in table if specifying --auto-generate-sql. |
--number-of-queries=num | Limit each client to this number of queries (this is not exact). |
--only-print | Do 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=name | Directory for client-side plugins. |
-P num , --port=num | Port number to use for connection. |
--post-query=name | Query to run or file containing query to execute after tests have completed. |
--post-system=name | system() string to execute after tests have completed. |
--pre-query=name | Query to run or file containing query to execute before running tests. |
--pre-system=name | system() string to execute before running tests. |
--protocol=name | The protocol to use for connection (tcp, socket, pipe, memory). |
-q name , --query=name | Query to run or file containing query to run. |
-s , --silent | Run program in silent mode - no output. |
-S name , --socket=name | The socket file to use for connection. |
--ssl | Enable SSL for connection (automatically enabled with other flags). |
--ssl-ca=name | CA file in PEM format (check OpenSSL docs, implies --ssl ). |
--ssl-capath=name | CA directory (check OpenSSL docs, implies --ssl ). |
--ssl-cert=name | X509 cert in PEM format (implies --ssl ). |
--ssl-cipher=name | SSL cipher to use (implies --ssl ). |
--ssl-key=name | X509 key in PEM format (implies --ssl ). |
--ssl-crl=name | Certificate revocation list (implies --ssl ). |
--ssl-crlpath=name | Certificate revocation list path (implies --ssl ). |
--ssl-verify-server-cert | Verify server's "Common Name" in its cert against hostname used when connecting. This option is disabled by default. |
-u , --user=name | User for login if not current user. |
-v , --verbose | More verbose output; you can use this multiple times to get even more verbose output. |
-V , --version | Output 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.