A method, medium and system for optimizing the granularity of enterprise production data microservices

By constructing the coupling degree and cohesion matrix of microservices and optimizing the microservice division scheme using hybrid optimization algorithms, the problem of difficulty in determining the reasonable microservice granularity in the existing technology is solved, and the system is efficient and maintainable and low operation and maintenance costs are achieved.

CN119356687BActive Publication Date: 2025-04-15QINGDAO GENGZE INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411918059.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-15
Estimated Expiration
2044-12-25

AI Technical Summary

Technical Problem

It is difficult for the prior art to determine a reasonable microservice granularity, resulting in increased system complexity, reduced resource utilization efficiency and increased operation and maintenance costs.

Method used

By obtaining the dependency data of microservices and business flow data in the enterprise production data system, a microservice coupling degree matrix and cohesion degree matrix are constructed, a microservice granularity evaluation equation system is established, and a hybrid optimization algorithm, including the gray wolf algorithm and genetic algorithm, optimize the microservice division scheme.

Benefits of technology

A multi-dimensional quantitative evaluation of the microservice granularity is realized, the coupling and cohesion between microservices is optimized, the maintenance and elasticity of the system is improved, and the operation and maintenance costs are reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119356687B_ABST
    Figure CN119356687B_ABST
Patent Text Reader

Abstract

The present invention provides a method, medium and system for optimizing the granularity of microservices for enterprise production data, which belongs to the technical field of production data management. By acquiring the dependency relationship and business flow data of microservices in the enterprise production data system, a coupling degree and cohesion matrix are constructed, and a group of microservice granularity evaluation equations are established. The method adopts a hybrid optimization algorithm, combines the search direction of the gray wolf algorithm and the population evolution of the genetic algorithm, and constructs a composite fitness function including system response time, resource utilization, maintenance cost and microservice granularity balance. Through iterative optimization, the microservice partitioning scheme is continuously updated until the preset number of iterations is reached and the composite fitness function meets the optimization target, and finally the optimal microservice partitioning scheme is output. The hybrid optimization algorithm of the present invention finds a partitioning scheme that meets multiple indicators such as system response time, resource utilization, maintenance cost and granularity balance, and solves the technical problem that the prior art is difficult to determine the microservice granularity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of production data management, and in particular, relates to a method, medium and system for optimizing the granularity of enterprise production data microservices. Background Art

[0002] In recent years, with the widespread application of microservice architecture in enterprise information systems, the issue of microservice division has become a focus of industry attention. The traditional monolithic application architecture is bloated and difficult to meet the needs of agile development and elastic scaling, so it is gradually replaced by a distributed system architecture based on microservices. Under this architecture, the business system of an enterprise is divided into multiple loosely coupled microservice units. Each microservice undertakes a specific functional module and collaborates with each other through a lightweight communication mechanism to realize the overall business process.

[0003] At present, the main methods for microservice division are the method based on domain-driven design and the method based on functional coupling. The former emphasizes business boundaries and aggregates functions with the same business attributes into a microservice unit, but it is difficult to quantify and evaluate the cohesion and external dependencies of microservices. The latter focuses more on technical factors and divides microservices according to the frequency of interface calls and the amount of data interaction between microservices, but it cannot fully reflect the business characteristics of microservices. Too fine microservice granularity will lead to increased system complexity, reduced resource utilization efficiency and increased operation and maintenance costs, while too coarse microservice granularity cannot give full play to the advantages of microservice architecture, and it is difficult to achieve flexible expansion and contraction and efficient function iteration. Therefore, how to determine a reasonable microservice granularity is a key issue that needs to be solved urgently. Summary of the invention

[0004] In view of this, the present invention provides a method, medium and system for optimizing the granularity of microservices of enterprise production data, which can solve the technical problem that it is difficult to determine the granularity of microservices in the prior art.

[0005] The present invention is achieved in that:

[0006] A first aspect of the present invention provides a method for optimizing the granularity of enterprise production data microservices, comprising the following steps:

[0007] S10. Obtain dependency data and business flow data of all microservices in the enterprise production data system;

[0008] S20, constructing a microservice coupling matrix based on the dependency data, wherein the coupling matrix includes call frequency, data interaction volume, and number of interfaces between microservices;

[0009] S30, constructing a microservice cohesion matrix based on the business flow data, wherein the cohesion matrix includes business function similarity, data consistency requirements, and transaction integrity requirements;

[0010] S40, establishing a microservice granularity evaluation equation group according to the coupling degree matrix and the cohesion degree matrix, wherein the microservice granularity evaluation equation group includes a coupling degree weight calculation equation, a cohesion degree weight calculation equation, and a granularity balance coefficient calculation equation;

[0011] S50, using the microservice granularity assessment equation group to perform a preliminary assessment on the existing microservices to obtain an initial microservice granularity assessment value;

[0012] S60, inputting the initial microservice granularity evaluation value into a hybrid optimization algorithm, wherein the hybrid optimization algorithm determines a search direction through a gray wolf algorithm and performs population evolution through a genetic algorithm;

[0013] S70, constructing a composite fitness function based on the hybrid optimization algorithm, wherein the composite fitness function is composed of system response time, resource utilization, maintenance cost, and microservice granularity balance;

[0014] S80, using the hybrid optimization algorithm to iteratively optimize the microservice partitioning scheme, each round of iteration includes gray wolf position update and genetic operator operation;

[0015] S90. When the number of iterations reaches a preset value and the composite fitness function value meets the optimization target, the final microservice partitioning scheme is output; otherwise, the process returns to step S80 to continue the optimization.

[0016] The enterprise production data system is a distributed system composed of multiple mutually cooperating microservices, which are responsible for production planning management, material demand management, production process control, quality management, equipment management, warehouse management and production statistical analysis functions;

[0017] The coupling degree weight calculation equation is used to quantitatively evaluate the degree of dependency between microservices. The input includes call frequency data, interface call response time data and data interaction scale data between microservices. The output is a numerical weight that represents the coupling strength between microservices.

[0018] The cohesion weight calculation equation is used to quantitatively evaluate the degree of aggregation of microservice internal functions. The input includes business function similarity data, data access frequency data and transaction correlation data. The output is a numerical weight that represents the concentration of microservice internal functions.

[0019] The granularity balance coefficient calculation equation is used to evaluate the scale balance of microservices. The input includes statistical data on the number of code lines, statistical data on the number of interfaces, and service complexity evaluation data. The output is a balance coefficient that characterizes the rationality of the scale distribution of microservices.

[0020] The calculation process and matrix involved in the present invention are described in detail below:

[0021] The coupling degree matrix is ​​specifically expressed as follows:

[0022] ;

[0023] In the formula, Indicates The first microservice and the The degree of coupling between microservices; is the total number of microservices.

[0024] The cohesion matrix is ​​specifically expressed as follows:

[0025] ;

[0026] In the formula, Indicates Microservice internal The cohesion of each functional module; is the total number of microservices.

[0027] The coupling degree weight calculation equation is specifically expressed as follows:

[0028] ;

[0029] In the formula, is the coupling weight; For Microservices and The frequency of calls between For Microservices and The average response time between For Microservices and The amount of data interaction between is the weight coefficient and satisfies ; is the error term.

