IntroductionAs the most popular open source database, MySQL is widely used in various fields. As a MySQL DBA, you often perform some performance tests on the database to actively (or passively) evaluate the business pressure and determine the current database load and the highest performance capacity. Common performance testing tools include sysbench and tpcc. Both are excellent stress testing tools, but they require special compilation or installation, and certain development capabilities to modify specific test statements. mysqlslap is automatically installed when MySQL is installed, and mysqlslap encapsulates many custom test functions externally. Users only need to provide SQL statement scripts externally to customize test statements, which makes it easier to use. Instructionsmysqlslap provides a lot of parameters to configure the type of test items. Here we only select some common parameters for explanation. For detailed information, please refer to the help information of mysqlslap itself.
Actual experienceHere is a simple trial of mysqlslap. The target instance uses Tencent Cloud Database MySQL. The simplest test example is as follows: root@VM-64-10-debian:~# 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 root@VM-64-10-debian:~# This example uses the simplest test model, in which mysqlslap generates all test statements and table creation statements by itself. If you want to compare the performance under different concurrency conditions, you can test it in this way: root@VM-64-10-debian:~# 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 root@VM-64-10-debian:~# The output result is time, so the smaller the time, the better the overall performance. If you want to customize the test statement, you can write the SQL statement in the file, for example: root@VM-64-10-debian:~# cat create.sql CREATE TABLE a (b int); INSERT INTO a VALUES (23); root@VM-64-10-debian:~# cat query.sql SELECT * FROM a; SELECT b FROM a; root@VM-64-10-debian:~# root@VM-64-10-debian:~# 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 root@VM-64-10-debian:~# summaryThere are many MySQL stress testing tools available on the market, and each tool has its own advantages and disadvantages. By learning more about the tools and then choosing the most suitable tool according to actual needs, you can complete the required stress testing in the most efficient way. The above is the detailed introduction to the use of MySQL's official performance testing tool mysqlslap. For more information on the use of mysqlslap, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: How to successfully retrieve VMware Esxi root password after forgetting it
>>: 3 ways to create JavaScript objects
Quickstart Guide The Foreman installer is a colle...
【Foreword】 Recently I want to stress test ITOO...
Recently, there is a particularly abnormal busine...
Preface This article only focuses on what Nginx c...
Solution: Directly in the directory where you dow...
With the popularity and maturity of Docker, it ha...
First, let's introduce several common operati...
Based on Vue and native javascript encapsulation,...
Question: What is the difference between int(1) a...
Run the command: glxinfo | grep rendering If the ...
useState useState adds some internal state to a c...
This blog is a work note environment: nginx versi...
What is CSS# CSS (abbreviation of Cascading Style...
Table of contents Preface 1. How to cancel a requ...
Preface: MySQL is a relational database managemen...