{"id":2239,"date":"2013-07-12T15:11:07","date_gmt":"2013-07-12T07:11:07","guid":{"rendered":"http:\/\/rmohan.com\/?p=2239"},"modified":"2013-07-12T15:11:07","modified_gmt":"2013-07-12T07:11:07","slug":"mysqlslap-for-mysql-load-testing","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=2239","title":{"rendered":"Mysqlslap for mysql load testing"},"content":{"rendered":"<p>Mysqlslap is a Load Emulation Client. mysqlslap is a diagnostic program designed to emulate client load for a MySQL server and to report the timing of each stage. It works as if multiple clients are accessing the server. mysqlslap is available as of MySQL 5.1.4.<\/p>\n<p>mysqlslap runs in three stages:<\/p>\n<p>1. Create schema, table, and optionally any stored programs or data you want to using for the test. This stage uses a single client connection.<\/p>\n<p>2. Run the load test. This stage can use many client connections.<\/p>\n<p>3. Clean up (disconnect, drop table if specified). This stage uses a single client connection.<\/p>\n<p>Please find expalnations for mysqlslap options below.<\/p>\n<p>#\u00a0\/usr\/local\/mysql\/bin\/mysqlslap -uroot -p &#8211;create-schema=DBName &#8211;query=file.txt &#8211;concurrency=100 &#8211;iterations=1 &#8211;delimiter=&#8221;;&#8221;<\/p>\n<p>mysqlslap usage<\/p>\n<p>To apply auto generated queries,<br \/>\n# mysqlslap -uroot -p &#8211;auto-generate-sql<\/p>\n<p>To use multiple simultaneous client connections,<br \/>\n# mysqlslap -uroot -p &#8211;auto-generate-sql &#8211;concurrency=100<\/p>\n<p>To run the above command multiple times, iteration option is used,<br \/>\n# mysqlslap -uroot -p &#8211;auto-generate-sql &#8211;concurrency=100 &#8211;iterations=5<\/p>\n<p>To specify the number of queries each client executes,<br \/>\n# mysqlslap -uroot -p &#8211;auto-generate-sql &#8211;concurrency=100 &#8211;number-of-queries=1000<\/p>\n<p>The default behavior of mysqlslap when using the \u2013auto-generate-sql switch is to create a two-column table with one integer column and one character column. To adjust these settings to include more integer and\/or character columns, use the &#8211;number-char-cols and &#8211;number-int-cols switches.<br \/>\n# mysqlslap -uroot -p &#8211;auto-generate-sql &#8211;concurrency=100 &#8211;number-of-queries=1000 &#8211;number-char-cols=4 &#8211;number-int-cols=7<\/p>\n<p>To specify the storage engine &#8211;engine option is used,<br \/>\n# mysqlslap -uroot -p &#8211;auto-generate-sql &#8211;concurrency=100 &#8211;number-of-queries=1000 &#8211;number-char-cols=4 &#8211;number-int-cols=7 &#8211;engine=innodb<\/p>\n<p>We can also apply custom queries to mysqlslap either from a text file or directly from command line using &#8211;query option. In order to use an existing database use the &#8211;create-schema option. This doesnt create a schema but uses an existing schema.<br \/>\n# mysqlslap -uroot -p &#8211;create-schema=Cherry_1H_B-01 &#8211;query=cherry_1h.txt &#8211;concurrency=100 &#8211;iterations=5 &#8211;delimiter=&#8221;;&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mysqlslap is a Load Emulation Client. mysqlslap is a diagnostic program designed to emulate client load for a MySQL server and to report the timing of each stage. It works as if multiple clients are accessing the server. mysqlslap is available as of MySQL 5.1.4.<\/p>\n<p>mysqlslap runs in three stages:<\/p>\n<p>1. Create schema, table, and [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2239"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2239"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2239\/revisions"}],"predecessor-version":[{"id":2240,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2239\/revisions\/2240"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}