A performance bottleneck analysis method and system for microservice architecture applications
By using a method based on multi-objective genetic algorithms to identify abnormal requests and normal requests in microservice applications, and using Trace structure information to locate performance bottlenecks, the problem in the existing technology that it is difficult to quickly discover and locate performance problems during the test phase is solved, and microservices applications are realized. Performance test automation and availability improvement for service applications.
Patent Information
- Application Number
- CN202210301760.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-24
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2042-03-24
AI Technical Summary
Existing microservice application performance analysis methods mainly focus on discovering and diagnosing performance problems after the system goes online, and lack effective methods and means to quickly expose and locate performance bottlenecks during the testing phase.
A performance problem exposure method based on a multi-objective genetic algorithm is used to automatically identify abnormal requests and normal requests, and through comparison of Trace structure information and critical paths, the service operations that cause performance problems are located.
During the testing phase, it can quickly expose potential performance problems of microservice applications and accurately locate performance bottlenecks, which improves the automation of performance testing of microservice applications, assists testers in analyzing performance problems, and improves application availability.
Smart Images

Figure CN114780385B
Abstract
Description
Technical Field
[0001] The present invention relates to a performance bottleneck analysis method and system for microservice architecture applications, and belongs to the field of Internet. Background Art
[0002] The current software architecture is changing from a monolithic architecture to a microservice architecture. The microservice architecture splits the application into multiple small-grained services and explicitly divides the module boundaries. Different services are in different processes and are independent of each other. Services exchange information through standard lightweight protocols. It has become the mainstream paradigm for enterprises to develop distributed applications. The advantages of using a microservice architecture are: 1) The application is no longer tightly coupled with the underlying framework and development language, and different microservices can be developed using different languages and frameworks; 2) The boundary between components is upgraded from the thread level to the process level, significantly reducing the impact of a single service crash on other services in the system; 3) Each microservice is deployed independently to support continuous integration and continuous release of applications. Although the microservice architecture speeds up the development and delivery of software, it also brings challenges to system operation and maintenance and microservice governance.
[0003] In order to help developers understand the execution status of microservice applications and detect performance anomalies in a timely manner, most cloud vendors provide corresponding performance monitoring tools for application developers, such as Amazon's CloudWatch, Google's StackDriver, Microsoft's Azure Monitor, etc. These monitoring frameworks provide application-level and system-level measurement information, and can report anomalies based on set thresholds, but the disadvantage is that there is a lack of analysis mechanism for monitoring information. Root (Jayathilaka H., Krintz C., Wolski R., Performance Monitoring and Root Cause Analysis for Cloud-hosted Web Applications, International Conference on WorldWide Web, pp. 469-478, 2017, Perth, Australia) reports anomalies by checking whether the average and median of the request response exceed the set static threshold. The work (Wang Ziyong, Wang Tao, Zhang Wenbo, Chen Ningjiang, Zuo Chun. A microservice fault diagnosis method based on execution trace monitoring. Journal of Software, 2017, 28(6): 1435-1454) proposed a microservice anomaly detection and diagnosis method based on execution trace. In order to detect performance anomalies, the coefficient of variation is used to evaluate the degree of abnormality of execution time. In order to timely discover problems existing in microservices during version updates, the work proposed CanaryAdvisor (Tarvo, Alexander, et al. CanaryAdvisor: a statistical-based tool for canary testing. Proceedings of 2015 International Symposium on Software Testing and Analysis. ACM, 2015) an anomaly detection method based on statistical monitoring. By sending requests to different versions of a microservice at the same time and collecting various monitoring measurement information, the use of different measurement information such as CPU usage, error log information, and response time of different versions is compared (based on statistical hypothesis testing) to detect whether there are anomalies in the performance, function, etc. of the new version.
[0004] For distributed applications, user requests usually span multiple different components. Distributed tracing is an important means of fault analysis by building the request processing path in the backend. Early distributed tracing systems, such as: Magpie (Barham, P., Isaacs, R., Mortier, R., and Narayanan, D. Magpie: Online Modelling and Performance-Aware Systems. In 9th USENIX Workshop on Hot Topics inOperating Systems, 2003), latencydistributions.ACM SIGMETRICS Performance Evaluation Review.Vol.36.No.1.ACM, 2008), Mystery Machine (Chow M., Meisner D., Flinn J.,et al.,The Mystery Machine:End-to-end performance analysis of large-scale Internet services,Proceedingsof the symposium on Operating Systems Design and Implementation,pp.217-233,2014) etc. assign a unique ID to each request, record the component information that the request passes through, and establish a complete execution path by associating the information related to the request ID; Dapper (Sigelman,BH,Barroso,LA,Burrows,M.,Stephenson,P.,Plakal,M.,Beaver,D.,Jaspan,S.,Shanbhag,C.Dapper: A Large-Scale Distributed Systems Tracing Infrastructure. Technical Report, Google, 2010) uses sampling technology to reduce the performance overhead introduced by monitoring, proposes the concept of Span ID to maintain the relationship between upstream and downstream service calls, and organizes the context information of the request into a tree structure (called a tracing tree). Zipkin, OpenTracing, and Jaeger are open source implementations developed based on Dapper, and are currently widely used in microservice architecture systems for tracing user requests. .
[0005] Pivot Tracing (Mace, J., Roelke, R., and Fonseca, R. Pivot Tracing: Dynamic Causal Monitoring for Distributed Systems. In 25th ACM Symposium on Operating Systems Principles, 2015) supports users to dynamically characterize monitoring requirements through dynamic code instrumentation mechanism, and supports event causal relationship capture across processes and machine boundaries, which can assist in the discovery of anomalies and analysis of fault causes in distributed systems. Canopy (Chow M., Meisner D., Flinn J., et al., The Mystery Machine: End-to-end performance analysis of large-scale Internet services, Proceedings of the symposium on Operating Systems Design and Implementation, pp. 217-233, 2014) is an end-to-end performance tracing and analysis system, which is characterized by the separation of code instrumentation mechanism and tracing model, and supports real-time processing of tracing and monitoring data of heterogeneous systems. Mystery Machine supports end-to-end request performance analysis technology. It builds application models by analyzing a large amount of component log information and infers the interaction models between components, including: happens-before, mutual exclusive, and first-in-first-out. Based on the constructed causal model, it detects and analyzes anomalies through critical path analysis and slack analysis.
[0006] Work (Thalheim, et al. Sieve: actionable insights from monitored metrics in distributed systems. Proceedings of the 18th ACM / IFIP / USENIX Middleware Conference. ACM, 2017.) proposed a microservice application fault analysis method based on metric information analysis and mining. This method continuously collects system metric information (CPU, memory, network, and disk I / O utilization) and application-level metric information (such as service call response time, concurrent users, etc.) of microservice components, uses the K-Shape time series clustering algorithm to reduce the dimensionality of the metric information, infers the causal relationship between different metrics based on the service dependency graph, and constructs a dependency graph between metrics. By analyzing the changes in the dependency graph before and after the application update, the root cause of the anomaly can be located. Professor Chen Pengfei and Professor Zheng Zibin's team from Sun Yat-sen University proposed Microscope (JinJin Lin, Pengfei Chen, ZibinZheng. Microscope: Pinpoint Performance Issues with Causal Graphs in Microservice Environments. International Conference on Service-oriented Computing, 2018), a performance problem diagnosis method based on causal dependency graphs. It establishes explicit dependencies at the service instance level by monitoring the underlying network calls, and supports the construction of service instance causal dependency graphs in combination with implicit dependencies between service instances. When performance anomalies occur, reverse analysis of the causal dependency graph is performed to support the location of microservice instances with bottlenecks. The work proposed a microservice debugging method based on delta debugging (Xiang Zhou, Jun Sun, Xin Peng, Wenhai Li, Dan Ding, Tao Xie, Chao Ji. Delta debugging microservices system. ACM / IEEE International Conference on Automated Software Engineering, 2016), which supports determining the minimum set of factors that trigger failures by considering many factors that cause execution failures, such as the number of nodes, the number of service instances, configuration, and the order of service calls.
[0007] Through the investigation and analysis of existing work, we found that the existing work on microservice application performance analysis mainly focuses on how to discover and diagnose performance problems after the system is launched, while there is less research on how to expose more system performance problems as quickly as possible during the testing phase and quickly locate the system's performance bottlenecks, and there is a lack of effective methods and means. Summary of the invention
[0008] To solve the above problems, the present invention proposes a performance bottleneck analysis system, method and system for microservice architecture applications, which support the discovery and location of potential performance problems of microservice applications during the testing phase.
[0009] The present invention mainly includes two stages: performance problem exposure and performance bottleneck analysis. In order to expose potential microservice performance problems in the testing phase, a microservice performance problem exposure method based on a multi-objective genetic algorithm is designed to automatically identify and classify "abnormal requests" (with performance problems) and "normal requests" (without performance problems); in the performance bottleneck location phase, by comparing the differences in Trace structure information corresponding to the same request in different classes and the differences in the execution time of service operations within the Trace, the service operations that cause performance problems are accurately located.
[0010] Technical solution of the present invention:
[0011] A performance bottleneck analysis method for microservice architecture applications includes the following steps:
[0012] Search for test request sequences based on genetic algorithms to generate test request sequences that can expose microservice application performance issues;
[0013] Execute the generated test request sequence and record the execution time of each test request;
[0014] According to the execution time of each test request, determine whether there is a performance problem during the execution of the test request, and divide the test requests into two categories: normal requests and abnormal requests. Normal requests do not have performance problems, while abnormal requests do.
[0015] Group normal requests according to the trace structure and trace key path;
[0016] The abnormal request is compared with the corresponding normal request group, and the performance bottleneck is obtained according to whether there is the same trace structure and the same trace critical path.
[0017] Furthermore, the genetic algorithm-based test request sequence search to generate a test request sequence that can expose microservice application performance issues includes:
[0018] Based on the integrated test case set of the application under test, the first generation representation of the genetic algorithm is constructed, where each generation contains a number of individuals, each individual contains a number of test request sequences of the same number, and the test request sequence consists of a set of sequentially executed http test requests;
[0019] Execute the request sequence contained in each individual of the first generation and record the execution time of each request;
[0020] After the initial execution is completed, the test request sequence is evolved by designing crossover and mutation operators for the test request sequence, and different test request input combinations are automatically generated. The test request sequence is guided to evolve by designing a multi-objective fitness function to generate a test request sequence that can expose performance issues of microservice applications.
[0021] Furthermore, the test requests are divided into two categories: normal requests and abnormal requests, including:
[0022] In the initial test case execution phase, based on the collected execution time of each request, the requests are grouped according to the APIs they correspond to. For requests of the same type, the average execution time u and variance δ of the requests are calculated.
[0023] In the test request sequence evolution stage, the request execution time after each round of iteration is collected, and the 3-sigma principle is used to determine the test requests with performance issues. For each request, the corresponding request category is queried. If the execution time of the request is within (u-3δ, u+3δ), the request is judged to have no performance issues and is a normal request. Otherwise, if the request execution time >u+3δ, the request has performance issues and is an abnormal request.
[0024] Furthermore, the grouping of normal requests according to the Trace structure and the Trace key path includes:
[0025] For the trace collection of normal requests, first classify them according to the API interface corresponding to each request;
[0026] For test requests of the same category, they are grouped according to the trace structure information of the requests. The same groups have the same trace structure information.
[0027] For groups with the same trace structure, the critical path of each trace in the group is further calculated. Traces with the same critical path belong to the same sub-group.
[0028] For each sub-group, the average execution time and variance information of each operation on the critical path are calculated based on the execution time of each service operation recorded in the Trace.
[0029] Furthermore, the performance bottleneck is obtained according to whether the same Trace structure and the same critical path exist, including:
[0030] If there are the same Trace structure and the same Trace critical path, the execution time of each operation on the critical path is further compared, the abnormal degree of the operation execution time is identified and sorted, and then a list of potential performance bottlenecks is output;
[0031] If the same Trace structure exists but the same Trace critical path does not exist, the most similar critical path is found, and the first operation call that causes the critical path deviation is determined as the performance bottleneck through comparison and returned;
[0032] If the same Trace structure does not exist, the most similar Trace structure is found, and the first operation call that causes the Trace structure to deviate is determined as the performance bottleneck through comparison and returned.
[0033] A performance bottleneck analysis system for microservice architecture applications, comprising: a request sequence search module based on a genetic algorithm, a test request sequence execution module, a performance problem identification module, a performance information monitoring module, a trace information analysis module and a performance bottleneck location module; wherein:
[0034] The request sequence search module based on the genetic algorithm first constructs the first generation of the genetic algorithm according to the integrated test cases of the application under test, and calls the test request sequence execution module to execute it. Secondly, based on the first generation, a multi-objective request sequence evolution search method is designed. By designing crossover and mutation operators for the test request sequence, the test request sequence is evolved to automatically generate different test request input combinations; by designing a multi-objective fitness function, the test request sequence is guided to evolve to generate a test request sequence that can expose application performance issues.
[0035] Test request sequence execution module: responsible for executing the test request sequence generated by the request sequence search module based on the genetic algorithm, and recording the execution time of each test request.
[0036] Performance information monitoring module: Based on distributed tracing technology, it tracks the processing flow of each test request in the backend (the server side of the application under test) and forms Trace information. Trace records the microservice operations called during the test request processing, the calling relationship between the operations, and the execution time of each microservice operation.
[0037] Performance problem identification module: Based on the test requests and their execution time recorded during the execution of the first generation of test cases, the requests are classified according to the API information corresponding to the requests, and the average response time u and variance δ of each type of request are calculated. During the request sequence search process of multi-objective evolutionary search, the 3-Sigma principle is used to determine whether the request has performance problems during execution based on the recorded execution time of each request, and the requests are divided into two categories: "normal requests" (no performance problems) and "abnormal requests" (performance problems).
[0038] In the trace information analysis module, for the trace collection of "normal requests", it is first classified according to the corresponding API interface, and each group contains requests of the same type. For each classification, it is further grouped according to the trace structure information of the request. The trace structure information in the same group is the same, that is, there is the same microservice operation call sequence. For the trace collection in each partition, the critical path of each trace is calculated according to the execution time and call relationship of each microservice operation in the trace, and the traces in the same partition are further grouped according to the critical path. Traces with the same critical path belong to the same sub-group; and the average execution time and variance information of each operation in the critical path of each trace in the sub-group are further calculated.
[0039] The performance bottleneck location module, for "abnormal requests", firstly queries the corresponding "normal request" group without performance issues according to its API interface; secondly, compares the Trace structure of the "abnormal request" with each partition in the corresponding "normal request" group to determine whether there is the same Trace structure and the same critical path. If both exist, further compare the execution time of each operation on the critical path, identify the degree of abnormality of the operation execution time, sort them, and output a list of potential performance bottlenecks. If the same Trace structure exists but the same critical path does not exist, find the most similar critical path, and determine the first operation call that causes the deviation of the critical path as the performance bottleneck through comparison and return it. If the same Trace structure does not exist, find the most similar Trace structure, and determine the first operation call that causes the deviation of the Trace structure as the performance bottleneck through comparison and return it.
[0040] Furthermore, the implementation process of the request sequence search module based on genetic algorithm is as follows:
[0041] (1)Construct the initial representation of the genetic algorithm based on the set of integration test cases自带的集成测试用例集合构造遗传算法初代表示。其中,代(population)包含若干个体(individual),每个个体包含相同数目的若干测试请求序列,每个测试请求序列也称为染色体(chromosome),测试请求序列由一组顺序执行的http测试请求构成,每个http测试请求也称为基因(gene)。基于被测应用自带的测试用例集,将其进行等分,形成若干个体,每个个体包含相同数目的测试请求序列。如果应用提供的测试用例不是由http请求序列构成,则首先调用测试用例执行引擎,在测试用例执行时捕获http请求序列信息,其将作为染色体的表示,并在此基础上构造个体和初代。
[0042] (2)Call the test request sequence execution module, which concurrently executes the request sequences contained in each individual of the initial generation and records the execution time of each request. During the request execution process, the performance information monitoring module is responsible for tracking the processing flow of the request at the backend, forming Trace information for storage.
[0043] (3)After the initial generation is executed, design crossover and mutation operators to evolve the parent individuals, design a multi-objective fitness function, and use Pareto optimization to select the offspring with higher fitness for the next round of evolutionary search. Set the individual crossover rate to p and the individual internal mutation rate to q. The individual internal mutation is further divided into 3 different mutation operations, including: request execution order mutation (mutation rate set to m), request content mutation (mutation rate set to n), and request Trace mutation (mutation rate set to k), where 0 < p, q, m, n, k < 1, and p + q < 1, m + n + k < 1. The fitness function of the individual mainly considers the following three objectives: 1) The number of test requests with an increase in execution time in the individual. The more the number, the greater the probability that the request has a performance problem, and the individual should be retained to continue participating in the evolution; 2) The degree of increase in the execution time of the request sequence in the individual compared to the parent generation. The longer the execution time, the higher the probability of a performance problem; 3) The number of newly appeared service calls in the Trace corresponding to the request in the individual. New service calls will increase the probability of discovering new performance anomalies, and the corresponding individuals should be retained to continue participating in the evolution. The specific process of one iteration is as follows, where Q stores the generated offspring individuals:
[0044] 1) Randomly generate a random number r between 0 and 1;
[0045] 2) If r < p, perform the crossover operation between individuals;
[0046] 3) If p < r < p + q, perform the mutation operation within an individual. The mutation within an individual mainly targets the request execution sequence and individual requests. The mutation operation is divided into three types: request execution order mutation, request content mutation, and request Trace mutation. Among them, the operation of request execution order mutation is to exchange the execution order of two adjacent requests in the request sequence content; the operation of request content mutation is to modify the message content carried by the request; the operation of request Trace mutation is to modify the return value of the internal service call;
[0047] 4) Repeat steps 1), 2), and 3) until the number of offspring individuals generated is the same as the number of initial individuals;
[0048] 5) Execute the offspring individuals and calculate the fitness of each individual;
[0049] 6) Based on the fitness of the parent individuals and offspring individuals, use the Pareto optimization method to select the optimal individuals (the number of individuals is the same as that of the parents) to enter the next round of iterative search.
[0050] Among them, the execution process of the crossover operation between individuals is as follows:
[0051] 1) Randomly select two parent individuals x1, x2, x1 = (l1,... l k ), x2 = (l1',... l k '); where l1,... l k represents k request sequences in x1, and l1',... l k ' represents k request sequences in x2;
[0052] 2) Randomly generate a vector V composed of 0 and 1, and the length of the vector is equal to the number k of request sequences included in the individual;
[0053] 3) Traverse the vector. If V[i] = 1, then the offspring x1'[i] = x1[i], and the offspring x2'[i] = x2[i]; if V[i] = 0, then the offspring x1'[i] = x2[i], and the offspring x2'[i] = x1[i];
[0054] 4) Select x1'[i] and add it to Q.
[0055] Among them, the execution process of the mutation operation within an individual is as follows:
[0056] 1) Randomly select an individual x i , and traverse each request sequence l i ;
[0057] 2) For each request sequence l i , randomly generate a random number r between 0 and 1
[0058] 3) When r < m, randomly generate an integer k less than len(l i ) - 1, and swap the requests represented by l i [k] and l i [k + 1]; where len represents the length of the request sequence, and l i [k] represents the request corresponding to the k-th position in the request sequence l i ;
[0059] 4) When m < r < m + n, randomly generate an integer k less than or equal to len(l i ) - 1, and modify the message content of the request corresponding to l i [k];
[0060] 5) When m + n < r < m + n + k, randomly generate an integer k less than or equal to len(l i ) - 1, randomly select a service call from the Trace corresponding to l i [k], and inject a fault into the return value of this service call.
[0061] Among them, the individual selection process based on multiple objectives is as follows:
[0062] 1) According to the multi-objective fitness functions of the parent generation and the offspring generation, use the non-dominated sorting method to find the Pareto front and obtain the non-dominated sorted individuals;
[0063] 2) Calculate the crowding distance for each Pareto front;
[0064] 3) Select a specified number of excellent individuals according to the crowding distance as the next generation for evolution.
[0065] Furthermore, the execution process of the performance problem identification module is as follows:
[0066] (1) In the initial test case execution stage, based on the execution time of each collected request, group them according to the corresponding API of the request. For requests of the same type, calculate the average execution time u and variance δ of this type of request;
[0067] (2) In the test request sequence evolution stage, collect the request execution time after each round of iteration, and use the 3-sigma principle to determine the test requests with performance problems. For each request, query the corresponding request category. If the execution time of this request is within (u - 3δ, u + 3δ), it is determined that the request has no performance problem and belongs to the "normal request"; otherwise, if the request execution time > u + 3δ, then this request has a performance problem and belongs to the "abnormal request".
[0068] Furthermore, the execution process of the Trace information analysis module is as follows:
[0069] (1) For the trace set of "normal requests", first classify them according to the API interface corresponding to each request;
[0070] (2) For test requests of the same category, further grouping is performed based on the trace structure information of the request. The same groups have the same trace structure information.
[0071] (3) For groups with the same trace structure, the critical path of each trace in the group is further calculated. Traces with the same critical path belong to the same sub-group;
[0072] (4) For each sub-group, the average execution time and variance information of each operation on the critical path are calculated based on the execution time of each service operation recorded in the Trace.
[0073] Furthermore, the execution process of the performance bottleneck location module is as follows:
[0074] (1) For "abnormal request" Ab req , according to the API interface, query the corresponding "normal request" category (referred to as NC req );
[0075] (2) According to "Abnormal Request" Ab req Trace structure, query NC req Is there a trace group with the same structure (denoted as NEG) in req );
[0076] (3) If NEG req is empty (i.e., there is no group with the same structure), then in NC req The group with the most similar structure (denoted as NSG req ), and returns Ab req and NSG req The first distinct service operation call in
[0077] (4) If NEG req If it is not empty, calculate the "abnormal request" Ab req Corresponding to the critical path information of Trace (denoted as Ab path ) and in NEG req Check whether there is a sub-group with the same critical path (denoted as NEG path );
[0078] (5) If NEG path If it is empty, then NG req The most similar subgroup (denoted as NSG) in the critical path is calculated path), and returns and returns Ab path and NSG path The first distinct service operation call in
[0079] (6) If NEG path If it is not empty, then further compare Ab path and NEG path The execution time of each operation on the critical path and the suspiciousness of each operation op G op The calculation formula is as follows:
[0080] G op =(Ab path .op.time-u(NEG path .op)) / δ(NEG path .op)
[0081] Among them, Ab path .op.time indicates the execution time of the operation op, u(NEG path .op) represents the average execution time of the operation in the corresponding normal group, δ(NEG path .op) indicates the variance information of the execution time of the operation in the corresponding normal group. op The larger the value, the more abnormal the operation execution time is, and the more suspicious the operation is for being a performance bottleneck.
[0082] The positive effects of the present invention are: the present invention can expose the performance problems of microservice applications and locate performance bottlenecks as early as possible during the testing phase, and design a test case evolution method based on multi-target search based on the test case set of the tested microservice application to quickly discover the test request sequence that causes performance problems. During the execution of the test request, the Trace information of the request executed on the server is captured through distributed tracing technology, and the microservice operation call that causes performance problems is quickly located based on the calculation and comparison of the structure information, critical path, and service operation execution time of the Trace. The invention improves the automation level of microservice application performance testing, assists testers in analyzing performance problems, and further improves the availability of microservice applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] Figure 1 It is a block diagram of the composition of the system of the present invention;
[0084] Figure 2 A schematic diagram showing the generation, individual and chromosome of the genetic algorithm in the present invention;
[0085] Figure 3 This is a flowchart for implementing a request sequence search module based on a genetic algorithm;
[0086] Figure 4This is the implementation flow chart of the Trace information analysis module;
[0087] Figure 5 This is the implementation flow chart of the performance bottleneck location module. DETAILED DESCRIPTION
[0088] The present invention is described in detail below with reference to the accompanying drawings.
[0089] like Figure 1 As shown, the present invention provides a performance bottleneck analysis system for microservice architecture applications, including: a request sequence search module based on a genetic algorithm, a test request sequence execution module, a performance information monitoring module, a performance problem identification module, a Trace information analysis module and a performance bottleneck positioning module.
[0090] The main functions of each module are described in detail below, and the implementation process of the method of the present invention is explained through the description of the functions of each module:
[0091] like Figure 2 , Figure 3 As shown, the request sequence search module based on the genetic algorithm of the present invention is specifically implemented as follows:
[0092] The genetic algorithm-based request sequence search module is mainly responsible for designing a genetic algorithm-based test request sequence search method according to the test case set provided by the application under test, and supports automatic discovery of test request sequences that can trigger performance issues in microservice applications.
[0093] 1) If Figure 2 As shown, the module first groups the test case set provided by the tested application to form the first generation of the genetic algorithm. The generation (population) in the genetic algorithm is composed of several individuals (individuals), each individual contains the same number of chromosomes (chromsomes), and each chromosome has a sequence composed of a different number of genes (genes). In the present invention, genes are test requests, and chromosomes are test request sequences of different lengths.
[0094] 2) If Figure 3 As shown, in the test request sequence evolution search phase, the parent individual is first handed over to the test request execution module for execution, and the performance information monitoring module tracks the process flow of each request on the server side to form Trace information. Based on the parent individual, the genetic algorithm-based request sequence search module first determines whether the termination condition of the search is met. In the present invention, the termination condition is set to the maximum number of iterations and the maximum search time. When any condition is met, the search is terminated.
[0095] 3) If the termination condition is not met, first perform crossover between individuals, and then perform mutation within individuals. Currently, the crossover between individuals adopts the uniform crossover method. For mutation within individuals, traverse each request sequence, and select a mutation operation from the mutation operation set according to probability for execution. Currently, three mutation operations are supported, including: request sequence mutation, request mutation, and service call mutation. The request sequence mutation operation randomly exchanges the execution order of two adjacent genes in the request sequence. The request mutation operation randomly selects a request in the request sequence and modifies its parameter value; the service call operation mutates a request and selects a service call according to its trace structure to mutate its return result. Specific mutation operations include: delayed response message return, response message return 503 error, etc. After generating offspring according to the crossover and mutation operations, call the test request sequence execution module to execute individuals in the offspring. During the individual execution process, the performance information monitoring module collects the processing flow of the test request in the backend based on the distributed tracing technology and forms trace information.
[0096] 4) Based on the request execution information collected during the execution of the parent and child generations and the trace information corresponding to the request, the fitness of the individual is calculated. The fitness of the individual mainly considers three objectives: (1) the number of test requests with increased execution time in the individual. The greater the number, the greater the probability of performance problems in the request, and the individual should be retained to continue to participate in the evolution; (2) the degree of increase in the execution time of the request sequence in the individual relative to the parent generation. The longer the execution time, the higher the probability of performance problems; (3) the number of new service calls in the trace corresponding to the request in the individual. New service calls will increase the probability of discovering new performance anomalies, and the corresponding individuals should be retained to continue to participate in the evolution.
[0097] 5) The individual selection process based on multiple objectives is as follows: (1) According to the multi-objective fitness functions of the parent and offspring generations, the non-dominated sorting method is used to find the Pareto front and obtain the non-dominated sorted individuals; (2) The crowding distance is calculated for each Pareto front; (3) According to the crowding distance, a specified number of excellent individuals are selected as the next generation for evolution.
[0098] The specific implementation of the test request sequence execution module is as follows:
[0099] The request sequence execution module executes one individual at a time, and executes several request sequences contained in the individual in a concurrent manner to simulate the operation sequences of different users. During the request sequence execution process, the execution time of each request is calculated by recording the sending time of each request and the receiving time of the response message.
[0100] The specific implementation of the performance information monitoring module is as follows:
[0101] The performance information monitoring module uses distributed tracing technology (Zipkin) to record the processing flow of each request in the application backend and form Trace information. Trace information records the microservice operations triggered by the request in the backend, the call relationship between microservice operations, and the execution time of each operation.
[0102] The specific implementation of the performance problem identification module is as follows:
[0103] 1) The performance problem identification module first classifies the requests by API interface based on the test request execution time collected during the execution of the initial test request sequence and the API interface corresponding to the request. For each type of request, the average execution time and variance information of the request are further calculated;
[0104] 2) In the evolutionary search phase, for each executed request, the 3-sigma principle is used to determine whether the request has execution time anomalies, and the requests are marked as “normal requests” and “abnormal requests”.
[0105] The specific implementation of the trace information analysis module is as follows:
[0106] 1) For the marked "normal requests", they are first classified according to the corresponding API interfaces. Requests with the same API interface and their corresponding traces are classified into the same category;
[0107] 2) For the same type of requests, they are further divided according to the Trace structure. Requests with the same Trace structure belong to the same group (denoted as G Trace );
[0108] 3) For G Trace The request set with the same Trace structure in the group further calculates the critical path of the request. Requests with the same critical path belong to the same group (denoted as G cp );
[0109] 4) For G cp For each request in the process, the execution time T of each operation is calculated based on the trace information. self_time , on this basis, the average execution time and variance information of the operation are calculated.
[0110] The specific implementation of the performance bottleneck location module is as follows:
[0111] 1) For "abnormal request" Ab req , according to the API interface, query the corresponding "normal request" category (referred to as NC req );
[0112] 2) According to "Abnormal Request" Ab req Trace structure, query NCreq Is there a trace group with the same structure (denoted as NEG) in req );
[0113] 3) If NEG req is empty (i.e., there is no group with the same structure), then in NC req The group with the most similar structure (denoted as NSG req ), and returns Ab req and NSG req The first distinct service operation call in
[0114] 4) If NEG req If it is not empty, calculate the "abnormal request" Ab req Corresponding to the critical path information of Trace (denoted as Ab path ) and in NEG req Check whether there is a sub-group with the same critical path (denoted as NEG path );
[0115] 5) If NEG path If it is empty, then NG req The most similar subgroup (denoted as NSG) in the critical path is calculated path ), and returns and returns Ab path and NSG path The first distinct service operation call in
[0116] 6) If NEG path If it is not empty, then further compare Ab path and NEG path The execution time of each operation on the critical path is calculated, and the coefficient of variation of each operation is calculated. The operations are sorted according to the size of the coefficient of variation. The larger the value of the coefficient of variation, the more suspicious it is for being a performance bottleneck.
[0117] Calculate Ab req With NC req The process of checking whether there is the same Trace structure and calculating the similarity of Trace structures is as follows:
[0118] 1) Ab req The trace structure is converted into a tree structure (denoted as Ab tree ) and NC req The trace structure corresponding to each group in is converted into a tree structure (denoted as NC tree ), where the nodes in the tree represent service operations and the edges represent the calling relationships between operations;
[0119] 2) For NC tree Each tree in (denoted as N tree) and Ab tree , respectively, using the idea of width traversal to match nodes, that is, starting from the root node, for Ab tree For each node in N tree Search the same layer to see if there is the same service operation, and if so, mark it as a match;
[0120] 3) After the same-layer matching traversal is completed, the matched nodes are further matched with their child nodes according to 2);
[0121] 4) Repeat step 3) until the bottom leaf node is matched;
[0122] 5) Calculate the number of matching nodes (denoted as NAb match );
[0123] 6) If NAb match With N tree and Ab tree The number of nodes of are equal, then N Trace With Ab Trace The Trace structure is the same as that of Trace ;
[0124] 7) If NAb match With N tree If the number of nodes is not equal, then calculate NAb match / (num(N tree )+num(Ab tree )-NAb match As the similarity, and finally return the N with the largest similarity tree As the most similar Trace structure.
[0125] Based on the same inventive concept, another embodiment of the present invention provides an electronic device (computer, server, smart phone, etc.), which includes a memory and a processor, the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program includes instructions for executing each step in the method of the present invention.
[0126] Based on the same inventive concept, another embodiment of the present invention provides a computer-readable storage medium (such as ROM / RAM, disk, CD), which stores a computer program. When the computer program is executed by a computer, it implements the various steps of the method of the present invention.
[0127] The above embodiments are provided only for the purpose of describing the present invention, and are not intended to limit the scope of the present invention. The scope of the present invention is defined by the appended claims. Various equivalent substitutions and modifications made without departing from the spirit and principles of the present invention should all be included within the scope of the present invention.
Claims
1. A performance bottleneck analysis method for microservice architecture applications, characterized in that: Including the following steps: Search for a test request sequence based on the genetic algorithm to generate a test request sequence that can expose performance problems in the microservice application; Execute the generated test request sequence and record the execution time of each test request; Based on the execution time of each test request, determine whether a performance problem occurs during the execution of the test request, and classify the test requests into two categories: normal requests and abnormal requests. Among them, normal requests have no performance problems, and abnormal requests have performance problems; Group the normal requests according to the Trace structure and the Trace critical path; Compare the abnormal requests with the groups of corresponding normal requests, and obtain the performance bottleneck according to whether there are the same Trace structure and the same Trace critical path; The search for a test request sequence based on the genetic algorithm to generate a test request sequence that can expose performance problems in the microservice application includes: Based on the integration test case set自带 by the application under test, construct the initial representation of the genetic algorithm. Among them, a generation contains several individuals, each individual contains the same number of several test request sequences, and the test request sequence is composed of a group of sequentially executed http test requests; Execute the request sequences included in each individual of the initial generation and record the execution time of each request; After the initial generation is executed, evolve the test request sequence by designing crossover and mutation operators for the test request sequence to automatically generate different test request input combinations, and guide the evolution of the test request sequence by designing a multi-objective fitness function to generate a test request sequence that can expose performance problems in the microservice application.
2. The method according to claim 1, characterized in that The evolution of the test request sequence includes: 1) Randomly generate a random number r between 0 and 1; set the individual crossover rate to p and the individual internal mutation rate to q; 2) If r < p, perform the crossover operation between individuals; 3) If p < r < p + q, perform the mutation operation within the individual; the mutation operation within the individual is divided into 3 types: request execution order mutation, request content mutation, and request Trace mutation; 4) Repeat steps 1), 2), and 3) until the number of generated offspring individuals is the same as the number of initial generation individuals; 5) Execute the offspring individuals and calculate the fitness of each individual; 6) Based on the fitness of the parent individuals and the offspring individuals, use the Pareto optimization method to select the optimal individuals to enter the next round of iterative search.
3. The method according to claim 2, characterized in that The execution process of the crossover operation between individuals is as follows: 1) Randomly select two parent individuals x1, x2, x1 = (l1, ... l k ),x2=(l1 ’ ,…l k ’ ), where l1,…l k represents the k request sequences in x1, l1 ’ ,…l k ’ represents the k request sequences in x2; 2) Randomly generate a vector V composed of 0 and 1, and the vector length is equal to the number k of request sequences included in the individual; 3) Traverse the vector, if V[i] = 1, then the child x1 ’ [i] = x1[i], offspring x2 ’ [i] = x2[i]; if V[i] = 0, then the offspring x1 ’ [i] = x2[i], offspring x2 ’ [i] = x1[i]; 4) Select x1 ’ [i] Join Q, which saves the resulting offspring individuals; The execution process of the mutation operation within the individual is as follows, where m is the mutation rate of the request execution order mutation, n is the mutation rate of the request content mutation, and k is the mutation rate of the request Trace mutation: 1) Randomly select individual x i , traverse each request sequence l i ; 2) For each request sequence l i , randomly generate a random number r between 0 and 1 3) When r < m, randomly generate an integer k less than len(l i ) - 1, and swap the requests represented by l i [k] and l i [k + 1]; 4) When m < r < m + n, randomly generate an integer k less than or equal to len(l i ) - 1, and modify the message content corresponding to l i [k] of the request; 5) When m + n < r < m + n + k, randomly generate an integer k less than or equal to len(l i ) - 1, and randomly select a service call from the Trace corresponding to l i [k], and inject a fault into the return value of this service call.
4. The method according to claim 1, characterized in that: The classification of the test requests into two categories: normal requests and abnormal requests includes: In the initial test case execution stage, based on the execution time of each collected request, group according to the API corresponding to the request. For requests of the same type, calculate the average execution time u and variance δ of this type of request; In the test request sequence evolution stage, the request execution time after each round of iteration is collected, and the 3-sigma principle is used to determine the test requests with performance issues. For each request, the corresponding request category is queried. If the execution time of the request is within (u-3δ, u+3δ), the request is judged to have no performance issues and is a normal request. Otherwise, if the request execution time >u+3δ, the request has performance issues and is an abnormal request.
5. The method according to claim 1, characterized in that The normal requests are grouped according to the Trace structure and the Trace key path, including: For the trace collection of normal requests, first classify them according to the API interface corresponding to each request; For test requests of the same category, they are grouped according to the trace structure information of the requests. The same groups have the same trace structure information. For groups with the same trace structure, the critical path of each trace in the group is further calculated. Traces with the same critical path belong to the same sub-group. For each sub-group, the average execution time and variance information of each operation on the critical path are calculated based on the execution time of each service operation recorded in the Trace.
6. The method according to claim 1, characterized in that The performance bottleneck is obtained based on whether the same trace structure and the same critical path exist, including: If there are the same Trace structure and the same Trace critical path, the execution time of each operation on the critical path is further compared, the abnormal degree of the operation execution time is identified and sorted, and then a list of potential performance bottlenecks is output; If the same Trace structure exists but the same Trace critical path does not exist, the most similar critical path is found, and the first operation call that causes the critical path deviation is determined as the performance bottleneck through comparison and returned; If the same Trace structure does not exist, the most similar Trace structure is found, and the first operation call that causes the Trace structure to deviate is determined as the performance bottleneck through comparison and returned.
7. A performance bottleneck analysis system for microservice architecture applications using the method described in any one of claims 1 to 6, characterized in that: It includes a request sequence search module based on genetic algorithm, a test request sequence execution module, a performance information monitoring module, a performance problem identification module, a trace information analysis module and a performance bottleneck location module; The genetic algorithm-based request sequence search module is used to perform a test request sequence search based on a genetic algorithm to generate a test request sequence that can expose microservice application performance problems; The test request sequence execution module is used to execute the generated test request sequence and record the execution time of each test request; The performance problem identification module is used to determine whether a performance problem occurs during the execution of a test request according to the execution time of each test request, and to classify the test requests into two categories: normal requests and abnormal requests, wherein normal requests do not have performance problems, and abnormal requests do have performance problems; The performance information monitoring module is used to track the processing flow of each test request in the backend and form Trace information based on distributed tracing technology; The trace information analysis module is used to group normal requests according to the trace structure and the trace key path; The performance bottleneck location module is used to compare the abnormal request with the corresponding normal request group, and obtain the performance bottleneck according to whether the same Trace structure and the same Trace critical path exist.
8. An electronic device, characterized in that: The invention comprises a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a computer, the method according to any one of claims 1 to 6 is implemented.
