当前位置:网站首页>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 .
边栏推荐
- Data sharing between laravel lower views
- [log service CLS] initial experience of Tencent cloud CLS log service
- As a developer, what is the most influential book for you?
- Cvpr2022 𞓜 thin domain adaptation
- 07. Tencent cloud IOT device side learning - Data Template
- Fine! Huawei firewall dual computer hot standby Technology: HRP, vgmp, VRRP
- Which securities company is better and safer for great wisdom to choose when opening an account
- Redis consistency hash and hash slot
- Cvpr2022 | domaine compact adaptable
- Teach you how to deploy the pressure test engine on Tencent cloud
猜你喜欢
![[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

A brief introduction to the lexical analysis of PostgreSQL

ES mapping之keyword;term查詢添加keyword查詢;更改mapping keyword類型

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

同样是初级测试工程师,为啥他薪资高?会这几点面试必定出彩

Do you really know the difference between H5 and applet?

Laravel8 uses faker to call factory to fill data

Laravel 8 realizes auth login
Bitmap of redis data structure

动作捕捉系统用于地下隧道移动机器人定位与建图
随机推荐
Analysis of similarities and differences between redis and memcached in cache use
FPGA based analog I ² C protocol system design (Part 2)
This website teaches you to imitate more than 100 well-known websites!
How to achieve long-term development of voice social source code?
update+catroot+c000021a+critical service failed+drivers+intelide+viaide+000000f
API data interface for announcement of Hong Kong listed companies
09_ An efficient memory method
Is it safe for futures companies to open accounts
东方财富哪个开户更安全,更好点
期货公司开户安全吗
Redis highly available
缓存使用中Redis,Memcached的共性和差异分析
[bitbear story collection] June MVP hero story | technology practice collision realm thinking
Data stack technology sharing: how to use data stack for data collection?
Redis consistency hash and hash slot
Service visibility and observability
Wide measuring range of jishili electrometer
Since the household appliance industry has entered the era of stock competition, why does Suning win the first channel for consecutive times?
leetcode. 12 --- integer to Roman numeral
同样是初级测试工程师,为啥他薪资高?会这几点面试必定出彩