[0030] The cohesion weight calculation equation is specifically expressed as follows:

[0031] ;

[0032] In the formula, is the cohesion weight; is the functional similarity; is the data access frequency; is the transaction relevance; is the weight coefficient and satisfies ; is the error term.

[0033] The particle size balance coefficient calculation equation is specifically expressed as follows:

[0034] ;

[0035] In the formula, is the particle size balance coefficient; They are the maximum and minimum number of lines of code respectively; They are the maximum and minimum number of interfaces respectively; are the maximum and minimum values ​​of complexity respectively; are the standard deviations of the corresponding indicators respectively; is the weight coefficient and satisfies ; is the error term.

[0036] Parameter acquisition method description:

[0037] 1. Obtained through log analysis, counting the number of calls between microservices per unit time;

[0038] 2. Obtained through performance monitoring tools, calculate the average response time of interface calls between microservices;

[0039] 3. Obtain statistics on the amount of data transmitted between microservices through network traffic monitoring;

[0040] 4. Calculated by semantic similarity algorithm, based on business function description text;

[0041] 5. Obtained through database access log analysis;

[0042] 6. Obtained by analyzing distributed transaction logs;

[0043] 7. Obtained through code static analysis tools;

[0044] 8. Obtained through interface document parsing;

[0045] 9. Obtained through cyclomatic complexity calculation tool.

[0046] Explanation of the equation construction principle:

[0047] 1. The coupling degree weight calculation equation adopts the weighted normalization form, taking into account the three dimensions of call frequency, response time and data interaction, and eliminating the dimension effect through normalization processing;

[0048] 2. The cohesion weight calculation equation also adopts the weighted normalization form, taking into account the three dimensions of functional similarity, data access frequency and transaction relevance;

[0049] 3. The particle size balance coefficient calculation equation adopts the Gaussian kernel function form, which can effectively reflect the difference degree of various indicators. The greater the difference, the smaller the balance coefficient;

[0050] 4. Error terms are introduced into all equations to deal with uncertainties in practical applications.

[0051] The following is a detailed description of the derivation process and effect of each equation:

[0052] 1. Derivation process of coupling weight calculation equation:

[0053] Step 1: Determine basic evaluation indicators;

[0054] Indicates the call frequency index: ; This item reflects the call intensity between microservices, and is normalized to a range of between.

[0055] Indicates the response time indicator: ; This item reflects the performance dependency between microservices and is normalized to a range of between.

[0056] Indicates data interaction indicators: ; This item reflects the data dependency between microservices and is normalized to make its range between.

[0057] Step 2: Introduce weight coefficient:

[0058] ;

[0059] Weight coefficient Determined through the hierarchical analysis method, it reflects the relative importance of each indicator.

[0060] 2. Derivation process of cohesion weight calculation equation:

[0061] Step 1: Determine basic evaluation indicators;

[0062] Functional similarity metrics: ; Calculated by text similarity algorithm.

[0063] Data access frequency indicators: ;Reflects the degree of cohesion of data operations.

[0064] Transaction relevance index: ;Reflect the integrity of business transactions.

[0065] Step 2: Introduce weight coefficient:

[0066] ;

[0067] Weight coefficient Determined by expert scoring.

[0068] 3. Derivation process of particle size balance coefficient calculation equation:

[0069] Step 1: Build code scale balance: ;

[0070] Using the Gaussian kernel function, the greater the difference between the maximum and minimum values, the lower the balance.

[0071] Step 2: Build a balanced interface quantity: ; The Gaussian kernel function is also used.

[0072] Step 3: Build complexity balance: ;Reflects the balance of microservice complexity distribution.

[0073] Step 4: Comprehensive balance coefficient:

[0074] ;

[0075] Weight coefficient Determined through multi-objective optimization.

[0076] The effects of these equations are:

[0077] 1. Coupling weight calculation equation: It can quantitatively evaluate the degree of dependency between microservices; it solves the problem of different dimensions through normalization; the introduction of weight coefficients makes the evaluation more objective; the introduction of error terms enhances the robustness of the model.

[0078] 2. Cohesion weight calculation equation: It realizes the quantitative evaluation of the internal cohesion of microservices; it takes into account the three dimensions of function, data and transaction; the normalization process makes the indicators of different dimensions comparable; the weight coefficient can be adjusted according to actual needs.

[0079] 3. Granularity balance coefficient calculation equation: The Gaussian kernel function effectively reflects the degree of difference; it takes into account the balance of multiple dimensions; the result range is between [0,1], which is easy to understand and use; it can guide the splitting and merging decisions of microservices.

[0080] The composite fitness function is specifically expressed as follows:

[0081] ;

[0082] In the formula, is the composite fitness function value; Evaluate the function for system response time; is the resource utilization evaluation function; Evaluate the function for maintenance cost; It is the microservice granularity balance evaluation function; is the weight coefficient and satisfies .

[0083] Among them, the system response time evaluation function is expressed as:

[0084] ;

[0085] In the formula, For Microservices and Response time between is the maximum allowed response time; For Microservices and The network delay between is the attenuation coefficient.

[0086] The resource utilization evaluation function is expressed as:

[0087] ;

[0088] In the formula, Microservices CPU usage, memory usage, and network bandwidth usage; are the maximum thresholds of the corresponding resources respectively.

[0089] The maintenance cost evaluation function is expressed as:

[0090] ;

[0091] In the formula, is the number of lines of code; is the cyclomatic complexity; is the number of dependencies; are the maximum thresholds of the corresponding indicators respectively; is the weight coefficient.

[0092] The microservice granularity balance evaluation function is expressed as: ; In the formula, For the The granularity of each microservice; is the average particle size; is the particle size standard deviation.

[0093] Parameter acquisition method description:

[0094] 1. Obtained through system performance monitoring tools;

[0095] 2. Obtained through the network delay test tool;

[0096] 3. Obtained in real time through resource monitoring tools;

[0097] 4. Obtained through code statistics tools;

[0098] 5. Calculated by static code analysis tools;

[0099] 6. Statistics are obtained through dependency analysis tools.

[0100] Design principles of each function:

[0101] 1. System response time evaluation function: adopt response time normalization processing; introduce exponential decay term of network delay; consider the calling relationship between microservices.

[0102] 2. Resource utilization evaluation function: comprehensively considers three resources: CPU, memory, and network; uses normalized processing of resource utilization; and reflects the resource efficiency of the system.

[0103] 3. Maintenance cost evaluation function: considers code size, complexity, and dependencies; uses weighted normalization processing; reflects the maintainability of the system.

[0104] 4. Microservice granularity balance evaluation function: adopts Gaussian kernel function form; considers the discrete degree of granularity distribution; the value range is between.

[0105] A second aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores program instructions, and when the program instructions are run in a computer, they are used to execute the above-mentioned enterprise production data microservice granularity optimization method.

[0106] A third aspect of the present invention provides an enterprise production data microservice granularity optimization system, which includes the above-mentioned computer-readable storage medium.

