当前位置:网站首页>MySQL toolset: the official performance testing tool mysqlslap
MySQL toolset: the official performance testing tool mysqlslap
2022-06-24 15:34:00 【Wangwen'an @dba】
brief introduction
MySQL As the most popular open source database , It is widely used in various fields , As a MySQL DBA, We often perform some performance tests on the database to take the initiative ( Or passive ) Make an assessment of business stress , To determine the current load and maximum performance capacity of the database .
Common performance testing tools are sysbench and tpcc, Both of these are excellent pressure measuring tools , But they all need special compilation or installation , And you need some development ability to modify the specific test statements .
mysqlslap It's with MySQL It will be installed automatically during installation , and mysqlslap The functions of many custom tests are encapsulated to the outside , Users only need to provide... Externally SQL Statement can customize the test statement , It will be easier to use .
Introduction
mysqlslap Provides a number of parameters to configure the type of project being tested , Here, only some common parameters are extracted for description , For details, please refer to mysqlslap Own help information .
Parameter name | explain |
|---|---|
login-path=# | The new version MySQL Login method provided |
-a, --auto-generate-sql | Automatic generation SQL sentence |
--auto-generate-sql-add-autoincrement | Add auto incrementing columns to the automatically generated table |
--auto-generate-sql-execute-number=# | In the test , perform SQL The total number of times |
--auto-generate-sql-guid-primary | Generation based GUID Primary key of |
--auto-generate-sql-load-type=name | Load model tested , Include mixed, update, write, key,read, The default is mix |
--auto-generate-sql-secondary-indexes=# | Automatically generated tables , Number of secondary indexes |
--auto-generate-sql-unique-query-number=# | In the test , Number of query statements that use unique indexes |
--auto-generate-sql-unique-write-number=# | In the test , Using a unique index DML Number of statements |
--auto-generate-sql-write-number=# | In the test , Each thread executes insert Number of statements , The default is 100 |
--commit=# | In the test , How many statements are executed once commit |
-c, --concurrency=name | In the test , Number of concurrent threads / Number of clients |
--create=name | Custom table creation statement , Or is it SQL File address |
--create-schema=name | In the test , Database name used |
--detach=# | In the test , Reconnection occurs after a certain number of statements are executed |
-e, --engine=name | Specify the storage engine when creating tables |
-h, --host=name | Specify the... Of the test instance host Address |
-u, --user=name | Specify the user name of the test instance |
-p, --password=name | Specify the password for the test instance |
-P, --port=# | Specify the port of the test instance |
-i, --iterations=# | Specify the number of times the test is repeated |
--no-drop | Specify that the library table used for the test will not be deleted after the test is completed |
-x, --number-char-cols=name | Specify the... In the test table varchar The number of columns |
-y, --number-int-cols=name | Specify the... In the test table int The number of columns |
--number-of-queries=# | Specifies the execution of each thread SQL Maximum number of statements ( Imprecise ) |
--only-print | Be similar to dry run, Output what will happen , But it will not really be implemented |
-F, --delimiter=name | Use the SQL When the sentence is , Explicitly specify the separator between statements |
--post-query=name | After the specified test is completed , Executed query statements , Or is it SQL Statement file |
--pre-query=name | Specify before the test starts , Executed query statements , Or is it SQL Statement file |
-q, --query=name | When specifying tests , Executed query statements , Or is it SQL Statement file |
Practical experience
Here to mysqlslap Make a simple trial , The target instance uses Tencent cloud database MySQL, The simplest test example is as follows :
[email protected]:~# mysqlslap --concurrency=100 --iterations 10 -a --auto-generate-sql-add-autoincrement --engine=innodb --number-of-queries=1000 -h172.1.100.10 -uroot -p Enter password: Benchmark Running for engine innodb Average number of seconds to run all queries: 0.046 seconds Minimum number of seconds to run all queries: 0.042 seconds Maximum number of seconds to run all queries: 0.049 seconds Number of clients running queries: 100 Average number of queries per client: 10 [email protected]:~#
The simplest test model used in this example , from mysqlslap Generate all test statements and create table statements by yourself .
If you want to compare the performance under different concurrency , Can be tested in this way :
[email protected]:~# mysqlslap --concurrency=100,200 --iterations 10 -a --auto-generate-sql-add-autoincrement --engine=innodb --number-of-queries=1000 -h172.16.0.40 -uroot -p Enter password: Benchmark Running for engine innodb Average number of seconds to run all queries: 0.046 seconds Minimum number of seconds to run all queries: 0.045 seconds Maximum number of seconds to run all queries: 0.048 seconds Number of clients running queries: 100 Average number of queries per client: 10 Benchmark Running for engine innodb Average number of seconds to run all queries: 0.037 seconds Minimum number of seconds to run all queries: 0.034 seconds Maximum number of seconds to run all queries: 0.052 seconds Number of clients running queries: 200 Average number of queries per client: 5 [email protected]:~#
The output result is time , Therefore, the more time it takes, the better the overall performance .
If you want to customize the test statement , Then you can put SQL The statement is written in the file , for example :
[email protected]:~# cat create.sql CREATE TABLE a (b int);INSERT INTO a VALUES (23); [email protected]:~# cat query.sql SELECT * FROM a; SELECT b FROM a; [email protected]:~# [email protected]:~# mysqlslap --concurrency=100,200 --query=query.sql --create=create.sql --delimiter=";" --engine=innodb --number-of-queries=1000 -h172.16.0.40 -uroot -p Enter password: Benchmark Running for engine innodb Average number of seconds to run all queries: 0.045 seconds Minimum number of seconds to run all queries: 0.045 seconds Maximum number of seconds to run all queries: 0.045 seconds Number of clients running queries: 100 Average number of queries per client: 10 Benchmark Running for engine innodb Average number of seconds to run all queries: 0.023 seconds Minimum number of seconds to run all queries: 0.023 seconds Maximum number of seconds to run all queries: 0.023 seconds Number of clients running queries: 200 Average number of queries per client: 5 [email protected]:~#
Summary
Available on the market MySQL There are many pressure measuring tools , Each tool has its pros and cons , Learn more about tools , Then select the most appropriate tool according to the actual needs to complete the required stress test in the most efficient way .
边栏推荐
- Chapter 8 operation bit and bit string (4)
- Stm32f1 and stm32cubeide programming examples -ws2812b full color LED driver (based on spi+dma)
- CVPR2022 | 可精簡域適應
- How to modify the login user name of easynvr video monitoring system?
- Record the range of data that MySQL update will lock
- 股票网上开户及开户流程怎样?网上开户安全么?
- He is also a junior test engineer. Why is his salary high? The interview must be brilliant at these points
- Bitmap of redis data structure
- FreeRTOS新建任务不执行问题解决办法
- MySQL toolset: the official export tool mysqlpump
猜你喜欢
An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!
![[bitbear story collection] June MVP hero story | technology practice collision realm thinking](/img/b7/ca2f8cfb124e7c68da0293624911d1.png)
[bitbear story collection] June MVP hero story | technology practice collision realm thinking

