A microservice topology modeling method based on local graph edge partitioning
Through the microservice topology modeling method based on local graph edge division, the cascade reaction problem caused by remote call problems in microservice architecture construction is solved, and more accurate microservice topology modeling and higher system stability are achieved.
Patent Information
- Application Number
- CN202211418686.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-14
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2042-11-14
AI Technical Summary
It is difficult for the existing technology to effectively build a microservice architecture, resulting in remote calls between microservices that may trigger cascade reactions and cause system crashes.
The microservice topology modeling method based on local graph edge division is adopted. By constructing the call chain data between microservices, the graph theory algorithm is used to divide the graph edge into two stages, and the microservice dependency graph is realized, and the call topology diagram between microservices is constructed.
It improves the accuracy of microservice topology modeling, reduces the probability of call errors between microservices, and enhances the stability and reliability of the system.
Smart Images

Figure CN115941497B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of microservice technology, and in particular to a microservice topology modeling method based on local graph edge partitioning. Background Art
[0002] Traditional Java Web uses a monolithic architecture for development, deployment, and operation. The so-called monolithic architecture is to package all business modules of the application in one file for deployment. However, with the development of the Internet, the surge in the number of users, and the rapid expansion of business, the shortcomings of the traditional monolithic application approach have gradually emerged, bringing great difficulties to development, deployment, and operation, and the workload will become increasingly heavy and difficult.
[0003] Because in the monolithic architecture, all business modules are too highly coupled. Microservice architecture came into being. Microservice is an architectural pattern that splits a monolithic application into several small services to work together to complete system functions.
[0004] The shortcoming of the existing technology is how to reasonably construct and model the architecture of microservices. Each service completes collaborative tasks through remote calls. If there is a problem with the remote call for some reason, resulting in the unavailability of the microservice, it is likely to cause a cascade reaction and cause the entire system to crash. Summary of the invention
[0005] The purpose of the present invention is to overcome the shortcomings of the prior art. To achieve the above purpose, a microservice topology modeling method based on local graph edge partitioning is adopted, so as to realize the storage of massive entities, relationships and attributes, as well as multi-granularity visualization of ultra-large-scale knowledge graphs, so as to achieve the purpose of reasonable and smooth use of ultra-large-scale intelligent operation and maintenance knowledge graphs.
[0006] A microservice topology modeling method based on local graph edge partitioning, the specific steps include:
[0007] Step S1: construct call chain data through the call relationship between microservices, where the microservices are used as nodes and the collection of calls between microservices are used as edges;
[0008] Step S2: For the constructed call chain data, the graph edges are divided into two stages according to the modularity of the subgraph. In the first stage, the graph partitioning strategy is adopted to select the nearest and local maximum degree vertices; in the second stage, according to the partitioning strategy, the vertices that make the local partitions the tightest are selected to realize the partitioning of the microservice dependency graph;
[0009] Step S3: construct a call topology diagram between different blocks through a graph theory algorithm to complete the topology modeling of the mutual call chain between microservices.
[0010] As a further solution of the present invention: the specific steps of step S1 include:
[0011] When analyzing the calling relationship between services, we ignore the calling direction and focus on the closeness between services. We use the idea of graph theory to map the calling network formed by the calling chain into an undirected graph G(V, E).
[0012] Where V represents the set of points in the undirected graph (v1, v2, ..., v n ), that is, the set of microservices in the calling network, n represents the number of microservices; E represents the set of edges in the undirected graph (e1, e2, ..., e m ), which is the set of calls between microservices in the calling network, and m represents the number of calling relationships between microservices;
[0013] Among them, each point in the undirected graph can store the indicators of its business performance, application system, network, container, resources and host, and each edge can store its weight information, which includes the number of calls and average delay.
[0014] As a further solution of the present invention: the specific steps of step S2 include:
[0015] Step S21, based on the structure of the measured graph partition, modularity is introduced, and the modularity is the ratio of the number of internal edges to the number of external edges;
[0016] Among them, an internal edge is an edge connecting two vertices in a partition, both of which belong to the partition, and an external edge is an edge connecting two vertices in a partition, one of which is in the partition and the other is not in the partition;
[0017] The calculation formula of partition modularity is:
[0018]
[0019] Among them, P k represents the kth partition of graph G, E i (P k ) represents partition P k The internal edge set of E, that is, the set of internal edges; o (P k ) represents partition P k The external edge set of |E i (P k )| and|E o (P k )|represents E i (P k ) and E o (P k)
[0020] Step S22: Based on the proposed modularity of the graph partition, according to the correlation between the partition modularity and the quality of the graph partition, for any graph G and any positive integer p, P k The modularity of is negatively correlated with the replication factor of the balanced p-edge graph partition;
[0021] Step S23: k When the initial partition is performed, P k The number of edges allocated in P is small, k The number of external edges of partition P is large. k The structure is loose, M(P k ) is smaller; as the partitioning proceeds, the k The number of edges gradually increases, M(P k ) increases, partition P k The structure becomes more compact; according to M(P k ) value, the graph edge partitioning is divided into two stages; when 0<M(P k )≤1, the first stage of division is carried out; when 1≤M(P k ), the second stage of division is carried out;
[0022] Step S24: Apply the microservice dependency graph G(V, E) obtained in step S1 to the two-stage local graph edge partitioning algorithm to achieve block partitioning of the microservice dependency graph.
[0023] As a further solution of the present invention: the specific steps of step S22 include:
[0024] Step 1: Define balanced p-edge graph partitioning: The graph G(V, E) is divided into p partitions, each partition is denoted by P k , k∈(1, 2, ..., p); there are no repeated edges between partitions, that is, Where (m, n)∈(1, 2, …, p), m≠n, and satisfies |E i (P k )|≤C, where C is the maximum capacity of edges in each partition;
[0025] Step 2: Define the replication factor: In order to quantify the number of mirrored vertices, the replication factor RF is defined as follows:
[0026]
[0027] Among them, |V| represents the total number of nodes, |V(P k )| represents partition P k The number of midpoints;
[0028] Step 3: Given a graph G = (V, E) with an average degree of l and a number of partitions p, we get:
[0029] |V|×l=2|E|
[0030] Assuming that the number of edges in each partition of the balanced p-edge graph is equal, we get:
[0031] |V|×l=2p×|E i (P k )|
[0032] V(P k )×1=2(|E i (P k )|+|E o (P k )|)
[0033] Combining the above formula, we get:
[0034]
[0035] It can be inferred from the above formula that the greater the modularity of each partition, the smaller the replication factor RF; therefore, for any graph G and any positive integer p, P k The modularity of is negatively correlated with the replication factor of the balanced p-edge graph partition.
[0036] As a further solution of the present invention: the specific steps of step S23 include:
[0037] Step 1: When modularity 0<M(P k )≤1, the first stage of graph partitioning is performed;
[0038] From partition P k The set of vertices adjacent to any vertex in k ) Select close to P k And the optimal vertex with high degree, the partitioning criteria satisfies the following formula:
[0039]
[0040] Among them, N(v m ) and N(v n ) respectively represent the vertex v m and v n The set of adjacent vertices; vertex v m With partition P k The degree of proximity between them is calculated by the formula (RF) through the vertex v m With partition P k It is measured by the proximity between the vertices in m When the degree is large, v mThe number of neighbors is large, |N(v m )∩N(v n )| may also have a larger value; by calculating the vertex set N(P k ) for each vertex in s1 (v m ), the optimal vertex v best The selection strategy is defined as follows:
[0041]
[0042] That is, select the adjacent vertex set N(P k ) s1 (v m ) is the vertex with the largest value as the best vertex v best ; Then, v best and partition P k The edges between the vertices in are assigned to partition P k ;
[0043] Step 2: When modularity 1≤M(P k ), the second phase of graph partitioning is performed;
[0044] With the addition of the optimal vertices in the previous step, the local partition becomes tighter, so the following formula is selected as the partition criterion:
[0045]
[0046] ΔM=M2(P k )-M1(P k )
[0047] Among them, M1(P k ) is to select the partition P before execution k Modularity, M2(P k ) is when the vertex v m Assign to P k Afterwards, partition P k The modularity of the optimal vertex v best The selection strategy is defined as follows:
[0048]
[0049] Select the adjacent vertex set N(P k ) s2 (v m ) is the vertex with the largest value as the best vertex v best , the partitions will be more closely divided; then, v best and partition P k The edges between the vertices in are assigned to partition P k .
[0050] As a further solution of the present invention: the specific steps of step S3 include:
[0051] Based on the graph partitioning obtained in step S2, for the divided microservices, a graph theory method is used to construct a call topology graph, so that users can analyze the call chain in segments;
[0052] Since microservice calls in the same block are relatively frequent, the probability of errors in service calls within a block is theoretically lower than calls between blocks.
[0053] Compared with the prior art, the present invention has the following technical effects:
[0054] By adopting the above technical solution, the microservices and the call chains between microservices are partitioned into graphs through a two-stage local graph edge partitioning algorithm. Only local information is used to partition the graph and only the data of a single partition needs to be saved in memory. According to the modular changes of the local partitions, the partitioning process of each partition is divided into two stages, which effectively improves the accuracy of microservice topology modeling. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings:
[0056] Figure 1 A schematic diagram of the steps of the microservice topology modeling method according to an embodiment disclosed in the present application. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0058] Please refer to Figure 1 In an embodiment of the present invention, a microservice topology modeling method based on local graph edge partitioning includes the following specific steps:
[0059] Step S1: construct call chain data through the call relationship between microservices, wherein the microservices are used as nodes and the collection of calls between microservices are used as edges. The specific steps include:
[0060] When analyzing the calling relationship between services, we ignore the calling direction and focus on the closeness between services. We use the idea of graph theory to map the calling network formed by the calling chain into an undirected graph G(V, E).
[0061] Where V represents the set of points in the undirected graph (v1, v2, ..., v n ), that is, the set of microservices in the calling network, n represents the number of microservices; E represents the set of edges in the undirected graph (e1, e2, ..., e m ), which is the set of calls between microservices in the calling network, and m represents the number of calling relationships between microservices;
[0062] Among them, each point in the undirected graph can store the indicators of its business performance, application system, network, container, resources and host, and each edge can store its weight information, which includes the number of calls and average delay.
[0063] Step S2: For the constructed call chain data, the graph edges are divided into two stages according to the modularity of the subgraph. In the first stage, the graph partitioning strategy is adopted to select the nearest and local maximum degree vertices; in the second stage, according to the partitioning strategy, the vertices that make the local partitions the tightest are selected to realize the partitioning of the microservice dependency graph. The specific steps include:
[0064] Step S21, based on the structure of the measured graph partition, modularity is introduced, and the modularity is the ratio of the number of internal edges to the number of external edges;
[0065] Among them, an internal edge is an edge connecting two vertices in a partition, both of which belong to the partition, and an external edge is an edge connecting two vertices in a partition, one of which is in the partition and the other is not in the partition;
[0066] The calculation formula of partition modularity is:
[0067]
[0068] Among them, P k represents the kth partition of graph G, E i (P k ) represents partition P k The internal edge set of E, that is, the set of internal edges; o (P k ) represents partition P k The external edge set of , that is, the set of external edges. i (P k )| and|E o (P k )|represents E i (P k ) and E o (P k )
[0069] Step S22: Based on the proposed modularity of the graph partition, according to the correlation between the partition modularity and the quality of the graph partition, for any graph G and any positive integer p, P k The modularity of is negatively correlated with the replication factor of the balanced p-edge graph partition;
[0070] The specific steps of step S22 include:
[0071] Step 1: Define balanced p-edge graph partitioning: The graph G(V, E) is divided into p partitions, each partition is denoted by P k , k∈(1,2,,..,p); there are no repeated edges between partitions, that is, Where (m, n)∈(1, 2, …, p), m≠n, and satisfies |E i (P k )|≤C, where C is the maximum capacity of edges in each partition;
[0072] Step 2: Define the replication factor: In order to quantify the number of mirrored vertices, the replication factor RF is defined as follows:
[0073]
[0074] Among them, |V| represents the total number of nodes, |V(P k )| represents partition P k The number of midpoints;
[0075] Step 3: Given a graph G = (V, E) with an average degree of l and a number of partitions p, we get:
[0076] |V|×l=2|E|
[0077] Assuming that the number of edges in each partition of the balanced p-edge graph is equal, we get:
[0078] |V|×l=2p×|E i (P k )|
[0079] V(P k )×1=2(|E i (P k )|+|E o (P k )|)
[0080] Combining the above formula, we get:
[0081]
[0082] It can be inferred from the above formula that the greater the modularity of each partition, the smaller the replication factor RF; therefore, for any graph G and any positive integer p, Pk The modularity of is negatively correlated with the replication factor of the balanced p-edge graph partition.
[0083] Step S23: k When the initial partition is performed, P k The number of edges allocated in P is small, k The number of external edges of partition P is large. k The structure is loose, M(P k ) is smaller; as the partitioning proceeds, the k The number of edges gradually increases, M(P k ) increases, partition P k The structure becomes more compact; according to M(P k ) value, the graph edge partitioning is divided into two stages; when 0<M(P k )≤1, the first stage of division is carried out; when 1≤M(P k ), the second stage of division is carried out;
[0084] The specific steps of step S23 include:
[0085] Step 1: When modularity 0<M(P k )≤1, the first stage of graph partitioning is performed;
[0086] From partition P k The set of vertices adjacent to any vertex in k ) Select close to P k And the optimal vertex with high degree, the partitioning criteria satisfies the following formula:
[0087]
[0088] Among them, N(v m ) and N(v n ) respectively represent the vertex v m and v n The set of adjacent vertices; vertex v m With partition P k The degree of proximity between them is calculated by the formula (RF) through the vertex v m With partition P k It is measured by the proximity between the vertices in m When the degree is large, v m The number of neighbors is large, |N(v m )∩N(v n )| may also have a larger value; by calculating the vertex set N(P k ) for each vertex in s1 (v m ), the optimal vertex v best The selection strategy is defined as follows:
[0089]
[0090] That is, select the adjacent vertex set N(P k ) s1 (v m ) is the vertex with the largest value as the best vertex v best ; Then, v best and partition P k The edges between the vertices in are assigned to partition P k ;
[0091] Step 2: When modularity 1≤M(P k ), the second phase of graph partitioning is performed;
[0092] With the addition of the optimal vertices in the previous step, the local partition becomes tighter, so the following formula is selected as the partition criterion:
[0093]
[0094] ΔM=M2(P k )-M1(P k )
[0095] Among them, M1(P k ) is to select the partition P before execution k Modularity, M2(P k ) is when the vertex v m Assign to P k Afterwards, partition P k The modularity of the optimal vertex v best The selection strategy is defined as follows:
[0096]
[0097] Select the adjacent vertex set N(P k ) s2 (v m ) is the vertex with the largest value as the best vertex v best , the partitions will be more closely divided; then, v best and partition P k The edges between the vertices in are assigned to partition P k .
[0098] Step S24: Apply the microservice dependency graph G(V, E) obtained in step S1 to the two-stage local graph edge partitioning algorithm to achieve block partitioning of the microservice dependency graph.
[0099] Step S3: construct a call topology diagram between different blocks through a graph theory algorithm to complete the topology modeling of the mutual call chain between microservices. The specific steps include:
[0100] Based on the graph partitioning obtained in step S2, for the divided microservices, a graph theory method is used to construct a call topology graph, so that users can analyze the call chain in segments;
[0101] Since microservice calls in the same block are relatively frequent, the probability of errors in service calls within a block is theoretically lower than calls between blocks.
[0102] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents, and all should be included within the scope of protection of the present invention.
Claims
1. A microservice topology modeling method based on local graph edge partitioning, characterized in that: The specific steps include: Step S1: construct call chain data through the call relationship between microservices, where the microservices are used as nodes and the collection of calls between microservices are used as edges; Step S2: For the constructed call chain data, the graph edges are divided into two stages according to the modularity of the subgraph. In the first stage, the graph partitioning strategy is adopted to select the nearest and local maximum degree vertices; in the second stage, according to the partitioning strategy, the vertices that make the local partitions the tightest are selected to realize the partitioning of the microservice dependency graph. The specific steps include: Step S21, based on the structure of the measured graph partition, modularity is introduced, and the modularity is the ratio of the number of internal edges to the number of external edges; Among them, an internal edge is an edge connecting two vertices in a partition, both of which belong to the partition, and an external edge is an edge connecting two vertices in a partition, one of which is in the partition and the other is not in the partition; The calculation formula of partition modularity is: Among them, P k represents the kth partition of graph G, E i (P k ) represents partition P k The internal edge set of E, that is, the set of internal edges; o (P k ) represents partition P k The external edge set of |E i (P k )| and|E o (P k )|represents E i (P k ) and E o (P k ) Step S22: Based on the proposed modularity of the graph partition, according to the correlation between the partition modularity and the quality of the graph partition, for any graph G and any positive integer p, P k The modularity of is negatively correlated with the replication factor of the balanced p-edge graph partition, which includes: Step 1: Define balanced p-edge graph partitioning: The graph G(V,E) is divided into p partitions, each partition is denoted by P k , k∈(1,2,…,p); there are no repeated edges between partitions, that is, Where (m,n)∈(1,2,…,p), m≠n, and satisfies |E i (P k )|≤C, where C is the maximum capacity of edges in each partition; Step 2: Define the replication factor: In order to quantify the number of mirrored vertices, the replication factor RF is defined as follows: Among them, |V| represents the total number of nodes, |V(P k )| represents partition P k The number of midpoints; Step 3: Given a graph G = (V, E) with an average degree of l and a number of partitions p, we get: |V|×l=2|E| Assuming that the number of edges in each partition of the balanced p-edge graph is equal, we get: |V|×l=2p×|E i (P k )| V(P k )×l=2(|E i (P k )|+|E o (P k )|) Combining the above formula, we get: It can be inferred from the above formula that the greater the modularity of each partition, the smaller the replication factor RF; therefore, for any graph G and any positive integer p, P k The modularity of is negatively correlated with the replication factor of the balanced p-edge graph partition; Step S23: k When the initial partition is performed, P k The number of edges allocated in P is small, k The number of external edges of partition P is large. k The structure is loose, M(P k ) is smaller; as the partitioning proceeds, the k The number of edges gradually increases, M(P k ) increases, partition P k The structure becomes more compact; according to M(P k ) value, the graph edge partitioning is divided into two stages; when 0 <M(P k )≤1, the first stage of division is carried out; when 1≤M(P k ), the second stage of division is carried out, and the specific steps include: Step 1: When modularity is 0 <M(P k )≤1, the first stage of graph partitioning is performed; From partition P k The set of vertices adjacent to any vertex in k ) Select close to P k And the optimal vertex with high degree, the partitioning criteria satisfies the following formula: Among them, N(v m ) and N(v n ) respectively represent the vertex v m and v n The set of adjacent vertices; vertex v m With partition P k The degree of proximity between them is calculated by the formula (RF) through the vertex v m With partition P k It is measured by the proximity between the vertices in m When the degree is large, v m The number of neighbors is large, |N(v m )∩N(v n )| may also have a larger value; by calculating the vertex set N(P k ) for each vertex in s1 (v m ), the optimal vertex v best The selection strategy is defined as follows: That is, select the adjacent vertex set N(P k ) s1 (v m ) is the vertex with the largest value as the best vertex v best ; Then, v best and partition P k The edges between the vertices in are assigned to partition P k ; Step 2: When modularity 1≤M(P k ), the second phase of graph partitioning is performed; With the addition of the optimal vertices in the previous step, the local partition becomes tighter, so the following formula is selected as the partition criterion: ΔM=M2(P k )-M1(P k ) Among them, M1(P k ) is to select the partition P before execution k Modularity, M2(P k ) is when the vertex v m Assign to P k Afterwards, partition P k The modularity of the optimal vertex v best The selection strategy is defined as follows: Select the adjacent vertex set N(P k ) s2 (v m ) is the vertex with the largest value as the best vertex v best , the partitions will be more closely divided; then, v best and partition P k The edges between the vertices in are assigned to partition P k ; Step S24, applying the microservice dependency graph G(V, E) obtained in step S1 to a two-stage local graph edge partitioning algorithm to achieve block partitioning of the microservice dependency graph; Step S3: construct a call topology diagram between different blocks through a graph theory algorithm to complete the topology modeling of the mutual call chain between microservices.
2. According to claim 1, a microservice topology modeling method based on local graph edge partitioning is characterized in that: The specific steps of step S1 include: When analyzing the calling relationship between services, ignore the calling direction and focus on the closeness between services. Using the idea of graph theory, map the calling network formed by the calling chain into an undirected graph G(V,E); Where V represents the set of points in the undirected graph (v1,v2,…,v n ), which is the set of microservices in the calling network, n is the number of microservices; E is the set of edges in the undirected graph (e1, e2, …, e m ), which is the set of calls between microservices in the calling network, and m represents the number of calling relationships between microservices; Among them, each point in the undirected graph can store the indicators of its business performance, application system, network, container, resources and host, and each edge can store its weight information, which includes the number of calls and average delay.
3. According to the microservice topology modeling method based on local graph edge partitioning according to claim 1, it is characterized in that: The specific steps of step S3 include: Based on the graph partitioning obtained in step S2, for the divided microservices, a graph theory method is used to construct a call topology graph, so that users can analyze the call chain in segments; Since microservice calls in the same block are relatively frequent, the probability of errors in service calls within a block is theoretically lower than calls between blocks.
Citation Information
Patent Citations
Microservice call chain anomaly detection method and device based on graph convolutional neural network
CN115185736A