[0107] Compared with the prior art, the method, medium and system for optimizing the granularity of enterprise production data microservices provided by the present invention can effectively solve the problems existing in the existing microservice partitioning scheme. The method evaluates the coupling and cohesion of microservices from multiple dimensions, and combines the scale characteristics of the microservices themselves to construct a comprehensive microservice granularity evaluation system. The specific technical features and effects are as follows:

[0108] 1. Comprehensively quantify the coupling relationship between microservices: This method not only considers the interface call frequency and data interaction scale between microservices, but also introduces performance indicators such as response time, which can more accurately reflect the business dependency between microservices. At the same time, the weighted normalization method is used to process different indicators, effectively solving the problem of inconsistent dimensions.

[0109] 2. In-depth exploration of the cohesion within microservices: In addition to focusing on the coupling between microservices, this method also quantitatively evaluates the cohesion of functional modules within microservices from multiple dimensions, such as business function similarity, data access frequency, and transaction correlation. This provides a basis for accurately identifying the reasonable boundaries of microservices.

[0110] 3. Effectively balance the granularity of microservices: In addition to coupling and cohesion, this method also introduces indicators such as code size, number of interfaces and complexity, and constructs a granularity balance coefficient, which can comprehensively reflect the scale distribution of microservices and provide a quantifiable basis for the splitting and merging of microservices.

[0111] 4. Adopting a hybrid optimization strategy: This method adopts a combination of the gray wolf algorithm and the genetic algorithm, making full use of the advantages of the two algorithms, that is, the gray wolf algorithm determines the search direction, and the genetic algorithm realizes population evolution, and finally finds the optimal microservice partitioning scheme that meets multi-objective requirements.

[0112] 5. Improve the maintainability and elasticity of the system: By reasonably dividing microservices, you can effectively reduce the coupling between microservices and improve the maintainability of the system. You can also flexibly adjust the granularity of microservices according to business needs to achieve efficient functional iteration and elastic scaling.

[0113] In general, the enterprise production data microservice granularity optimization method proposed in the present invention, based on the existing microservice partitioning technology, deeply evaluates the characteristics of microservices from multiple dimensions, and uses advanced hybrid optimization algorithms to find the optimal partitioning scheme that meets multiple indicators such as system response time, resource utilization, maintenance cost and granularity balance, solving the technical problem that the existing technology is difficult to determine the microservice granularity. BRIEF DESCRIPTION OF THE DRAWINGS

[0114] Figure 1 A flow chart of the method provided by the present invention. DETAILED DESCRIPTION

[0115] In order to make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0116] like Figure 1 As shown, it is a flow chart of a method for optimizing the granularity of enterprise production data microservices provided by the present invention. The specific implementation method of each step in the method is described in detail below:

[0117] The specific implementation method of step S10 is to first collect the operation log data of each microservice in the enterprise production data system. Extract the interface call data between microservices from these operation log data, and count the call frequency data per unit time. At the same time, it is also necessary to collect the network traffic monitoring data in the enterprise production data system and extract the data interaction scale data between microservices. Integrate these call frequency data and data interaction scale data to form dependency data. In addition, it is also necessary to collect the business operation log in the enterprise production data system, extract the business function call sequence, and analyze its timing relationship to form business flow data. The comprehensive dependency data and business flow data can fully reflect the mutual collaboration of microservices in the enterprise production data system.

[0118] The specific implementation method of step S20 is to first group the dependency data according to the microservice identifier. For each group of dependency data, calculate the sum of microservice call frequencies, the average response time of interface calls, and the total amount of data interaction. Then establish an n-order square matrix, where n is the total number of microservices, fill the above three indicator data into the corresponding positions of the square matrix, and finally form a microservice coupling matrix. This matrix can intuitively reflect the degree of mutual dependence between microservices.

[0119] The specific implementation method of step S30 is to first group the business flow data according to the microservice identifier. For each microservice, extract the business function description text, and use the natural language processing algorithm to calculate the semantic similarity between business functions. At the same time, count the data access patterns within each microservice and analyze its transaction boundaries. Then establish an n-order square matrix, fill the semantic similarity, data access pattern and transaction boundary information into the corresponding positions of the square matrix, and finally form a microservice cohesion matrix. This matrix can reflect the degree of aggregation of the internal functional modules of the microservice.

[0120] The specific implementation method of step S40 is to first construct a coupling weight calculation equation, a cohesion weight calculation equation and a granularity balance coefficient calculation equation. Among them, the coupling weight calculation equation adopts a weighted normalization form, taking into account the three dimensions of call frequency, interface response time and data interaction; the cohesion weight calculation equation also adopts a weighted normalization form, taking into account the three dimensions of business function similarity, data access frequency and transaction correlation; the granularity balance coefficient calculation equation uses a Gaussian kernel function, which can effectively reflect the degree of difference of various indicators. In order to determine the weight coefficients in these equations, it is necessary to use a hierarchical analysis method, an expert scoring method and a multi-objective optimization method respectively. Finally, these three equations are combined to form a microservice granularity evaluation equation group.

[0121] The specific implementation method of step S50 is to first input the microservice coupling matrix into the coupling weight calculation equation to calculate the coupling weight. Similarly, input the microservice cohesion matrix into the cohesion weight calculation equation to calculate the cohesion weight. In addition, it is also necessary to collect the code scale data, interface quantity data and complexity data of the existing microservices, and input them into the granularity balance coefficient calculation equation to obtain the granularity balance coefficient. Finally, the initial microservice granularity evaluation value is calculated based on the coupling weight, cohesion weight and granularity balance coefficient. These evaluation values ​​provide basic input for subsequent optimization algorithms.

[0122] The specific implementation method of step S60 is to first initialize the population size and number of iterations of the hybrid optimization algorithm. The initial microservice granularity evaluation value calculated in the previous step is used as the input of the fitness function. Then the gray wolf algorithm is used to calculate the position update direction of each individual in the population, and the population is preliminarily updated according to the direction. Then, the crossover operation and mutation operation of the genetic algorithm are used to further optimize the updated population. By determining the search direction through the gray wolf algorithm and realizing population evolution through the genetic algorithm, the optimal division scheme of the microservice granularity can be effectively explored.

[0123] The specific implementation method of step S70 is to first construct a system response time evaluation function, a resource utilization evaluation function, a maintenance cost evaluation function and a microservice granularity balance evaluation function. Among them, the system response time evaluation function adopts response time normalization processing and introduces an exponential decay term of network delay; the resource utilization evaluation function comprehensively considers the utilization rate of three resources: CPU, memory and network; the maintenance cost evaluation function considers the code size, complexity and dependencies, and adopts weighted normalization processing; the microservice granularity balance evaluation function uses a Gaussian kernel function form to reflect the discrete degree of granularity distribution. Finally, the weighted summation method is used to combine these four evaluation functions into a composite fitness function. This composite fitness function will be used as the objective function of the subsequent hybrid optimization algorithm.

[0124] The specific implementation method of step S80 is to first initialize an iteration counter. Then calculate the composite fitness function value of each individual in the current population, and sort the population according to these function values. Select the individual with the best composite fitness function value as the current optimal solution. Next, execute the position update operation of the gray wolf algorithm and the crossover mutation operation of the genetic algorithm to iteratively optimize the population. Each round of iteration includes two steps: gray wolf position update and genetic operator operation. This iterative process is repeated until the termination condition is met. The gray wolf algorithm determines the search direction, and the genetic algorithm realizes population evolution. The two work together to effectively explore the optimal division scheme of microservice granularity.

