Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Stress test of database with mysql's own tool mysqlslap

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Mysqlslap is a tool that comes with mysql and does not need to be installed separately:

Parameters:

-concurrency represents the number of concurrency. Multiple concurrency=10,50,100 can be separated by commas. The number of concurrent connection threads is 10,50,100, respectively.

-- engines represents the engine to be tested, and there can be multiple, separated by delimiters.

-- iterations represents how many times to run these tests.

Auto-generate-sql stands for testing with a SQL script generated by the system itself.

-- auto-generate-sql-load-type stands for testing whether to read or write or a mix of both (read,write,update,mixed)

-- number-of-queries represents the total number of queries to run. The number of queries run by each customer can be calculated as the total number of queries / concurrency.

-- debug-info represents additional output of CPU and memory related information.

-- number-int-cols: the number of int fields used to create the test table

-- auto-generate-sql-add-autoincrement: indicates that auto_increment columns are automatically added to the generated table, starting with version 5.1.18

-- the number of char fields in which number-char-cols creates the test table.

-- the schema in the schema,MySQL tested by create-schema is database.

-- query uses custom scripts to execute tests, such as calling a custom stored procedure or sql statement to execute the test.

-- only-print can use this option if you just want to print to see what the SQL statement is.

1. Simple usage [root@Linux_Aolens_01 / home/aolens] # mysqlslap-- user=root-- password=password-- auto-generate-sql Benchmark Average number of seconds to run all queries: 0.002 seconds Minimum number of seconds to run all queries: 0.002 seconds Maximum number of seconds to run all queries: 0.002 seconds Number of clients running queries: 1 Average number of queries per client: 0

The implications of the results:

Average number of... Average number of seconds to run all statements

Minimum number of... Minimum number of seconds to run all statements

Maximum number of... Maximum number of seconds to run all statements

Number of clients... Number of client

Average number of queries run by each client in Average number of queries per client

2. Add concurrent [root@Linux_Aolens_01 / home/aolens] # mysqlslap-- user=root-- password=password-- auto-generate-sql-- concurrency=100-- number-of-queries=1000BenchmarkAverage number of seconds to run all queries: 0.316 secondsMinimum number of seconds to run all queries: 0.316 secondsMaximum number of seconds to run all queries: 0.316 secondsNumber of clients running queries: 100Average number of queries per client: 10

3. Use your own test library and test statements

[root@Linux_Aolens_01 / home/aolens] # mysqlslap-- user=root-- password=password-- concurrency=10-- number-of-queries=100-- create-schema=wordpress-- query= "SELECT * FROM wordpress.wp_posts;" BenchmarkAverage number of seconds to run all queries: 4.255 secondsMinimum number of seconds to run all queries: 4.255 secondsMaximum number of seconds to run all queries: 4.255 secondsNumber of clients running queries: 10Average number of queries per client: 104. combined with practice, do stress test on the database connection requested by the home page of the website.

Database Mariadb 10.0.14

First install the audit plug-in for the database and enable

MariaDB [(none)] > show variables like'% audit%'- > +-- +-+ | Variable_name | Value | +-+ | server _ audit_events | server_audit_excl_users | | server_audit_file_path | server_audit.log | | server_audit_file_rotate_now | OFF | | server_audit_file_rotate_size | 1000000 | server_audit_file_rotations | 9 | server_audit_incl_users | | server_audit_logging | OFF | | server_audit_mode | 0 | server_audit_output_type | file | | server_audit_syslog_facility | LOG_USER | | server_audit_syslog_ident | mysql- Server_auditing | | server_audit_syslog_info | server_audit_syslog_priority | LOG_INFO | +-+ 14 rows in set (0.00 sec)

Found that MariaDB [(none)] > INSTALL PLUGIN server_audit SONAME 'server_audit.so' is installed, but not installed.

The command line starts the audit function:

Audit is enabled on the command line and expires after restart

MariaDB [(none)] > set global server_audit_file_rotate_size=1024*1024*1024;Query OK, 0 rows affected (0.01 sec) MariaDB [(none)] > set global server_audit_events='query,table';Query OK, 0 rows affected (0.00 sec) MariaDB [(none)] > set global server_audit_file_rotate_now=on;Query OK, 0 rows affected (0.00 sec) MariaDB [(none)] > set global server_audit_logging='ON';Query OK, 0 rows affected (0.00 sec)

Refresh the home page to see what SQL operations are in the audit log, and perform stress tests on these SQL:

Mysqlslap-- user=root-- password=password-- concurrency=20-- number-of-queries=1000-- create-schema=wordpress-- query= "\ SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes';\ SELECT option_value FROM wp_options WHERE option_name =' a3roomlzgift googlekeeper apiece keyword 'LIMIT 1;\ SELECT option_value FROM wp_options WHERE option_name =' a3roomlzghost googlekeeper apiece keyword enable` LIMIT 1 \ SELECT option_value FROM wp_options WHERE option_name ='_ transient_timeout_a3_lz_google_api_key_status' LIMIT 1;\ SELECT option_value FROM wp_options WHERE option_name ='_ transient_a3_lz_google_api_key_status' LIMIT 1;\ SELECT option_value FROM wp_options WHERE option_name = 'wordpress_api_key' LIMIT 1;\ SELECT option_value FROM wp_options WHERE option_name =' onp_license_clipboard-p_w_picpaths' LIMIT 1 \ SELECT autoload FROM wp_options WHERE option_name = 'onp_license_clipboard-p_w_picpaths';\ SELECT option_value FROM wp_options WHERE option_name =' onp_version_check_clipboard-p_w_picpaths' LIMIT 1;\ SELECT option_value FROM wp_options WHERE option_name = 'ossdl_https' LIMIT 1;\ SELECT option_value FROM wp_options WHERE option_name =' uninstall_plugins' LIMIT 1 \ SELECT option_value FROM wp_options WHERE option_name ='a3 lazy lazyloadloadjustworthy installed' LIMIT 1;\ SELECT option_value FROM wp_options WHERE option_name = 'akismet_comment_nonce' LIMIT 1;\ SELECT option_value FROM wp_options WHERE option_name =' preload_cache_counter' LIMIT 1;\ SELECT option_value FROM wp_options WHERE option_name = 'rewrite_rules' LIMIT 1 \. "BenchmarkAverage number of seconds to run all queries: 40.931 secondsMinimum number of seconds to run all queries: 40.931 secondsMaximum number of seconds to run all queries: 40.931 secondsNumber of clients running queries: 20Average number of queries per client: 50

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report