Table of Contents
3.3.3 Usage performance analysis: limited
3.4 Diagnosis of simple and intermittent problems
3.4.1 Single query problem or service problem
Use SHOW GLOBAL STATUS
Use SHOW PROCESSLIST [Reference] Display which threads are running
Use query log
Understand the problems found
gnuplot:
3.4.2 Obtaining diagnostic data
Diagnosis trigger
What kind of data is collected
Interpret the result data
3.4.3 A diagnostic case
3.5 Other analysis tools
Summary:
Home Database Mysql Tutorial [MySQL Database] Interpretation of Chapter 3: Server Performance Analysis (Part 2)

[MySQL Database] Interpretation of Chapter 3: Server Performance Analysis (Part 2)

Aug 07, 2018 pm 01:43 PM
mysql

Let me sigh: DBA is really not covered

3.3.3 Usage performance analysis: limited

3.4 Diagnosis of simple and intermittent problems

If the system occasionally pauses, slows queries, or causes shadowing problems, try not to use trial and error methods to solve problems: the risk is high

3.4.1 Single query problem or service problem

Use SHOW GLOBAL STATUS

Higher frequency: 1s/time execution of this command to obtain data, the problem occurs through the counter

Use SHOW PROCESSLIST [Reference] Display which threads are running

[MySQL Database] Interpretation of Chapter 3: Server Performance Analysis (Part 2)

Use query log

Enable slow query, set global long_query_time=0, and confirm that all connections adopt the new settings (you may need to reset all connections to take effect)

Pay attention to the logs during the period when the throughput suddenly drops. The query is only written to the slow query log during the completion phase

Good tools get twice the result with half the effort: tcpdump, pt-query-digest, Percona Server

Understand the problems found

Visualize data: gnuplot /R (drawing tool)

gnuplot:

Installation Some commands: Common skills Getting started tutorial 2 Gnuplot Data visualization

Recommendation: Use the first two methods first, which are low-cost and interactively collect data through simple shell scripts or repeatedly executed queries

3.4.2 Obtaining diagnostic data

Is intermittent Problem, try to collect as much data as possible (not just when the problem occurs)

Figure out: 1. There is a way to distinguish when the problem occurs: trigger; 2. Tools to collect diagnostic data

Diagnosis trigger

Error: A lot of diagnostic data is collected during the period when no problem occurs, which is a waste of time (this is not inconsistent with the previous one, read it carefully)

Missed detection: When the problem occurs No data was captured, an opportunity was missed. Before starting collection, confirm that the trigger can truly identify the problem.

Good triggers:

Find some that can work with normal Indicators for comparing thresholds

Choose an appropriate threshold: high enough (not triggered when normal), not too high (not missed when problems occur)

Recommended tool pt-stalk【 Reference】【2】Trigger, set to a certain condition to record and configure the frequency of threshold checks for variables to be monitored

What kind of data is collected

Execution time: Working time and waiting time

Collect all the data that can be collected within the required time period

The reason for the unknown problem: 1 , The server needs to do a lot of work, resulting in a lot of CPU consumption; 2. Waiting for resource release

Collect diagnostic data using different methods to confirm the reason:

1. Analysis report: Confirm whether there are too many Work, tool: tcpdump monitors TCP traffic mode opening and closing, slow query log

2. Wait analysis: confirm whether there is a large number of waits, GDB stack trace information, show processlist, show innodb status to observe threads and transaction status

Interpret the result data

Purpose: 1. Whether the problem really occurred; 2. Whether there is an obvious jump change

Tools:

oprofileUsing the performance counter (performance counter) provided at the CPU hardware level, through counting sampling, it helps us find the "culprit" that occupies the CPU from the process, function, and code levels. Example [Reference]

The opreport command is a method to view the CPU usage from the process and function levels respectively

1

2

3

samples |                            %|

-----------------------------------------------------

     镜像内发生的采样次数     采样次数所占总采样次数的百分比      镜像名称

Copy after login

The opannotate command can display the statistical information of the CPU occupied at the code level

GDB:In Linux application development, the most commonly used debugger is gdb (the object of debugging is an executable file). It can set breakpoints in the program, view variable values, and track the execution process of the program step by step. (data, source code), view memory and stack information. Using these functions of the debugger can easily find non-grammatical errors in the program. [Reference] [Reference] Syntax and examples

3.4.3 A diagnostic case

Intermittent performance problem, with knowledge of MySQL, innodb, GNU/Linux

Clear: 1. What is the problem, describe it clearly; 2. What actions have been taken to solve the problem?

Start: 1. Understand the behavior of the server; 2. Sort out the status parameters of the server and configure the software and hardware environment (pt-summary pt-mysql-summary)

Don’t be distracted by various situations that are too off-topic. Write the questions on a slip of paper. Check whether each crossed out

is a cause or a result? ? ?

Possible reasons why resources become inefficient:

1. Resources are overused and the balance is insufficient; 2. Resources are not correctly matched; 3. Resources Damage or failure

3.5 Other analysis tools

USER_STATISTICS: Some tables measure and audit database activities

strace: Investigate system calls, use Actual time, unpredictability, overhead, oprofileUse spent CPU cycles

Summary:

  • The most effective way to define performance is response time

  • If it cannot be measured, it cannot be effectively optimized. Performance optimization work needs to be based on high-quality, comprehensive and complete response time measurement

  • The best starting point for measurement is an application. Even if the problem lies in the underlying database, it is easier to find the problem with good measurements

  • Most systems cannot measure completely, and measurements sometimes have wrong results. Find ways to bypass some limitations and be aware of the flaws and uncertainties of the method.

  • Complete measurements will generate a large amount of data that needs to be analyzed, so you need to use a profiler ( Best tool)

  • Profiling report: summarizes information, glosses over and throws away a lot of details, won’t tell you what’s missing, can’t be completely relied on

  • Two time-consuming operations: work or waiting. Almost the profiler can only measure the time spent on work, so waiting for sharing is sometimes a useful supplement, especially when the CPU utilization is low but the work has never been completed.

  • Optimization and improvement are two different things. When the cost of continued improvement exceeds the benefits, optimization should be stopped

  • Pay attention to your directness, ideas, and decisions as much as possible Based on data

in a words:First clarify the problem, choose the appropriate technology, make good use of tools, be careful enough, have clear logic and stick to it, don’t put the cause and effect Confused, do not make changes to the system casually before determining the problem

Related articles:

[MySQL Database] Chapter 2 Interpretation: MySQL Benchmark Test

[MySQL Database] Interpretation of Chapter 3: Server Performance Analysis (Part 1)

The above is the detailed content of [MySQL Database] Interpretation of Chapter 3: Server Performance Analysis (Part 2). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP's big data structure processing skills PHP's big data structure processing skills May 08, 2024 am 10:24 AM

Big data structure processing skills: Chunking: Break down the data set and process it in chunks to reduce memory consumption. Generator: Generate data items one by one without loading the entire data set, suitable for unlimited data sets. Streaming: Read files or query results line by line, suitable for large files or remote data. External storage: For very large data sets, store the data in a database or NoSQL.

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values ​​to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

The difference between oracle database and mysql The difference between oracle database and mysql May 10, 2024 am 01:54 AM

Oracle database and MySQL are both databases based on the relational model, but Oracle is superior in terms of compatibility, scalability, data types and security; while MySQL focuses on speed and flexibility and is more suitable for small to medium-sized data sets. . ① Oracle provides a wide range of data types, ② provides advanced security features, ③ is suitable for enterprise-level applications; ① MySQL supports NoSQL data types, ② has fewer security measures, and ③ is suitable for small to medium-sized applications.

See all articles