[0125] The specific implementation method of step S90 is to first obtain the optimal individual obtained by the final iteration, and generate a microservice partitioning scheme based on the individual. Then verify whether the composite fitness function value of this microservice partitioning scheme meets the optimization target. If the optimization target is met, the scheme is output as the final microservice partitioning scheme. If the optimization target is not met, return to step S80 to continue optimization. This process ensures that the final scheme can meet the requirements of multiple indicators such as system response time, resource utilization, maintenance cost and granularity balance.

[0126] A second aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores program instructions, and when the program instructions are run in a computer, they are used to execute the above-mentioned enterprise production data microservice granularity optimization method.

[0127] A third aspect of the present invention provides an enterprise production data microservice granularity optimization system, which includes the above-mentioned computer-readable storage medium.

[0128] Specifically, the principles of the present invention are: 1. Quantification of coupling between microservices: First, a microservice coupling matrix is ​​constructed from three dimensions: interface call frequency, response time, and data interaction scale between microservices, which is used to quantitatively reflect the degree of dependence between microservices. Among them, the interface call frequency represents the intensity of business collaboration between microservices, the response time reflects the dependency of system performance, and the data interaction scale reflects the data coupling between microservices. After normalizing these three indicators, a comprehensive coupling evaluation matrix is ​​formed, which provides a basis for subsequent granularity optimization.

[0129] 2. Quantification of microservice cohesion: In addition to focusing on the coupling between microservices, the present invention also deeply explores the functional characteristics of microservices, and constructs a microservice cohesion matrix from three dimensions: business function similarity, data access frequency, and transaction correlation, which is used to evaluate the closeness of functional modules within microservices. Among them, business function similarity reflects the functional aggregation of modules within microservices, data access frequency reflects the data coupling between internal functions, and transaction correlation indicates the process integrity of internal functions of microservices. After normalization, a microservice cohesion evaluation matrix is ​​formed, which provides another dimension of input for subsequent granularity optimization.

[0130] 3. Granularity balance evaluation: In addition to coupling and cohesion, the present invention also introduces three indicators, namely, the number of lines of code, the number of interfaces, and complexity, based on the scale characteristics of microservices, and constructs a granularity balance coefficient to evaluate the balance of microservice granularity. Here, the Gaussian kernel function is used. The larger the scale difference of each microservice, the smaller the granularity balance coefficient, indicating that the granularity distribution of the system is uneven. This provides a quantifiable evaluation basis for the splitting and merging of microservices.

[0131] 4. Comprehensive optimization solution: Based on the above three evaluation dimensions, the present invention constructs a complete set of microservice granularity evaluation equations, including coupling weight calculation, cohesion weight calculation and granularity balance coefficient calculation, etc. These equations fully consider various influencing factors, can fully reflect the characteristics of microservices, and provide basic input for subsequent optimization algorithms.

[0132] In order to explore the optimal microservice partitioning scheme that meets multi-objective requirements, the present invention adopts a hybrid optimization strategy that combines the gray wolf algorithm and the genetic algorithm. Among them, the gray wolf algorithm is good at determining the search direction, while the genetic algorithm is good at realizing population evolution. The two complement each other and can effectively explore the optimal partitioning scheme that meets indicators such as system response time, resource utilization, maintenance cost and granularity balance. Specifically, the gray wolf algorithm is first used to update the position of the population, and then the crossover and mutation operations of the genetic algorithm are used for further optimization. Through continuous iteration, the optimal microservice partitioning scheme that meets multi-objective requirements is finally obtained.

[0133] A specific embodiment 1 of the present invention is provided below. The specific implementation of each step in this embodiment 1 is described in detail as follows: The specific implementation of step S10 is as follows:

[0134] First, collect the operation log data of each microservice in the enterprise production data system. These operation log data record the interface calls between microservices and can be used to extract microservice dependency data. Specifically, extract the interface call data between microservices from the operation log data, expressed as:

[0135] ;

[0136] in, Indicates The first microservice and the The interface call frequency between microservices, n is the total number of microservices.

[0137] Next, count the timestamp information in these interface call data and calculate the call frequency per unit time, expressed as: ;in, Indicates The first microservice and the The call frequency between microservices, Indicates the unit time For example, 1 second The number of calls within a period, T represents the statistical time window.

[0138] At the same time, the network traffic monitoring data in the enterprise production data system is collected, and the data interaction scale data between microservices is extracted, which is expressed as: ;in, Indicates Microservices in a time unit With Microservices The amount of data interaction between time units to get the total data interaction scale .

[0139] Finally, the frequency data is called Interact with data and scale data Integrate to form dependency data for subsequent microservice coupling analysis.

[0140] On the other hand, we collect business operation logs from the enterprise production data system, extract business function call sequences, analyze their time series relationships, and form business flow data, which can be expressed as: ;in, Indicates Microservice internal The cohesion of each functional module reflects the correlation between the internal functions of the microservice.

[0141] In summary, step S10 obtains the dependency data and business flow data of microservices in the enterprise production data system, providing basic input for subsequent microservice coupling and cohesion analysis.

[0142] The specific implementation of step S20 is as follows:

[0143] First, the dependency data Group by microservice ID and calculate the sum of microservice call frequencies in each group of data, expressed as: ;in, Indicates The total call frequency of each microservice.

[0144] At the same time, the average response time of the interface calls in each set of dependency data is calculated, expressed as: ;in, Indicates The average interface response time of each microservice.

[0145] Next, the total amount of data interaction in each set of dependency data is calculated, expressed as: ;in, Indicates The total data interaction volume of each microservice.

[0146] Then, create a The coupling matrix C of the above three indicators is filled into the corresponding positions of the matrix to form: ;This matrix reflects the degree of coupling between microservices and provides basic data for subsequent coupling quantification analysis.

[0147] The specific implementation of step S30 is as follows:

[0148] First, business flow data The microservices are grouped according to their IDs, the business function description text in each microservice is extracted, and the semantic similarity between business functions is calculated using the natural language processing algorithm, which is expressed as: ;in, and Respectively represent Microservices and The business function description of a microservice, (, ) represents the calculation of the semantic similarity between two texts.

[0149] At the same time, the data access pattern within each microservice is counted, expressed as: ;in, Indicates Microservice internal The data access frequency of each functional module, Indicates the number of data accesses of this function module. Representing microservices The total number of data accesses of all internal functional modules.

[0150] Next, we analyze the transaction boundaries within each microservice, expressed as:

[0151] ;

[0152] Specifically, if the The first microservice A functional module is in the same transaction boundary as other functional modules. ,otherwise, .

[0153] Then, create a The cohesion matrix H is filled with the above three indicators into the corresponding positions of the matrix to form: ;This matrix reflects the degree of cohesion of the internal functional modules of the microservices and provides basic data for subsequent quantitative analysis of cohesion.

[0154] The specific implementation of step S40 is as follows:

