MySQL comes with performance stress testing tool mysqlslap Detailed

PS: Today, a colleague asked me with wood have more reliable mysql stress testing tools available. In fact, there is a built-mysql mysqlslap called stress test tool, or analog nice. The following are examples to talk about. 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: [caption id = "attachment_3476" align = "alignnone" width = "693"] mysqlslap Pressure Test [/ caption] using the following syntax: # mysqlslap [options] Common Parameters [options] Description: --auto-generate-sql, -a 自动生成测试表和数据,表示用mysqlslap工具自己生成的SQL脚本来测试并发压力。 --auto-generate-sql-load-type=type 测试语句的类型。代表要测试的环境是读操作还是写操作还是两者混合的。取值包括:read,key,write,update和mixed(默认)。 --auto-generate-sql-add-auto-increment 代表对生成的表自动添加auto_increment列,从5.1.18版本开始支持。 --number-char-cols=N, -x N 自动生成的测试表中包含多少个字符类型的列,默认1 --number-int-cols=N, -y N 自动生成的测试表中包含多少个数字类型的列,默认1 --number-of-queries=N 总的测试查询次数(并发客户数×每客户查询次数) --query=name,-q 使用自定义脚本执行测试,例如可以调用自定义的一个存储过程或者sql语句来执行测试。 --create-schema 代表自定义的测试库名称,测试的schema,MySQL中schema也就是database。 --commint=N 多少条DML后提交一次。 --compress, -C 如果服务器和客户端支持都压缩,则压缩信息传递。 --concurrency=N, -c N 表示并发量,也就是模拟多少个客户端同时执行select。可指定多个值,以逗号或者--delimiter参数指定的值做为分隔符。例如:--concurrency=100,200,500。 --engine=engine_name, -e engine_name 代表要测试的引擎,可以有多个,用分隔符隔开。例如:--engines=myisam,innodb。 --iterations=N, -i N 测试执行的迭代次数,代表要在不同并发环境下,各自运行测试多少次。 --only-print 只打印测试语句而不实际执行。 --detach=N 执行N条语句后断开重连。 --debug-info, -T 打印内存和CPU的相关信息。 Description: testing process requires generating a test table, insert the test data, the mysqlslap can be generated automatically, by default generate a mysqlslap the schema If you delete already exists. Can be used --only-print to print the actual testing process, the entire test is completed without leaving a trace in the database. Examples of various test parameters (-p back with the 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 different properties and allows the storage engine were compared: # mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --iterations=5 --engine=myisam,innodb --debug-info -uroot -p123456 performing a test, respectively 50 and 100 concurrent, execution 1000 Total queries: # mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --debug-info -uroot -p123456 50 and 100 concurrent respectively a test result (Benchmark), the more the number of concurrent, performing all the longer the time of the query. 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
Permanent link: http://www.ha97.com/5182.html  

Reproduced in: https: //my.oschina.net/766/blog/211513

Guess you like

Origin blog.csdn.net/weixin_34212189/article/details/91548314