当前位置:网站首页>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 .
边栏推荐
- Py's toad: a detailed introduction to toad, its installation and use
- 50 practical applications of R language (23) - important concepts of Bayesian Theory: credibility, model models, and parameters
- Data sharing between laravel lower views
- 安装wireshark时npcap怎么都安装不成功,建议先用winpcap
- A brief introduction to the lexical analysis of PostgreSQL
- 一个简单而功能强大的开发者工具箱Box3.cc
- Huangchuping presided over the video conference on fixed-point contact with Zhuhai, resolutely implemented the deployment requirements of the provincial Party committee, and ensured positive results i
- CIA security model - use PGP to describe privacy and integrity of network security CIA model
- Record the range of data that MySQL update will lock
- How to modify the login user name of easynvr video monitoring system?
猜你喜欢
Record the range of data that MySQL update will lock
From pair to unordered_ Map, theory +leetcode topic practice
List of PostgreSQL
刚刚阿里面软件测试回来,3+1面任职阿里P7,年薪28*15薪
How to generate assembly code using clang in Intel syntax- How to generate assembly code with clang in Intel syntax?
入行 4 年,跳槽 2 次,我摸透了软件测试这一行
高速公路服务区智能一体机解决方案
测试 H5 和小程序的区别,你真的知道吗?
Application of motion capture system in positioning and mapping of mobile robot in underground tunnel
A common defect management tool - Zen, which teaches you from installation to using the handle
随机推荐
股票网上开户及开户流程怎样?网上开户安全么?
09_ An efficient memory method
Concurrent writing of maps in golang
Laravel 8 realizes auth login
设备通过国标GB28181接入EasyCVR平台,出现断流情况该如何解决?
FPGA based analog I ² C protocol system design (Part I)
一个简单而功能强大的开发者工具箱Box3.cc
Easynvr has been connected to the third-party supervision platform. How to achieve local Internet access
How to achieve long-term development of voice social source code?
Py's toad: a detailed introduction to toad, its installation and use
Differential privacy
Is it safe to open an account for stock speculation in the top ten securities app rankings in China
A series of problems caused by IPVS connection reuse in kubernetes
刚刚阿里面软件测试回来,3+1面任职阿里P7,年薪28*15薪
Fine! Huawei firewall dual computer hot standby Technology: HRP, vgmp, VRRP
Openinstall joins hands with the book chain to help channel data analysis and create the era of Book Networking
同样是初级测试工程师,为啥他薪资高?会这几点面试必定出彩
Redis consistency hash and hash slot
动作捕捉系统用于地下隧道移动机器人定位与建图
API data interface for announcement of Hong Kong listed companies