[0155] First, the coupling weight calculation equation is constructed, which is expressed as:

[0156] ;

[0157] in, is the coupling weight; is the weight coefficient of the three indicators, satisfying is an error term, which is used to deal with uncertainties in practical applications.

[0158] Next, construct the cohesion weight calculation equation, which is expressed as:

[0159] ;

[0160] in, is the cohesion weight; is the weight coefficient of the three indicators, satisfying is the error term.

[0161] Finally, the particle size balance coefficient calculation equation is constructed, which is expressed as:

[0162] ;

[0163] in, is the particle size balance coefficient; They are the maximum and minimum number of lines of code respectively; They are the maximum and minimum values ​​of the number of interfaces respectively; are the maximum and minimum values ​​of complexity respectively; are the standard deviations of the corresponding indicators respectively; is the weight coefficient of the three indicators, satisfying = 1; is the error term.

[0164] Combining the above three equations, a group of microservice granularity evaluation equations is formed, which provides a basis for subsequent optimization algorithms.

[0165] The specific implementation of step S50 is as follows:

[0166] First, the coupling matrix Input the coupling weight calculation equation to get the coupling weight :

[0167] ;

[0168] Next, the cohesion matrix Enter the cohesion weight calculation equation to get the cohesion weight :

[0169] ;

[0170] At the same time, collect the number of lines of code of existing microservices 、Number of interfaces and complexity Data, input the particle size balance coefficient calculation equation, and obtain the particle size balance coefficient :

[0171] ;

[0172] Finally, according to the coupling weight , cohesion weight and particle size balance coefficient Calculate the initial microservice granularity assessment value as input for subsequent optimization algorithms:

[0173] ;

[0174] Among them, the function Taking the above three factors into consideration, the initial microservice granularity assessment value E is output.

[0175] The specific implementation of step S60 is as follows:

[0176] First, initialize the population size of the hybrid optimization algorithm and the number of iterations T.

[0177] Next, the initial microservice granularity evaluation value calculated in the previous step is As the input of the fitness function, it is expressed as:

[0178] ;

[0179] in, Represents an individual in a population.

[0180] Then, the gray wolf algorithm is used to calculate the position update direction of each individual in the population, which is expressed as:

[0181] ;

[0182] in,

[0183] Positions for the next generation of individuals;

[0184] is the position of the current optimal individual;

[0185] and is the coefficient vector of the Grey Wolf algorithm;

[0186] is the position update factor, which decreases linearly with the number of iterations.

[0187] According to the above position update direction, the population is preliminarily updated.

[0188] Finally, the crossover and mutation operations of the genetic algorithm are used to further optimize the updated population, which can be expressed as:

[0189] ;

[0190] in, Indicates a crossover operation; Represents a mutation operation.

[0191] The search direction is determined by the grey wolf algorithm, and the population evolution is realized by the genetic algorithm. The collaboration of the two can effectively explore the optimal division scheme of microservice granularity.

[0192] The specific implementation of step S70 is as follows:

[0193] First, construct the system response time evaluation function, expressed as:

[0194] ;

[0195] in, Evaluate the function for system response time; For Microservices and Response time between is the maximum allowed response time; For Microservices and The network delay between is the attenuation coefficient.

[0196] Next, construct a resource utilization evaluation function, expressed as:

[0197] ;

[0198] in, is the resource utilization evaluation function; Microservices CPU usage, memory usage, and network bandwidth usage; are the maximum thresholds of the corresponding resources respectively.

[0199] Then, the maintenance cost evaluation function is constructed as follows:

[0200] ;

[0201] in, Evaluate the function for maintenance cost; For Microservices Number of lines of code; For Microservices The cyclomatic complexity of For Microservices The number of dependencies; are the maximum thresholds of the corresponding indicators respectively; is the weight coefficient of the three indicators.

[0202] Finally, the microservice granularity balance evaluation function is constructed, which is expressed as:

[0203] ;

[0204] in, It is the microservice granularity balance evaluation function; For the The granularity of each microservice; is the average particle size; is the standard deviation of particle size.

[0205] The above four evaluation functions are combined into a composite fitness function, expressed as:

[0206] ;

[0207] in,

[0208] is the composite fitness function; are the weight coefficients of the four evaluation functions, satisfying = 1.

[0209] This composite fitness function will serve as the objective function of the subsequent hybrid optimization algorithm to ensure that the final solution can meet the requirements of multiple indicators such as system response time, resource utilization, maintenance cost, and granularity balance.

[0210] The specific implementation of step S80 is as follows:

[0211] First, initialize an iteration counter .

[0212] Then, the composite fitness function value of each individual in the current population is calculated, expressed as:

[0213] ;

[0214] The calculation method of each evaluation function is the same as the previous step.

[0215] Next, the population is sorted according to the composite fitness function value, and the individual with the best value is selected as the current optimal solution, which is expressed as .

[0216] Then, the position update operation of the gray wolf algorithm is executed to update the positions of other individuals in the population, which is expressed as:

[0217] ;

[0218] in,

[0219] Positions for the next generation of individuals;

[0220] is the position of the current optimal individual;

[0221] and is the coefficient vector of the Grey Wolf algorithm;

[0222] is the position update factor, which decreases linearly with the number of iterations.

[0223] Next, the crossover and mutation operations of the genetic algorithm are performed to further optimize the updated population, which can be expressed as:

[0224] ;

[0225] in, Indicates a crossover operation; Represents a mutation operation.

[0226] Finally, update the iteration counter , determine whether the termination condition is met, if not, return to step S80 to continue iterating.

[0227] In this step, the gray wolf algorithm determines the search direction and the genetic algorithm realizes population evolution. The two work together to effectively explore the optimal division scheme of microservice granularity.

[0228] The specific implementation of step S90 is as follows:

[0229] First, obtain the optimal individual obtained in the final iteration .

[0230] Then, according to the optimal individual Generate a microservice partitioning scheme, expressed as:

[0231] ;

[0232] Among them, the function According to the best individual Determine the division of microservices .

[0233] Next, verify the microservice partitioning scheme Whether the composite fitness function value meets the optimization objective is expressed as:

[0234] ;

[0235] in,

[0236] is the composite fitness function value;

[0237] is the preset optimization target value.

[0238] If the optimization goal is met, the microservice partitioning scheme is output As the final solution. Otherwise, return to step S80 to continue optimization.

[0239] Through this iterative optimization process, we can ensure that the final solution can meet the requirements of multiple indicators such as system response time, resource utilization, maintenance cost and granularity balance.

[0240] In general, this method fully considers the coupling relationship between microservices and the cohesion of internal functions, and combines the scale characteristics of microservices to build a complete evaluation system. On this basis, a hybrid optimization strategy of the gray wolf algorithm and the genetic algorithm is adopted to explore the optimal microservice partitioning scheme that meets multi-objective requirements. This method not only considers technical factors, but also takes into account key factors in practical applications such as business needs and operation and maintenance costs, and has strong pertinence and practicality.

