Microservice splitting method, device and electronic device based on dynamic execution tracking
By adding log tracking probes to the single-body system, generating directed graphs of system calls and performing clustering operations, automatic splitting of microservice applications is realized, solving the problems of low splitting efficiency and high labor costs in the existing technology, improving the splitting efficiency and avoiding human errors.
Patent Information
- Application Number
- CN202411782522.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-04-04
AI Technical Summary
In the prior art, microservice splitting is inefficient, labor costs are high, and manual migration and maintenance of microservice systems are difficult.
The microservice splitting method based on dynamic execution tracking is adopted. By adding log tracking probes to the source code of the single system, the runtime log files are obtained, the system call directed graph is generated, and clustering operations are performed according to the functional correlation to automatically split microservices.
The automatic splitting of microservice applications is realized, reducing manpower waste, improving the efficiency of microservice splitting, avoiding human errors, and ensuring the correct call and operation between generated microservice applications.
Smart Images

Figure CN119759319A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software engineering application technology, and in particular to a microservice splitting method, device and electronic device based on dynamic execution tracing. Background Art
[0002] With the rapid development of software applications, microservice technology has been widely used in the deployment of program system functions. A large and complex application is split into multiple distributed, low-coupled microservices according to its business functions. Each service can be independently developed, deployed and upgraded, significantly improving the flexibility of software development and maintenance.
[0003] However, the process of migrating from a monolithic system architecture to a microservice architecture is very complex. If software designers perform it manually, it is time-consuming and error-prone. In addition, the quality of the migrated system depends on the experience and knowledge accumulation of the executors, which also makes it very difficult to manually migrate and maintain the microservice system. Therefore, there is an urgent need for a microservice decomposition method to support and help software designers extract the appropriate architecture from the monolithic system architecture to implement microservice applications. Summary of the invention
[0004] To this end, the present application provides a microservice splitting method, device and electronic device based on dynamic execution tracking to solve the problems of low efficiency and high labor cost of microservice splitting caused by the need for relevant technicians to manually split microservices in the prior art.
[0005] In order to achieve the above-mentioned objectives, the first aspect of the present application provides a microservice splitting method based on dynamic execution tracking, the method comprising: adding a log tracking probe to the source code of a monolithic system to obtain the log file of the monolithic system during operation; for each layer in the abstract logic layer and the persistence layer of the monolithic system, performing a microservice splitting operation to obtain the microservice applications corresponding to each layer; wherein the microservice splitting operation comprises: based on the log file, obtaining the system execution path and the calling relationship between the entity class and the class method in the layer; based on the system execution path and the calling relationship, generating a system call directed graph corresponding to the layer; performing a clustering operation according to the system call directed graph, aggregating and combining nodes whose functional correlation is greater than a threshold and directed edges of the same type under the node to obtain multiple microservice applications.
[0006] According to the first aspect, the abstract logic layer includes the business presentation layer and the logic layer in the monolithic system; the entity classes and class methods in the abstract logic layer include: the entity classes and class methods in the business presentation layer, and the entity classes and class methods in the logic layer.
[0007] According to the first aspect, or any implementation of the first aspect above, a log tracking probe is added to the source code of the monomer system to obtain the log file of the monomer system when it is running, including: determining the entity class that defines the system domain from the source code of the monomer system; adding a log tracking probe to the class method related to the entity class to obtain the log file of the monomer system when it is running.
[0008] According to the first aspect, or any implementation method of the first aspect above, the system call directed graph corresponding to the layer is generated based on the system execution path and the calling relationship, including: taking the entity classes and class methods in the layer as nodes of the system call directed graph; based on the system execution path and the calling relationship, constructing directed edges between the nodes.
[0009] According to the first aspect, or any implementation method of the first aspect above, the directed edge between the nodes is constructed based on the system execution path and the calling relationship, including: constructing the direction of the directed edge based on the system execution path; constructing the type and weight of the directed edge based on the calling relationship; wherein the types of the directed edge include: calling edge, using edge, persistent edge, reference edge and extended edge.
[0010] According to the first aspect, or any implementation of the first aspect above, the type and weight of the directed edge are constructed based on the call relationship, including: when there is a method call between a class method node and another class method node, a call edge is constructed between the two class method nodes; when the class method node has a reference to an entity class node, a use edge is constructed between the class method node and the entity class node; when the class method node in the persistence layer reads or writes a given entity on the database, a persistence edge is constructed between the class method node and the corresponding entity class node; when an entity class node references another entity class node, a reference edge is constructed between the two entity class nodes; when an entity class node extends another entity class node, an extension edge is constructed between the two entity class nodes.
[0011] According to the first aspect, or any implementation of the first aspect above, the system calls a directed graph to perform a clustering operation, and aggregates and combines nodes whose functional correlation is greater than a threshold and directed edges of the same type under the nodes to obtain multiple microservice applications, including: based on the system call directed graph, determining the functional correlation between the nodes according to the weights of the directed edges between the nodes; aggregating multiple nodes whose functional correlation is greater than a threshold into one identical node, and aggregating and combining directed edges of the same type under multiple nodes whose functional correlation is greater than the threshold to obtain multiple microservice applications.
[0012] The second aspect of the present application provides a microservice splitting device based on dynamic execution tracking, which includes: a tracking module, which is used to add a log tracking probe to the source code of a monolithic system to obtain the log file of the monolithic system when it is running; a splitting module, which is used to perform a microservice splitting operation on each layer in the abstract logic layer and the persistence layer of the monolithic system to obtain the microservice application corresponding to each layer; wherein the splitting module includes: an acquisition submodule, which is used to obtain the system execution path and the calling relationship between the entity class and the class method in the layer based on the log file; a generation submodule, which is used to generate a system call directed graph corresponding to the layer based on the system execution path and the calling relationship; a clustering submodule, which is used to perform a clustering operation according to the system call directed graph, and to aggregate and combine nodes whose functional similarity is greater than a threshold and the directed edges of the same type under the nodes to obtain multiple microservice applications.
[0013] The third aspect of the present application provides an electronic device, which includes: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by one or more processors, the one or more processors implement any one of the methods in the first aspect; one or more I / O interfaces, connected between the processor and the memory, and configured to implement information interaction between the processor and the memory.
[0014] A fourth aspect of the present application provides a computer-readable medium having a computer program stored thereon, which implements any one of the methods in the first aspect when the program is executed by a processor.
[0015] The present application has the following advantages: a microservice splitting method, device and electronic device based on dynamic execution tracking provided by an embodiment of the present application, in which a log tracking probe is first added to the source code of the monolithic system to obtain the log file of the monolithic system during operation; then, for each layer in the abstract logic layer and the persistence layer in the monolithic system, a microservice splitting operation is performed to obtain the microservice applications corresponding to each layer; wherein the microservice splitting operation includes: based on the log file, obtaining the system execution path and the calling relationship between the entity classes and class methods in the layer; based on the system execution path and the calling relationship, generating a system call directed graph corresponding to the layer; performing clustering operations according to the system call directed graph, aggregating and combining nodes whose functional correlation is greater than a threshold and directed edges of the same type under the nodes, and obtaining multiple microservice applications with high cohesion and low coupling, thereby realizing automatic splitting of microservice applications for the monolithic system, effectively reducing manpower waste, improving microservice splitting efficiency, and avoiding human errors to ensure the correct calling and running of the generated microservice applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings are used to provide further understanding of the present application and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present application, but do not constitute a limitation to the present application.
[0017] Figure 1 A flowchart of a microservice splitting method based on dynamic execution tracking provided in an embodiment of the present application;
[0018] Figure 2 A flowchart of a method for generating a system call directed graph provided in an embodiment of the present application;
[0019] Figure 3 A schematic diagram of the structure of a microservice splitting device based on dynamic execution tracing provided in an embodiment of the present application;
[0020] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0022] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.
[0023] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0024] The terms used in this application are only used to describe specific embodiments and are not intended to limit the present application.As used in this application, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
[0025] When the terms “comprising” and / or “made of…” are used in this application, it specifies the existence of the stated features, integers, steps, operations, elements and / or components, but does not exclude the existence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0026] The embodiments described in the present application may be described with reference to plan views and / or cross-sectional views by means of ideal schematic diagrams of the present application. Therefore, the exemplary illustrations may be modified according to manufacturing techniques and / or tolerances.
[0027] Unless otherwise defined, all terms (including technical and scientific terms) used in this application have the same meaning as those commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this application, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined in this application.
[0028] With the rapid development of software applications, microservice technology has been widely used in the deployment of program system functions. A large and complex application is split into multiple distributed, low-coupled microservices according to its business functions. Each service can be independently developed, deployed and upgraded, significantly improving the flexibility of software development and maintenance.
[0029] However, the process of migrating from a monolithic system architecture to a microservice architecture is very complex. If software designers perform it manually, it is time-consuming and error-prone. In addition, the quality of the migrated system depends on the experience and knowledge accumulation of the executors, which also makes it very difficult to manually migrate and maintain the microservice system. Therefore, there is an urgent need for a microservice decomposition method to support and help software designers extract the appropriate architecture from the monolithic system architecture to implement microservice applications.
[0030] To this end, an embodiment of the present application provides a microservice splitting method based on dynamic execution tracking. First, a log tracking probe is added to the monolithic system to collect and obtain the log files of the monolithic system during operation; then, based on the log files, the system execution path and the calling relationship between entity classes and class methods in different layers of the monolithic system are obtained; a method-level system directed graph is generated according to the system execution path and the calling relationship between entity classes; nodes with the same functions and paths of the same operation types in the system directed graph are extracted, aggregated and combined to obtain microservice applications with high cohesion and low coupling in different layers, thereby realizing the automatic decomposition of the overall system into microservices, helping developers to build and reconstruct monolithic systems, which can effectively reduce manpower investment and avoid human errors.
[0031] Figure 1 A schematic diagram of a process flow of a microservice splitting method based on dynamic execution tracking provided in an embodiment of the present application. The method is applied to electronic devices. Figure 1 As shown, the microservice splitting method based on dynamic execution tracing includes: step S11 and step S12, wherein step S12 includes: step S121-step S1213.
[0032] Step S11: adding a log tracking probe to the source code of the monolithic system to obtain the log file of the monolithic system during operation.
[0033] The log tracking probe is a tool used to monitor and record log information generated during system operation. It is used to record various events during system operation, including user operations, system calls, error messages, etc., and associate related logs through a globally unique identifier to form a complete call chain.
[0034] In an embodiment of the present application, the log file mainly includes logs generated by tracking events indicating function entry and exit and database access. Each log in the log file contains a timestamp and a session ID. The timestamp is used to record the time when the log is generated, and the session ID is used to distinguish whether the previous log and the next log are generated based on the same request.
[0035] In a possible implementation method provided in an embodiment of the present application, a log tracking probe is added to the source code of the monolithic system to obtain the log file of the monolithic system during operation (the above-mentioned step S11), including: the following steps 1 and 2.
[0036] Among them, step 1 is to determine the entity class that defines the system domain from the source code of the single system.
[0037] Step 2: Add a log tracking probe to the class method related to the entity class to obtain the log file of the single system when it is running.
[0038] Among them, the class methods related to the entity class may refer to the methods defined in the entity class, which are closely related to the data attributes of the entity class and are mainly used to operate or process these data attributes.
[0039] In this implementation, the electronic device does not add log tracking probes to all entity class-related class methods, but only adds log tracking probes to specific class methods, so as to improve the availability of the generated log files and thus improve the efficiency of microservice splitting.
[0040] This is understandable when analyzing monolithic systems, based on the fact that most languages and frameworks for building service systems rely on a layered architecture where classes and methods in the presentation layer provide a public interface and get incoming requests, then call methods in lower layers to pass requests to the persistence layer and underlying database.
[0041] When splitting microservices for a monolithic system, a directed graph can be generated by analyzing the role of each layer in the system to represent the relationship between classes and methods. In order to be more general, in the steps of splitting microservices described later, two main layers are considered in the embodiment of the present application to abstract the system layered architecture, namely, a logic layer including a business presentation layer and a persistence layer.
[0042] Step S12: For each layer in the abstract logic layer and the persistence layer in the monolithic system, a microservice splitting operation is performed to obtain microservice applications corresponding to each layer.
[0043] The abstract logic layer includes the business presentation layer and the logic layer in the single system; the entity classes and class methods in the abstract logic layer include: the entity classes and class methods in the business presentation layer, and the entity classes and class methods in the logic layer.
[0044] The microservice splitting operation includes: the following steps S121 to S1213.
[0045] Step S121: Based on the log file, obtain the system execution path and the calling relationship between the entity classes and class methods in the layer.
[0046] In an implementation method provided in an embodiment of the present application, based on the log file, the system execution path and the calling relationship between the entity classes and class methods in the layer are obtained, including: generating a data flow graph based on the log file, obtaining the system execution path based on the data flow graph, and obtaining the calling relationship between the entity classes and class methods in the layer by analyzing the system execution path.
[0047] In the embodiment of the present application, the classes containing the system business logic are all considered to be classes in the abstract logic layer. In addition, in the embodiment of the present application, the annotations used in the system framework can also be used to define the technical role of the class, such as using the @Controller, @Service, @Repository, @Entity and other annotations provided in the Spring Framework framework to identify whether each class belongs to the abstract logic layer or the persistence layer.
[0048] Step S122: Based on the system execution path and the calling relationship, generate a system call directed graph corresponding to the layer.
[0049] The system call directed graph is used to represent the calling relationship and hierarchical relationship of each entity class and each method in the layer (abstract logic layer or persistence layer).
[0050] It can be understood that the system call directed graph is a method-level system call directed graph, that is, the nodes of the system call directed graph are refined to the class method level, and the granularity of the call relationship within the system is finer, which is convenient for the subsequent splitting of microservice applications.
[0051] Figure 2 A flowchart of a method for generating a system call directed graph provided in an embodiment of the present application. Figure 2Based on the system execution path and the calling relationship, a system call directed graph corresponding to the layer is generated (step S122), including: step S122a and step S122b.
[0052] Step S122a: Use the entity classes and class methods in the layer as nodes of the system call directed graph.
[0053] Step S122b: construct directed edges between the nodes based on the system execution path and the call relationship.
[0054] In a possible implementation method provided in an embodiment of the present application, the step of constructing the directed edge between the nodes based on the system execution path and the call relationship (step S122b) includes: the following steps one and two.
[0055] Step 1: Based on the system execution path, construct the direction of the directed edge.
[0056] The direction of the directed edge is the same as the direction of the system execution path. For example, when node 1 calls node 2, the directed edge between node 1 and node 2 points from node 1 to node 2.
[0057] Step 2: Based on the calling relationship between the entity class and the class method, construct the type and weight of the directed edge.
[0058] The types of directed edges include: call edge, use edge, persistent edge, reference edge and extension edge. The weights assigned to directed edges can represent the relevance of each relationship between nodes, wherein the greater the weight, the higher the relevance.
[0059] In one example, the step of constructing the type and weight of the directed edge based on the calling relationship includes: the following cases (1) to (5).
[0060] (1) When a method call exists between a class method node and another class method node, a call edge is constructed between the two class method nodes, and the weight of the call edge is set to 0.8.
[0061] (2) When a class method node has a reference to an entity class node, a use edge is constructed between the class method node and the entity class node, and the weight of the use edge is set to 0.6.
[0062] (3) When a class method node in the persistence layer reads or writes a given entity on the database, a persistent edge is constructed between the class method node and the corresponding entity class node. Since the persistent edge is a persistent relationship, the weight of the persistent edge is set to 1 by default.
[0063] (4) When an entity class node references another entity class node, a reference edge is constructed between the two entity class nodes, and the weight of the reference edge is set to 0.2.
[0064] (5) When one entity class node extends another entity class node, an extension edge is constructed between the two entity class nodes, and the weight of the extension edge is set to 0.
[0065] In the embodiment of the present application, the persistent relationship is set to be the most important, followed by the method call relationship. The reference and extension relationship weights are low, which is conducive to distributing entities of different functional classes to different microservices. The weight of the directed edge defines the relevance of the relationship between nodes. The higher the weight of the edge, the more likely the method or entity class at its endpoint is to be clustered and combined into the same microservice.
[0066] Step S123: Perform a clustering operation on the directed graph according to the system call, aggregate and combine nodes whose functional relevance is greater than a threshold and directed edges of the same type under the nodes to obtain multiple microservice applications.
[0067] It is understandable that the abstract logic layer and persistence layer directed graphs obtained above can be considered as the model of the entire monolithic system. The call, use and persistence relationships represent all interdependencies in the system code, while the entity-to-entity reference and extension relationships reflect the structure of the system model. Therefore, clustering operations are performed based on the system call directed graph, and nodes with functional relevance greater than a threshold and directed edges of the same type under the node are aggregated and combined, so that multiple microservice applications with high cohesion and low coupling can be obtained.
[0068] In a possible implementation method provided in an embodiment of the present application, the above-mentioned step of performing a clustering operation on a directed graph based on the system call, aggregating and combining nodes whose functional correlation is greater than a threshold and directed edges of the same type under the node to obtain multiple microservice applications (step S123) includes: the following steps one and two.
[0069] Step 1: Based on the system call directed graph, the functional correlation between the nodes is determined according to the weights of the directed edges between the nodes.
[0070] Among them, the weight assigned to the directed edge can represent the relevance of each relationship between nodes. The larger the weight, the higher the functional relevance.
[0071] Step 2: Aggregate multiple nodes whose functional correlation is greater than a threshold into one identical node, and aggregate and combine directed edges of the same type under multiple nodes whose functional correlation is greater than a threshold to obtain multiple microservice applications.
[0072] The threshold value may be set according to actual application conditions, for example, 80%.
[0073] For example, the system call directed graph contains nodes A, B, C, D, E, and F, where the functional correlation between nodes A, B, and C is greater than a threshold, and the functional correlation between nodes D and E is greater than a threshold, then nodes A, B, and C are aggregated into a new node G, and nodes D and E are aggregated into a new node H. For nodes A, B, and C, if nodes A, B, and C all have reference edges pointing to node F, the reference edges to node F are aggregated into a new directed edge.
[0074] The step division of the above methods is only for clear description. When implemented, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this application; adding insignificant modifications to the algorithm or process or introducing insignificant designs without changing the core design of the algorithm and process are all within the scope of protection of this application.
[0075] A microservice splitting method based on dynamic execution tracking is provided in an embodiment of the present application. In this method, a log tracking probe is first added to the source code of a monolithic system to obtain the log file of the monolithic system when it is running; then, a microservice splitting operation is performed on each layer in the abstract logic layer and the persistence layer of the monolithic system to obtain the microservice applications corresponding to each layer; wherein the microservice splitting operation includes: based on the log file, obtaining the system execution path and the calling relationship between the entity classes and class methods in the layer; based on the system execution path and the calling relationship, generating a system call directed graph corresponding to the layer; performing clustering operations according to the system call directed graph, aggregating and combining nodes whose functional correlation is greater than a threshold and directed edges of the same type under the nodes, and obtaining multiple microservice applications with high cohesion and low coupling, thereby realizing automatic splitting of microservice applications for the monolithic system, effectively reducing manpower waste, improving microservice splitting efficiency, and avoiding human errors to ensure correct calling and operation between generated microservice applications.
[0076] The microservice splitting method based on dynamic execution tracking provided in the embodiment of the present application is applicable to various scenarios such as migration of monolithic system applications of different scales. It can be dynamically updated with the version iteration of the monolithic system application, and the generated microservice application set meets the principle of independent single responsibility, and has the characteristics of high cohesion and low coupling.
[0077] In a second aspect, an embodiment of the present application provides a microservice splitting device based on dynamic execution tracing. Figure 3 The structure diagram of a microservice splitting device based on dynamic execution tracking provided in an embodiment of the present application is shown in FIG. Figure 3As shown, the microservice splitting device includes: a tracking module 31 and a splitting module 32, wherein the splitting module 32 includes an acquisition submodule 321, a generation submodule 322 and a clustering submodule 323.
[0078] The tracking module 31 is used to add a log tracking probe to the source code of the monolithic system to obtain the log file of the monolithic system during operation.
[0079] The log tracking probe is a tool used to monitor and record log information generated during system operation. It is used to record various events during system operation, including user operations, system calls, error messages, etc., and associate related logs through a globally unique identifier to form a complete call chain.
[0080] In an embodiment of the present application, the log file mainly includes logs generated by tracking events indicating function entry and exit and database access. Each log in the log file contains a timestamp and a session ID. The timestamp is used to record the time when the log is generated, and the session ID is used to distinguish whether the previous log and the next log are generated based on the same request.
[0081] In a possible implementation method provided in an embodiment of the present application, the above-mentioned tracking module 31 is specifically used to: determine the entity class that defines the system domain from the source code of the monomer system, add a log tracking probe to the class method related to the entity class, so as to obtain the log file of the monomer system during operation.
[0082] In this implementation, the electronic device does not add log tracking probes to all entity class-related class methods, but only adds log tracking probes to specific class methods, so as to improve the availability of the generated log files and thus improve the efficiency of microservice splitting.
[0083] This is understandable when analyzing monolithic systems, based on the fact that most languages and frameworks for building service systems rely on a layered architecture where classes and methods in the presentation layer provide a public interface and get incoming requests, then call methods in lower layers to pass requests to the persistence layer and underlying database.
[0084] When splitting microservices for a monolithic system, a directed graph can be generated by analyzing the role of each layer in the system to represent the relationship between classes and methods. In order to be more general, in the steps of splitting microservices described later, two main layers are considered in the embodiment of the present application to abstract the system layered architecture, namely, a logic layer including a business presentation layer and a persistence layer.
[0085] The splitting module 32 is used to perform a microservice splitting operation on each layer in the abstract logic layer and the persistence layer in the monolithic system to obtain microservice applications corresponding to each layer.
[0086] The abstract logic layer includes the business presentation layer and the logic layer in the single system; the entity classes and class methods in the abstract logic layer include: the entity classes and class methods in the business presentation layer, and the entity classes and class methods in the logic layer.
[0087] The above-mentioned splitting module includes an acquisition submodule 321 , a generation submodule 322 and a clustering submodule 323 .
[0088] The acquisition submodule 321 is used to acquire the system execution path and the calling relationship between the entity classes and class methods in the layer based on the log file.
[0089] In the embodiment of the present application, the classes containing the system business logic are all considered to be classes in the abstract logic layer. In addition, in the embodiment of the present application, the annotations used in the system framework can also be used to define the technical role of the class, such as using the @Controller, @Service, @Repository, @Entity and other annotations provided in the Spring Framework framework to identify whether each class belongs to the abstract logic layer or the persistence layer.
[0090] The generating submodule 322 is used to generate a system call directed graph corresponding to the layer based on the system execution path and the calling relationship.
[0091] The system call directed graph is used to represent the calling relationship and hierarchical relationship of each entity class and each method in the layer (abstract logic layer or persistence layer).
[0092] It can be understood that the system call directed graph is a method-level system call directed graph, that is, the nodes of the system call directed graph are refined to the class method level, and the granularity of the call relationship within the system is finer, which is convenient for the subsequent splitting of microservice applications.
[0093] The generation submodule 322 is specifically used to: use the entity classes and class methods in the layer as nodes of the system call directed graph, and construct directed edges between the nodes based on the system execution path and the call relationship.
[0094] Wherein, based on the system execution path and the calling relationship, the directed edge between the nodes is constructed, including: based on the system execution path, the direction of the directed edge is constructed; based on the calling relationship between the entity class and the class method, the type and weight of the directed edge are constructed.
[0095] The types of directed edges include: call edge, use edge, persistent edge, reference edge and extension edge. The weights assigned to directed edges can represent the relevance of each relationship between nodes, wherein the greater the weight, the higher the relevance.
[0096] In one example, the generation submodule constructs the type and weight of the directed edge based on the call relationship, including: the following cases (1) to (5).
[0097] (1) When a method call exists between a class method node and another class method node, a call edge is constructed between the two class method nodes, and the weight of the call edge is set to 0.8.
[0098] (2) When a class method node has a reference to an entity class node, a use edge is constructed between the class method node and the entity class node, and the weight of the use edge is set to 0.6.
[0099] (3) When a class method node in the persistence layer reads or writes a given entity on the database, a persistent edge is constructed between the class method node and the corresponding entity class node. Since the persistent edge is a persistent relationship, the weight of the persistent edge is set to 1 by default.
[0100] (4) When an entity class node references another entity class node, a reference edge is constructed between the two entity class nodes, and the weight of the reference edge is set to 0.2.
[0101] (5) When one entity class node extends another entity class node, an extension edge is constructed between the two entity class nodes, and the weight of the extension edge is set to 0.
[0102] In the embodiment of the present application, the persistent relationship is set to be the most important, followed by the method call relationship. The reference and extension relationship weights are low, which is conducive to distributing entities of different functional classes to different microservices. The weight of the directed edge defines the relevance of the relationship between nodes. The higher the weight of the edge, the more likely the method or entity class at its endpoint is to be clustered and combined into the same microservice.
[0103] The clustering submodule 323 is used to perform a clustering operation according to the system call directed graph, aggregate and combine nodes with functional similarity greater than a threshold and directed edges of the same type under the nodes to obtain multiple microservice applications.
[0104] It should be clear that the present application is not limited to the specific configurations and processes described in the above embodiments and shown in the figures. For the convenience and brevity of description, a detailed description of the known methods is omitted here, and the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, which will not be repeated here.
[0105] The embodiment of the present application provides a microservice splitting device based on dynamic execution tracking, in which a tracking module is used to add a log tracking probe to the source code of a monolithic system to obtain the log file of the monolithic system when it is running; the splitting module is used to perform a microservice splitting operation on each layer in the abstract logic layer and the persistence layer in the monolithic system to obtain the microservice application corresponding to each layer; wherein the splitting module includes: an acquisition submodule, used to obtain the system execution path and the call relationship between the entity class and the class method in the layer based on the log file; a generation submodule, used to generate a system call directed graph corresponding to the layer based on the system execution path and the call relationship; a clustering submodule, used to perform a clustering operation according to the system call directed graph, and to aggregate and combine nodes whose functional correlation is greater than a threshold and directed edges of the same type under the nodes to obtain multiple microservice applications with high cohesion and low coupling, thereby realizing automatic splitting of microservice applications for the monolithic system, effectively reducing manpower waste, improving microservice splitting efficiency, supporting and helping software designers to build and reconstruct monolithic systems, and also avoiding errors when manually splitting monolithic systems to ensure correct calling and operation between generated microservice applications.
[0106] By analyzing the log files of the monolithic system, extracting the calling relationships between the system execution paths and entity class methods, extracting and aggregating the paths with the same functions and the same operation types in the system directed graph, the overall system is automatically decomposed into a set of microservice applications, supporting and helping software designers to build and reconstruct monolithic systems, which can effectively reduce manpower, avoid human errors, and ensure the correct calling and operation between the generated microservice applications.
[0107] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 4 The electronic device includes: one or more processors 401; a memory 402, on which one or more programs are stored. When the one or more programs are executed by one or more processors, the one or more processors implement any one of the above-mentioned microservice splitting methods based on dynamic execution tracking; one or more I / O interfaces 403, connected between the processor and the memory, and configured to realize information interaction between the processor and the memory.
[0108] Among them, the processor 401 is a device with data processing capabilities, including but not limited to a central processing unit (CPU); the memory 402 is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH); the I / O interface (read-write interface) 403 is connected between the processor 401 and the memory 402, and can realize information interaction between the processor 401 and the memory 402, including but not limited to a data bus (Bus), etc.
[0109] In some embodiments, the processor 401 , the memory 402 , and the I / O interface 403 are connected to each other through a bus, and further connected to other components of the computing device.
[0110] This embodiment also provides a computer-readable medium on which a computer program is stored. When the program is executed by a processor, the microservice splitting method based on dynamic execution tracing provided in this embodiment is implemented. To avoid repeated description, the specific steps of the microservice splitting method based on dynamic execution tracing are not repeated here.
[0111] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the invented method described above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0112] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0113] Those skilled in the art will understand that although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features from different embodiments is meant to be within the scope of the present embodiment and to form different embodiments.
[0114] It is to be understood that the above embodiments are merely exemplary embodiments used to illustrate the principles of the present application, but the present application is not limited thereto. For those skilled in the art, various modifications and improvements can be made without departing from the spirit and substance of the present application, and these modifications and improvements are also considered to be within the scope of protection of the present application.
Claims
1. A microservice splitting method based on dynamic execution tracing, characterized in that: The method comprises: Add a log tracking probe to the source code of the monolithic system to obtain the log file of the monolithic system when it is running; For each layer in the abstract logic layer and the persistence layer in the monolithic system, a microservice splitting operation is performed to obtain a microservice application corresponding to each layer; wherein the microservice splitting operation includes: Based on the log file, obtaining a system execution path and a calling relationship between entity classes and class methods in the layer; Based on the system execution path and the call relationship, generating a system call directed graph corresponding to the layer; A clustering operation is performed according to the system call directed graph, and nodes whose functional relevance is greater than a threshold and directed edges of the same type under the nodes are aggregated and combined to obtain multiple microservice applications.
2. The method according to claim 1, characterized in that The abstract logic layer includes the business presentation layer and the logic layer in the monomer system; The entity classes and class methods in the abstract logic layer include: the entity classes and class methods in the business presentation layer, and the entity classes and class methods in the logic layer.
3. The method according to claim 1, characterized in that Adding a log tracking probe to the source code of the monolithic system to obtain the log file of the monolithic system when it is running includes: Determining entity classes defining a system domain from source code of the monolithic system; A log tracking probe is added to the class method related to the entity class to obtain the log file of the single system when it is running.
4. The method according to claim 1, characterized in that: The generating a system call directed graph corresponding to the layer based on the system execution path and the call relationship includes: Using entity classes and class methods in the layer as nodes of the system call directed graph; Based on the system execution path and the call relationship, directed edges between the nodes are constructed.
5. The method according to claim 4, characterized in that The step of constructing directed edges between the nodes based on the system execution path and the call relationship includes: Based on the system execution path, construct the direction of the directed edge; Based on the calling relationship, the type and weight of the directed edge are constructed; wherein the types of the directed edge include: calling edge, using edge, persistent edge, reference edge and extended edge.
6. The method according to claim 5, characterized in that The step of constructing the type and weight of the directed edge based on the calling relationship includes: When there is a method call between a class method node and another class method node, a call edge is constructed between the two class method nodes; When a class method node has a reference to an entity class node, a use edge is constructed between the class method node and the entity class node; In case a class method node in the persistence layer reads or writes a given entity on the database, a persistence edge is constructed between the class method node and the corresponding entity class node; When an entity class node references another entity class node, a reference edge is constructed between the two entity class nodes; In the case where one entity class node extends another entity class node, an extension edge is constructed between the two entity class nodes.
7. The method according to claim 1, characterized in that The clustering operation is performed according to the system call directed graph, and nodes whose functional correlation is greater than a threshold and directed edges of the same type under the nodes are aggregated and combined to obtain multiple microservice applications, including: Based on the system call directed graph, determining the functional correlation between the nodes according to the weights of the directed edges between the nodes; Multiple nodes whose functional correlation is greater than a threshold are aggregated into one identical node, and directed edges of the same type under multiple nodes whose functional correlation is greater than a threshold are aggregated and combined to obtain multiple microservice applications.
8. A microservice splitting device based on dynamic execution tracing, characterized in that: The device comprises: A tracking module is used to add a log tracking probe to the source code of the monolithic system to obtain the log file of the monolithic system when it is running; A splitting module is used to perform a microservice splitting operation on each layer in the abstract logic layer and the persistence layer in the monolithic system to obtain a microservice application corresponding to each layer; wherein the splitting module includes: An acquisition submodule, used for acquiring a system execution path and a calling relationship between entity classes and class methods in the layer based on the log file; A generating submodule, used for generating a system call directed graph corresponding to the layer based on the system execution path and the calling relationship; The clustering submodule is used to perform clustering operations according to the system call directed graph, aggregate and combine nodes with functional similarity greater than a threshold and directed edges of the same type under the nodes to obtain multiple microservice applications.
9. An electronic device, characterized in that: include: one or more processors; A storage device having one or more programs stored thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7; One or more I / O interfaces are connected between the processor and the memory and are configured to implement information interaction between the processor and the memory.
10. A computer-readable medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method according to any one of claims 1 to 7.