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

What are the methods of performance tuning

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "what are the methods of performance tuning". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. What is the performance test?

Performance testing is through a specific way to exert pressure on the tested system according to a certain test strategy to obtain the response time, throughput, resource utilization and other performance indicators of the system to verify whether the system can meet the needs of users after it is online, including test requirements / purposes, test environment / tools, test scheme, test execution, test results and analysis.

two。 Four indicators to measure the system

To measure the performance of a system, there are mainly the following four indicators:

Response time

The time it takes for an application to perform an operation, including the time it takes from the time the request is made until the response is finally received. Response time is the most important performance index of the system, which directly reflects the speed of the system.

Throughput

Refers to the number of requests processed by the system per unit time, reflecting the overall processing capacity of the system. TPS (Transaction per second) is a commonly used quantitative indicator of throughput, in addition to HPS (Hits per second), QPS (Query per second) and so on.

Resource utilization ratio

It refers to the use of CPU, memory, disk, network and other system resources of the application server, database server and the middleware server included in the tested system.

Concurrent number

Refers to the number of users who submit requests at the same time. The relationship between these four indicators is shown in figure 1.

Figure 2

A request is sent to receive a response, as shown in figure 2. The general process is as follows:

The client sends a request message. The client sends a request message, which is transmitted through the network and reaches the server.

Server processing. After receiving the request message, the server carries out business logic processing and necessary data reading and writing operations.

The server returns a response message. After the server has finished processing, the response message is sent to the client.

We usually refer to the response time as the total time consumed by steps 1, 2, and 3. The first step is mainly client request time and network time; the second step is business logic, data read and write and network time; and the third step is client rendering and network time.

Each step of steps 1, 2, and 3 may have performance problems, resulting in longer response times. In the first step, such as low configuration of the client host, slow response, etc., in the second step, such as business thread blocking, slow database query, and in step 3, such as network transmission delay. According to the types of problems, we can classify the problems as hardware problems, network problems, code problems, middleware problems and so on. There are different tuning methods for different problems, so let's talk about performance tuning briefly.

4. Thief of seizing time-performance tuning

Common tuning methods are:

Space for time. For example, data cache reads data from disk to memory in advance, and CPU requests data to be obtained directly from memory, thus achieving higher efficiency

Time for space, such as uploading large attachments, processing data in batches and completing tasks with less space

Divide and rule, divide tasks, execute them separately, and facilitate parallel execution to improve efficiency

Asynchronous processing, such as MQ message queues, which are most common in Internet applications, splits the more time-consuming traffic on the service link and reduces the blocking impact through asynchronous processing.

Parallel, multiple processes or threads process business at the same time, shortening business processing time

Be closer to the user, such as CDN technology, and put the static resources requested by the user closer to the user.

Everything is scalable, business modularization, service (at the same time no state), good horizontal scalability.

Let's give a few examples to illustrate.

Case 1

Problem description: when testing an interface, with the execution of the pressure test, the response time is getting longer and longer.

Problem analysis:

Printing the thread stack and comparing the thread stack information, it is found that there are more and more FailoverEvent threads in the thread stack, and finally memory overflows.

Looking at the code, it is found that the program does not determine whether the FailoverEvent thread queue already exists, causing the FailoverEvent thread queue to be created repeatedly.

Solution: call downstream services in a multithreaded way.

Solution: get rid of redundant calls and call the selectList method once per request.

Solution: split transaction 1, query it first, and then delete it in batches based on the results of the query.

Optimization result: the deadlock problem is solved.

Tuning recommendations:

Avoid big business

Access data pairs in the same order

Avoid writing transactions that include user interaction

Use low isolation levels, such as RC, as appropriate

Add a reasonable index to the table, if the index is not removed, each row of the table will be locked, and the probability of deadlock will be greatly increased.

Avoid running multiple scripts that read and write the same table at the same time, and pay special attention to locked statements that operate with a large amount of data

Set the lock wait timeout parameter, innodb_lock_wait_timeout.

5. Summary

Response time is usually only the performance of the problem, the root cause lies in whether the use of various resources is reasonable, where resources refer to the broad sense of resources, including hardware / software resources, systems / threads / data and other different levels of resources. Tuning itself is a more reasonable allocation of various resources. The purpose of tuning is usually to meet business needs, so we do not have to pursue premature and over-optimization, and we should realize that performance tuning cannot be done once and for all, and as the business iterates, there will always be new problems. therefore, we should have the consensus and ability to fight a protracted war.

This is the end of the content of "what are the methods of performance tuning". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Development

Wechat

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

12
Report