[0241] In order to better understand and implement the present invention, the following provides Example 2 of a specific application scenario of the present invention: A manufacturing enterprise X company is promoting information construction and migrating its production management system from a traditional monolithic architecture to a distributed architecture based on microservices. The production management system covers multiple functional modules such as production planning management, material demand management, production process control, quality management, equipment management, warehouse management, and production statistics analysis. In the process of transforming the microservice architecture, how to reasonably divide the microservice boundaries and ensure the loose coupling between microservices and the high internal cohesion is a key issue that needs to be solved urgently.

[0242] X Company decided to use the enterprise production data microservice granularity optimization method proposed in this invention to guide the microservice division of its production management system. This method quantitatively evaluates the characteristics of microservices from multiple dimensions, and uses a hybrid optimization algorithm to explore the optimal microservice division scheme that meets the requirements of system performance, resource utilization, and maintenance cost. The following is a specific example of X Company implementing the method of this invention.

[0243] First, the IT team of Company X investigated and sorted out the various functional modules of the production management system and initially identified eight microservice units, which are responsible for production planning management, material demand management, production process control, quality management, equipment management, warehouse management, production statistics analysis and system coordination. For these eight microservices, the IT team collected the following data:

[0244] 1. Interface call data between microservices. By analyzing the operation logs of the production management system, the interface call information between microservices, such as call frequency, average response time, etc., was extracted. These data reflect the business collaboration intensity and performance dependency between microservices.

[0245] 2. Network traffic data between microservices. By deploying network monitoring equipment, the data transmission between microservices is collected to characterize the data coupling degree between microservices.

[0246] 3. Description of business functions within microservices. The business functions undertaken by each microservice are extracted from the system design document, and semantic similarity analysis is performed to quantify the degree of aggregation of functional modules within the microservices.

[0247] 4. Data access within microservices. By analyzing the database operation logs, the data access frequency of each microservice internal functional module is counted, reflecting the data coupling between internal functions.

[0248] 5. Transaction correlation within microservices. By combing the distributed transaction logs, the transaction dependencies between the internal functional modules of each microservice are analyzed to represent the process integrity of the internal functions.

[0249] 6. Code size, number of interfaces and complexity data of each microservice. Through code static analysis and interface document parsing, the number of lines, number of interfaces and cyclomatic complexity indicators of each microservice were obtained, providing a basis for evaluating the balance of microservice granularity.

[0250] With the above data as input, the IT team of Company X began to execute the steps of the method of the present invention:

[0251] Step S10: Obtain dependency data and business flow data of all microservices in the enterprise production data system.

[0252] By analyzing the operation logs and network traffic monitoring data, the IT team extracted the interface call frequency, average response time, and data interaction volume between the eight microservices, forming the dependency data shown in Table 1:

[0253] Table 1 Microservice dependency data

[0254]

[0255] In the table, the value on the left of the “ / ” symbol indicates the call frequency between microservices, the value in the middle indicates the average response time (unit: seconds), and the value on the right indicates the data interaction scale (unit: MB). The blank cells on the diagonal indicate the dependencies between microservices themselves.

[0256] At the same time, by analyzing the business operation logs, the IT team extracted the call sequences of each microservice functional module and analyzed the timing relationship between them, forming the business flow data shown in Table 2:

[0257] Table 2 Microservice business flow data

[0258]

[0259] The values ​​in the table indicate the degree of correlation between business functions of microservices, ranging from [0,1]. The larger the value, the stronger the correlation.

[0260] Through the above steps, the IT team of Company X obtained the dependency data and business flow data of microservices in the enterprise production data system, laying the foundation for the subsequent microservice granularity optimization.

[0261] Step S20: construct a microservice coupling matrix based on the dependency data.

[0262] Based on the dependency data in Table 1, the IT team constructed the microservice coupling matrix shown below: :

[0263] ;

[0264] in, Indicates The first microservice and the The coupling degree between microservices is comprehensively reflected by three indicators: call frequency, average response time, and data interaction scale. The empty cells on the diagonal represent the coupling relationship between microservices themselves.

[0265] This coupling matrix provides basic data for subsequent coupling evaluation and optimization.

[0266] Step S30: construct a microservice cohesion matrix based on the business flow data.

[0267] Based on the business flow data in Table 2, the IT team constructed the following microservice cohesion matrix: :

[0268] ;

[0269] in, Indicates Microservice internal The cohesion of each functional module is comprehensively reflected by three indicators: business function similarity, data access frequency, and transaction correlation. The values ​​on the diagonal represent the cohesion of each functional module within the microservice.

[0270] This cohesion matrix provides basic data for subsequent cohesion evaluation and optimization.

[0271] Step S40: Establish a microservice granularity evaluation equation group according to the coupling matrix and the cohesion matrix.

[0272] Based on the above coupling matrix and the cohesion matrix ,The IT team constructed the following microservice granularity evaluation equations:

[0273] 1. Coupling weight calculation equation:

[0274] ;

[0275] in, is the coupling weight, For the The sum of the call frequencies of the microservices, For the The average response time of each microservice, For the The total data interaction scale of microservices, is the error term. The weight coefficient of each index is determined by the hierarchical analysis method.

[0276] 2. Cohesion weight calculation equation:

[0277] ;

[0278] in, is the cohesion weight, For the The average semantic similarity of the internal functional modules of the microservices, For the The average data access frequency of the internal functional modules of each microservice, For the The average transaction correlation of the internal functional modules of the microservices, is the error term. The weight coefficient of each indicator is determined by the expert scoring method.

[0279] 3. Particle size balance coefficient calculation equation:

[0280] ;

[0281] in, is the particle size balance coefficient, are the maximum and minimum number of lines of code, respectively. are the maximum and minimum number of interfaces, are the maximum and minimum values ​​of complexity respectively, are the standard deviations of the corresponding indicators, is the error term. The weight coefficient of each index is determined by multi-objective optimization method.

[0282] Combining the above three equations, the IT team formed a set of microservice granularity evaluation equations, which provided basic input for subsequent optimization algorithms.

[0283] Step S50: Perform a preliminary evaluation of existing microservices using the microservice granularity evaluation equation group.

[0284] First, the IT team will use the coupling matrix Substitute into the coupling weight calculation equation to get the coupling weight of each microservice :

[0285] ;

[0286] Next, the cohesion matrix Substitute into the cohesion weight calculation equation to get the cohesion weight of each microservice :

[0287] ;

[0288] Then, the IT team collected the number of lines of code, number of interfaces, and complexity data of each microservice, and substituted them into the granularity balance coefficient calculation equation to obtain the granularity balance coefficient :

[0289] ;

[0290] Finally, according to the above coupling weight , cohesion weight and particle size balance coefficient , the IT team calculated the initial microservice granularity estimate :

[0291] ;

[0292] This initial evaluation value provides the basic input for the subsequent optimization algorithm.

[0293] Step S60: Input the initial microservice granularity evaluation value into the hybrid optimization algorithm for optimization.

[0294] Based on the initial microservice granularity evaluation value calculated in the previous step , the IT team of Company X uses a hybrid optimization strategy that combines the gray wolf algorithm and the genetic algorithm to iteratively optimize the microservice partitioning scheme. The specific steps are as follows:

[0295] 1. Initialize the population size of the hybrid optimization algorithm to 100 and the number of iterations to 200.