【我的OpenGL学习进阶之旅】OpenGL的坐标系的学习笔记

How to generate assembly code using clang in Intel syntax- How to generate assembly code with clang in Intel syntax?

Application of motion capture system in positioning and mapping of mobile robot in underground tunnel

Left hand code, right hand open source, part of the open source road

Py's toad: a detailed introduction to toad, its installation and use

高速公路服务区智能一体机解决方案
Redis consistency hash and hash slot

刚刚阿里面软件测试回来,3+1面任职阿里P7,年薪28*15薪
随机推荐
3 ring kill 360 security guard process
Design of vga/lcd display controller system based on FPGA (Part 2)
Is industrial securities reliable? Is it safe to open a securities account?
左手代码,右手开源,开源路上的一份子
At? Let's blow the air conditioner together!
update+catroot+c000021a+critical service failed+drivers+intelide+viaide+000000f
Ethical considerations
Golang implements BigInteger large number calculation
Differential privacy
Is it safe to open an account in flush? What preparation is needed
A full set of tutorials for interviewers from Android manufacturers teach you: prepare for the interview and get the offer smoothly!
入行 4 年,跳槽 2 次,我摸透了软件测试这一行
Left hand code, right hand open source, part of the open source road
Carry forward the fine style of continuous operation and go all out to ensure the safety of Beijiang Levee
Is financial management of securities account safe??
Phpcms upgrade editor method -- simple and effective
Mots clés pour la cartographie es; Ajouter une requête par mot - clé à la requête term; Changer le type de mot - clé de cartographie
Closed loop management of time synchronization service -- time monitoring
中国十大证券app排名 炒股开户安全吗
Security Analysis on mining trend of dogecoin, a public cloud