mysqlslap — クライアント負荷エミュレーション

mysqlslapはMySQLサーバのクライアント負荷をエミュレートし、各ステージのタイミングを報告する
診断プログラムです。サーバにたいして複数のクライアントがアクセスしているかのように作動します。
mysqlslapはMySQL 5.1.4.から提供されています。

[root@colinux data]# mysqlslap --no-defaults -V
mysqlslap  Ver 1.0 Distrib 5.5.0-m2, for pc-linux-gnu (i686)
[root@colinux data]#
[root@colinux data]# mysqlslap --no-defaults -?
mysqlslap  Ver 1.0 Distrib 5.5.0-m2, for pc-linux-gnu (i686)
Copyright (C) 2005 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Run a query multiple times against the server

Usage: mysqlslap [OPTIONS]

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
The following groups are read: mysqlslap client
The following options may be given as the first argument:
<code>--print-defaults </code>       Print the program argument list and exit
<code>--no-defaults</code>           Don't read default options from any options file
<code>--defaults-file=</code>#       Only read default options from the given file #
<code>--defaults-extra-file=</code># Read this file after the global files are read
<code>  -?, --help </code>         Display this help and exit.
<code>  -a, --auto-generate-sql</code>
                      Generate SQL where not supplied by file or command line.
<code>  --auto-generate-sql-add-autoincrement</code>
                      Add an AUTO_INCREMENT column to auto-generated tables.
<code>  --auto-generate-sql-execute-number=#</code>
                      Set this number to generate a set number of queries to
                      run.
<code>  --auto-generate-sql-guid-primary</code>
                      Add GUID based primary keys to auto-generated tables.
<code>  --auto-generate-sql-load-type=name</code>
                      Specify test load type: mixed, update, write, key, or
                      read; default is mixed.
<code>  --auto-generate-sql-secondary-indexes=</code>#
                      Number of secondary indexes to add to auto-generated
                      tables.
<code>  --auto-generate-sql-unique-query-number=</code>#
                      Number of unique queries to generate for automatic tests.
<code>  --auto-generate-sql-unique-write-number=</code>#
                      Number of unique queries to generate for
                      auto-generate-sql-write-number.
<code>  --auto-generate-sql-write-number=</code>#
                      Number of row inserts to perform for each thread (default
                      is 100).
<code>  --commit=</code>#          Commit records every X number of statements.
<code>  -C, --compress </code>     Use compression in server/client protocol.
<code>  -c, --concurrency=name</code>
                      Number of clients to simulate for query to run.
<code>  --create=name  </code>     File or string to use create tables.
<code>  --create-schema=name</code>
                      Schema to run tests in.
<code>  --csv[=name]  </code>      Generate CSV output to named file or to stdout if no file
                      is named.
<code>  -#, --debug[=#] </code>    This is a non-debug version. Catch this and exit.
<code>  --debug-check </code>      Check memory and open file usage at exit.
<code>  -T, --debug-info</code>    Print some debug info at exit.
<code>  -F, --delimiter=name</code>
                      Delimiter to use in SQL statements supplied in file or
                      command line.
 <code> --detach=</code>#          Detach (close and reopen) connections after X number of
                      requests.
<code>  -e, --engine=name </code>  Storage engine to use for creating the table.
<code> -h, --host=name </code>    Connect to host.
<code>  -i, --iterations=</code>#  Number of times to run the tests.
<code>  -x, --number-char-cols=name</code>
                      Number of VARCHAR columns to create in table if
                      specifying --auto-generate-sql.
<code>  -y, --number-int-cols=name</code>
                      Number of INT columns to create in table if specifying
                      --auto-generate-sql.
<code>  --number-of-queries=</code>#
                      Limit each client to this number of queries (this is not
                      exact).
<code>  --only-print</code>        This causes mysqlslap to not connect to the databases,
                      but instead print out what it would have done instead.
<code>  -p, --password[=name]</code>
                      Password to use when connecting to server. If password is
                      not given it's asked from the tty.
<code>  -P, --port=</code>#        Port number to use for connection.
<code>  --post-query=name</code>   Query to run or file containing query to execute after
                      tests have completed.
<code>  --post-system=name</code>  system() string to execute after tests have completed.
<code>  --pre-query=name </code>   Query to run or file containing query to execute before
                      running tests.
<code>  --pre-system=name</code>   system() string to execute before running tests.
<code>  --protocol=name </code>    The protocol of connection (tcp,socket,pipe,memory).
<code>  -q, --query=name </code>   Query to run or file containing query to run.
<code>  -s, --silent  </code>      Run program in silent mode - no output.
<code>  -S, --socket=name </code>  Socket file to use for connection.
<code>  -u, --user=name </code>    User for login if not current user.
<code>  -v, --verbose </code>      More verbose output; you can use this multiple times to
                      get even more verbose output.
<code>  -V, --version</code>       Output version information and exit.
[root@colinux data]#

————————————————————————————————————————–
ここではDBをSLAPという名前で指定してますが、DBはmysqlslapを実行すると
自動作成(CREATE)されて最後に自動削除(DROP)されます。
既存のDB名を指定して実行する場合はバックアップしておかないとDBが無くなって
しまいますので注意が必要です。
————————————————————————————————————————–
MyIsamを指定してmysqlslapを実行してます

mysqlslap --no-defaults --create-schema=SLAP --auto-generate-sql --auto-generate-sql-guid-primary --engine=myisam --number-int-cols=3 --number-char-cols=5 --concurrency=10 --auto-generate-sql-write-number=1000 --auto-generate-sql-execute-number=1000 --auto-generate-sql-load-type=mixed -u root -p

InnoDBを指定してmysqlslapを実行してます

mysqlslap --no-defaults --create-schema=SLAP --auto-generate-sql --auto-generate-sql-guid-primary --engine=InnoDB --number-int-cols=3 --number-char-cols=5 --concurrency=10 --auto-generate-sql-write-number=1000 --auto-generate-sql-execute-number=1000 --auto-generate-sql-load-type=mixed -u root -p

--no-defaults

を最初に付けないと、
mysqlslap: unknown variable ‘default-character-set=utf8’というエラーが出てきたので
オプションファイルのDefaultをSkipしてテストしています。

mysqlslap

Benchmark
Running for engine myisam
Average number of seconds to run all queries: 5.391 seconds
Minimum number of seconds to run all queries: 5.391 seconds
Maximum number of seconds to run all queries: 5.391 seconds
Number of clients running queries: 10
Average number of queries per client: 1000

Benchmark
Running for engine InnoDB
Average number of seconds to run all queries: 9.250 seconds
Minimum number of seconds to run all queries: 9.250 seconds
Maximum number of seconds to run all queries: 9.250 seconds
Number of clients running queries: 10
Average number of queries per client: 1000

参考サイト

7.16. mysqlslap — クライアント負荷エミュレーション

Comments are closed.

Post Navigation