[0296] 2. Evaluate the initial microservice granularity As the input of the fitness function, , in Represents an individual in a population.

[0297] 3. Use the gray wolf algorithm to calculate the position update direction of each individual in the population:

[0298] ;

[0299] in, For the location of the next generation of individuals, is the current optimal individual position, and is the coefficient vector of the Grey Wolf Algorithm, is the position update factor, which decreases linearly with the number of iterations.

[0300] 4. Perform a preliminary update of the population based on the above position update direction.

[0301] 5. Use the crossover and mutation operations of the genetic algorithm to further optimize the updated population:

[0302] ;

[0303] in, represents the crossover operation, Represents a mutation operation.

[0304] 6. Repeat steps 3-5 until the iteration termination condition is reached.

[0305] Through the above hybrid optimization strategy, the IT team of Company X finally obtained the optimal microservice partitioning solution that meets multiple indicators such as system response time, resource utilization, maintenance cost, and granularity balance.

[0306] Step S70: Construct a composite fitness function based on the hybrid optimization algorithm.

[0307] In order to ensure that the final microservice partitioning solution can meet the requirements of multiple indicators such as system performance, resource utilization, and maintenance cost, the IT team of Company X built the following composite fitness function:

[0308] ;

[0309] in:

[0310] 1. System response time evaluation function:

[0311] ;

[0312] in, For Microservices With Microservices The response time between is the maximum allowed response time, For Microservices With Microservices The network delay between

[0313] 2. Resource utilization evaluation function:

[0314] ;

[0315] in, Microservices CPU usage, memory usage, and network bandwidth usage, are the maximum thresholds of the corresponding resources respectively.

[0316] 3. Maintenance cost evaluation function:

[0317] ;

[0318] in, For Microservices Number of lines of code, For Microservices The cyclomatic complexity of For Microservices The number of dependencies, are the maximum thresholds of the corresponding indicators respectively.

[0319] 4. Microservice granularity balance evaluation function:

[0320] ;

[0321] in, For the The granularity of each microservice, is the average particle size, is the standard deviation of particle size.

[0322] The above four evaluation functions are combined into a composite fitness function by weighted summation. , where the weight coefficient of each index is determined by a multi-objective optimization method. The composite fitness function will be used as the objective function of the subsequent hybrid optimization algorithm.

[0323] Step S80: Use the hybrid optimization algorithm to iteratively optimize the microservice partitioning scheme.

[0324] Composite fitness function based on the previous step , X company’s IT team adopted a hybrid optimization strategy combining the gray wolf algorithm and the genetic algorithm to further optimize the microservice partitioning scheme. The specific steps are as follows:

[0325] 1. Initialize the iteration counter .

[0326] 2. Calculate the composite fitness function value of each individual in the current population .

[0327] 3. According to The population is sorted by value, and the individual with the best composite fitness function value is selected as the current optimal solution .

[0328] 4. Execute the position update operation of the gray wolf algorithm:

[0329] ;

[0330] in, For the location of the next generation of individuals, is the position update factor, which decreases linearly with the number of iterations.

[0331] 5. Perform crossover and mutation operations of genetic algorithm:

[0332] ;

[0333] 6. Update iteration counter .

[0334] 7. Determine whether the termination condition is met (such as the number of iterations reaches 200 or the composite fitness function value is less than 0.9). If not, return to step 2 to continue iterative optimization.

[0335] Through the above iterative optimization process, the IT team of Company X finally obtained the optimal microservice partitioning solution that meets multiple indicators such as system response time, resource utilization, maintenance cost, and granularity balance.

[0336] Step S90: Output the final microservice partitioning plan.

[0337] After 200 iterations of the hybrid optimization algorithm, the IT team of Company X obtained the final microservice partitioning solution, as follows:

[0338] 1. Production planning management microservice: includes functions such as production planning, material requirement planning, and production progress tracking.

[0339] 2. Material requirement management microservice: includes functions such as material information management, procurement plan preparation, inventory monitoring, etc.

[0340] 3. Production process control microservices: includes functions such as production scheduling optimization, process parameter adjustment, and production progress monitoring.

[0341] 4. Quality management microservices: includes functions such as quality inspection, defective product processing, and quality analysis.

[0342] 5. Equipment management microservices: includes equipment maintenance planning, fault diagnosis and repair, equipment monitoring and other functions.

[0343] 6. Warehouse management microservices: includes functions such as incoming warehouse acceptance, warehouse scheduling, and outgoing warehouse management.

[0344] 7. Production statistics analysis microservice: contains production data.

[0345] It should be noted that the explanations of the variables involved in the present invention are shown in Table 3 below:

[0346] Table 3 Variable explanation table

[0347]

[0348] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. A method for optimizing the granularity of enterprise production data microservices, characterized in that: The following steps are involved: S10. Obtain dependency data and business flow data of all microservices in the enterprise production data system; S20, constructing a microservice coupling matrix based on the dependency data, wherein the coupling matrix includes call frequency, data interaction volume, and number of interfaces between microservices; S30, constructing a microservice cohesion matrix based on the business flow data, wherein the cohesion matrix includes business function similarity, data consistency requirements, and transaction integrity requirements; S40, establishing a microservice granularity evaluation equation group according to the coupling degree matrix and the cohesion degree matrix, wherein the microservice granularity evaluation equation group includes a coupling degree weight calculation equation, a cohesion degree weight calculation equation, and a granularity balance coefficient calculation equation; S50, using the microservice granularity assessment equation group to perform a preliminary assessment on the existing microservices to obtain an initial microservice granularity assessment value; S60, inputting the initial microservice granularity evaluation value into a hybrid optimization algorithm, wherein the hybrid optimization algorithm determines a search direction through a gray wolf algorithm and performs population evolution through a genetic algorithm; S70, constructing a composite fitness function based on the hybrid optimization algorithm, wherein the composite fitness function is composed of system response time, resource utilization, maintenance cost, and microservice granularity balance; S80, using the hybrid optimization algorithm to iteratively optimize the microservice partitioning scheme, each round of iteration includes gray wolf position update and genetic operator operation; S90, when the number of iterations reaches a preset value and the composite fitness function value meets the optimization target, output the final microservice partitioning scheme, otherwise return to step S80 to continue optimization; The coupling degree matrix is ​​specifically expressed as follows: ; In the formula, Indicates The first microservice and the The degree of coupling between microservices; is the total number of microservices; The cohesion matrix is ​​specifically expressed as follows: ; In the formula, Indicates Microservice internal The cohesion of each functional module; is the total number of microservices; The coupling degree weight calculation equation is specifically expressed as follows: ; In the formula, is the coupling weight; For Microservices and The frequency of calls between For Microservices and The average response time between For Microservices and The amount of data interaction between is the weight coefficient and satisfies ; is the error term; The cohesion weight calculation equation is specifically expressed as follows: ; In the formula, is the cohesion weight; is the functional similarity; is the data access frequency; is the transaction relevance; is the weight coefficient and satisfies ; is the error term; The particle size balance coefficient calculation equation is specifically expressed as follows: ; In the formula, is the particle size balance coefficient; They are the maximum and minimum number of lines of code respectively; They are the maximum and minimum number of interfaces respectively; are the maximum and minimum values ​​of complexity respectively; are the standard deviations of the corresponding indicators respectively; is the weight coefficient and satisfies ; is the error term; The composite fitness function is specifically expressed as follows: ; In the formula, is the composite fitness function value; Evaluate the function for system response time; is the resource utilization evaluation function; Evaluate the function for maintenance cost; It is the microservice granularity balance evaluation function; is the weight coefficient and satisfies ; Among them, the system response time evaluation function is expressed as: ; In the formula, For Microservices and Response time between is the maximum allowed response time; For Microservices and The network delay between is the attenuation coefficient; The resource utilization evaluation function is expressed as: ; In the formula, Microservices CPU usage, memory usage, and network bandwidth usage; are the maximum thresholds of the corresponding resources respectively; The maintenance cost evaluation function is expressed as: ; In the formula, For Microservices Number of lines of code; is the cyclomatic complexity; is the dependent quantity; are the maximum thresholds of the corresponding indicators respectively; is the weight coefficient; The microservice granularity balance evaluation function is expressed as: ; In the formula, For the The granularity of each microservice; is the average particle size; is the particle size standard deviation.

2. According to claim 1, a method for optimizing the granularity of enterprise production data microservices is characterized in that: The step S10 specifically includes: Step 101: Collect the operation log data of each microservice in the enterprise production data system; Step 102: extracting interface call data between microservices from the operation log data; Step 103: Count the call timestamp information in the interface call data and calculate the call frequency data per unit time; Step 104: Collect network traffic monitoring data from the enterprise production data system and extract data on the scale of data interaction between microservices; Step 105: Integrate the call frequency data and the data interaction scale data to form dependency relationship data; Step 106: Collect the business operation logs in the enterprise production data system and extract the business function call sequence; Step 107: Analyze the timing relationship in the business function call sequence to form business flow data.

3. The method for optimizing the granularity of enterprise production data microservices according to claim 2, characterized in that: The step S20 specifically includes: Step 201: group the dependency data according to microservice identifiers; Step 202: Calculate the sum of microservice call frequencies in each group of dependency data; Step 203: Count the average response time of the interface calls in each group of dependency data; Step 204: Calculate the total amount of data interaction in each group of dependency data; Step 205: Establish an n-order square matrix, where n is the total number of microservices; Step 206: Fill the sum of the microservice call frequencies, the average response time of the interface calls, and the total amount of data interactions into corresponding positions of the n-order square matrix; Step 207: Form a microservice coupling matrix.

4. The method for optimizing the granularity of enterprise production data microservices according to claim 3, characterized in that: The step S30 specifically includes: Step 301: group the business flow data according to the microservice identifier; Step 302: extract the business function description text in each microservice; Step 303: Calculate the semantic similarity between business functions using a natural language processing algorithm; Step 304: Count the data access patterns within each microservice; Step 305: Analyze the transaction boundaries within each microservice; Step 306: Establish an n-order square matrix, where n is the total number of microservices; Step 307: Fill the semantic similarity, the data access mode and the transaction boundary into corresponding positions of the n-order square matrix; Step 308: Form a microservice cohesion matrix.

5. The method for optimizing the granularity of enterprise production data microservices according to claim 4, characterized in that: The step S40 specifically includes: Step 401, constructing a coupling degree weight calculation equation; Step 402: construct a cohesion weight calculation equation; Step 403, constructing a particle size balance coefficient calculation equation; Step 404, using the analytic hierarchy process to determine the weight coefficient in the coupling degree weight calculation equation; Step 405: Determine the weight coefficient in the cohesion weight calculation equation using the expert scoring method; Step 406, using a multi-objective optimization method to determine the weight coefficient in the particle size balance coefficient calculation equation; Step 407: Combine the coupling degree weight calculation equation, the cohesion degree weight calculation equation, and the granularity balance coefficient calculation equation to form a microservice granularity evaluation equation group.

6. The method for optimizing the granularity of enterprise production data microservices according to claim 5, characterized in that: The step S50 specifically includes: Step 501: Input the microservice coupling degree matrix into a coupling degree weight calculation equation; Step 502: Calculate and obtain coupling degree weight; Step 503: Input the microservice cohesion matrix into a cohesion weight calculation equation; Step 504, calculating and obtaining the cohesion weight; Step 505: Collect code size data, interface quantity data, and complexity data of existing microservices; Step 506: input the code size data, the interface quantity data and the complexity data into a granularity balance coefficient calculation equation; Step 507, calculating and obtaining the particle size balance coefficient; Step 508: Calculate an initial microservice granularity assessment value according to the coupling weight, the cohesion weight, and the granularity balance coefficient.

7. The method for optimizing the granularity of enterprise production data microservices according to claim 6, characterized in that: The step S60 specifically includes: Step 601, initializing the population size and number of iterations of the hybrid optimization algorithm; Step 602: Using the initial microservice granularity evaluation value as an input of a fitness function; Step 603: Use the gray wolf algorithm to calculate the position update direction of each individual in the population; Step 604: preliminarily update the population according to the position update direction; Step 605: Optimize the updated population using a crossover operation of a genetic algorithm; Step 606: Utilize the mutation operation of the genetic algorithm to further optimize the population.

8. The method for optimizing the granularity of enterprise production data microservices according to claim 7, characterized in that: The step S70 specifically includes: Step 701: construct a system response time evaluation function; Step 702: construct a resource utilization evaluation function; Step 703: construct a maintenance cost evaluation function; Step 704: construct a microservice granularity balance evaluation function; Step 705: Use a weighted sum method to combine the system response time evaluation function, the resource utilization evaluation function, the maintenance cost evaluation function, and the microservice granularity balance evaluation function to form a composite fitness function; Wherein, the step S80 specifically includes: Step 801, initializing an iteration counter; Step 802: Calculate the composite fitness function value of each individual in the current population; Step 803: sorting the population according to the composite fitness function value; Step 804: Select the individual with the best composite fitness function value as the current optimal solution; Step 805: Execute the position update operation of the Grey Wolf Algorithm; Step 806: Execute the crossover and mutation operation of the genetic algorithm; Step 807: Update the iteration counter; Step 808: determine whether the termination condition is met. If not, return to step 802 to continue iterating. Wherein, the step S90 specifically includes: Step 901, obtaining the optimal individual obtained by the final iteration; Step 902: Generate a microservice partitioning scheme according to the optimal individual; Step 903: Verify whether the composite fitness function value of the microservice partitioning scheme meets the optimization goal; Step 904: if the optimization goal is met, output the microservice partitioning solution as the final solution; Step 905: If the optimization target is not met, return to step S80 to continue optimization.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program instructions, and when the program instructions are executed in a computer, they are used to execute the enterprise production data microservice granularity optimization method according to any one of claims 1 to 8.

10. An enterprise production data microservice granularity optimization system, characterized in that: A computer-readable storage medium comprising the computer-readable storage medium of claim 9.

Citation Information

Patent Citations

  • Micro-service granularity identification method based on user stories

    CN114780060A

  • Maintainability-oriented micro-service granularity evaluation method and tool

    CN115826979A