A circular dependency detection method and system in a microservice system

By dividing the microservice system into the first and second circular dependency detection tasks and generating a directed graph for judgment, it solves the problem that manual detection is difficult to process a large amount of data and is easy to miss detection, and realizes the detection of circular dependencies in the microservice system. Automatic detection and alerting.

CN114416564BActive Publication Date: 2024-09-13SHENZHEN COMTOP INFORMATION TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210065403.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-20
Publication Date
2024-09-13
Estimated Expiration
2042-01-20

AI Technical Summary

Technical Problem

In the existing technology, circular dependency detection in microservice systems mainly relies on manual detection, which makes detection difficult and easy to miss when the amount of data is large, and cannot effectively solve the circular dependency problem in microservice systems.

Method used

A method of cyclic dependency detection in a microservice system is proposed. By dividing the first cyclic dependency detection task and the second cyclic dependency detection task, a first directed graph representing the service process of executing the requested task and a third directed graph representing the service calling relationship are generated. The second directed graph determines whether there are circular dependencies, outputs alarm information and records service version information.

Benefits of technology

It realizes the automatic detection of cyclic dependencies in microservice systems, solves the problem of manual detection being difficult to process large amounts of data and easy to miss detection, and can effectively detect whether there are cyclic dependencies in microservice systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114416564B
    Figure CN114416564B
Patent Text Reader

Abstract

The embodiment of the present application is to provide a method and system for detecting circular dependencies in a microservice system, which belongs to the field of microservice systems. The detection method includes: in response to a circular dependency detection request for the microservice system, executing a first circular dependency detection task and a second circular dependency detection task; wherein, executing the first circular dependency detection task includes: obtaining the call information reported by each service that executes the same request task in the microservice system; based on the call information reported by each service, generating a first directed graph representing the service flow of each service that executes the request task; based on the first directed graph, determining whether there is a circular dependency in the request task; based on the second directed graph representing the call relationship of each service; determining whether there is a circular dependency between the multiple services. The present application aims to detect circular dependencies in a microservice system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the field of microservice systems, and more specifically, to a method and system for detecting circular dependencies in a microservice system. Background Art

[0002] Microservices are a very popular software architecture currently, and are widely used in the development of distributed systems. Microservices split a complete system into several smaller service units, each of which calls other service units through network interfaces to jointly complete business functions. Microservice architecture advocates splitting services into small and independent units. A software system often has many service units, and most business needs require the cooperation of multiple service units to complete. Microservice architecture advocates splitting service units into small and independent units. A software system often has many service units, and most business needs require the cooperation of multiple service units to complete.

[0003] The main advantages of microservices all come from one principle, that is, independent deployability; independent deployability requires that each service can fully control its own development, deployment, and operation and maintenance. To achieve this, the most important thing is to avoid circular dependencies between services. Assume that service A and service B have a circular dependency. When either A or B needs to release a new function or crashes due to an abnormal situation, it will affect the other's function, so the two services must coordinate consistent lifecycle operations.

[0004] In the prior art, the method for detecting whether there is a circular dependency in a microservice system is mainly through manual detection, which lists all services within a service cycle of the microservice system and then analyzes these services one by one; this method requires a lot of manpower and is prone to missed detection; when the service volume in the microservice system reaches a certain level, the manual detection method cannot perform detection. Summary of the invention

[0005] The embodiments of the present application provide a method and system for detecting circular dependencies in a microservice system, aiming to detect circular dependencies in the microservice system.

[0006] In a first aspect, an embodiment of the present application provides a method for detecting circular dependencies in a microservice system, the method comprising:

[0007] In response to a circular dependency detection request for the microservice system, executing a first circular dependency detection task and a second circular dependency detection task;

[0008] The step of executing the first circular dependency detection task includes:

[0009] Obtain the call information reported by each service that executes the same request task in the microservice system, including the current timestamp of each service executing the request task, the service ID of the service, and the service IDs of other services to be called by the service;

[0010] Generate a first directed graph representing the service flow of each service executing the requested task based on the current timestamp of each service executing the requested task, the service identifier of the service, and the service identifiers of other services to be called by the service in the call information reported by each service;

[0011] Based on the first directed graph, determining whether the requested task has a circular dependency;

[0012] The step of executing the second circular dependency detection task includes:

[0013] Obtain the service identifier of each service execution request task in the microservice system, as well as the service identifiers of other services to be called by the service;

[0014] Based on the service identifier of each service execution request task and the service identifiers of other services to be called by the service, a second directed graph representing the calling relationship of the services is generated;

[0015] Based on the second directed graph, it is determined whether there is a circular dependency between the multiple services.

[0016] Optionally, obtaining call information reported by each service executing the same request task in the microservice system includes:

[0017] Whenever a service in the microservice system calls an interface of another service, the other service detects whether there is a unique identifier in the call request of the service;

[0018] If it does not exist, a unique identifier is generated and placed in the service;

[0019] If it exists, the unique identifier is placed in the call request generated by another service;

[0020] Obtain call information of all services with the same unique identifier.

[0021] Optionally, the generating a first directed graph representing the service flow of each service executing the requested task based on the current timestamp of each service executing the requested task, the service identifier of the service, and the service identifiers of other services to be called by the service in the call information reported by each service, includes:

[0022] Create a group, and put the call information reported by each service into the group;

[0023] Arrange the multiple call information in the group in sequence according to the sequence of the current timestamps;

[0024] The service identifiers of the calling service and the service identifiers of the called service in the plurality of calling information are sequentially connected according to the arrangement order to obtain the first directed graph.

[0025] Optionally, the generating a first directed graph representing the service flow of each service executing the requested task based on the current timestamp of each service executing the requested task, the service identifier of the service, and the service identifiers of other services to be called by the service in the call information reported by each service, includes:

[0026] Create a group, and put the call information reported by each service into the group;

[0027] The order of the current timestamps in the case is used to arrange the multiple call information in the group in order;

[0028] The service identifiers of the calling service and the service identifiers of the called service in the plurality of calling information are sequentially connected according to the arrangement order to obtain the first directed graph.

[0029] Optionally, the generating of a second directed graph representing the calling relationship of each service based on the service identifier of each service execution request task and the service identifiers of other services to be called by the service includes:

[0030] According to the service calling relationship between other services called by each service, the service identifiers of the services are connected, wherein the service identifier of the calling service is connected to the service identifier of the called service, to obtain the second directed graph.

[0031] Optionally, determining whether there is a circular dependency between the multiple services based on the second directed graph includes:

[0032] Traversing the second directed graph, and determining whether there is a connection relationship between two services with the same service identifier in the second directed graph;

[0033] If so, there is a circular dependency in the microservice system.

[0034] Optionally, the method further comprises:

[0035] When it is detected that the request task has a circular dependency, outputting a first warning message;

[0036] When it is detected that there is a circular dependency in the second directed graph, second alarm information of the service with the circular dependency is output.

[0037] Optionally, the method further comprises:

[0038] Each time the second alarm information is output, current service version information of the circularly dependent service in the second directed graph is obtained;

[0039] The current service version information obtained when the second alarm information is output multiple times is compared to determine the version of the service with circular dependency.

[0040] In a second aspect, an embodiment of the present application provides a circular dependency detection system in a microservice system, including a first acquisition module, a first directed graph generation module, a second acquisition module, a second directed graph generation module, a circular dependency judgment module, an alarm module and a record comparison module, wherein:

[0041] The first acquisition module is used to obtain the call information reported by each service that executes the same request task in the microservice system, the current timestamp of each service executing the request task, the service identifier of the service, and the service identifiers of other services to be called by the service;

[0042] A first directed graph generation module, configured to generate a first directed graph representing the service flow of each service executing the requested task based on the current timestamp of each service executing the requested task, the service identifier of the service, and the service identifiers of other services to be called by the service in the call information reported by each service;

[0043] The second acquisition module is used to obtain the service identifier of each service execution request task in the microservice system, and the service identifiers of other services to be called by the service;

[0044] A second directed graph generating module, configured to generate a second directed graph representing the calling relationship of each service based on the service identifier of each service execution request task and the service identifiers of other services to be called by the service;

[0045] A circular dependency judgment module, used to determine whether there is a circular dependency between the request task based on the first directed graph; used to determine whether there is a circular dependency between the multiple services based on the second directed graph;

[0046] An alarm module, configured to output a first alarm message when a circular dependency is detected in the request task; and output a second alarm message of a service with a circular dependency when a circular dependency is detected in the second directed graph;

[0047] The record comparison module is used to compare the current service version information of the service with circular dependency when outputting the second alarm information; if the current service version information of the service with circular dependency is inconsistent, report the record.

[0048] Beneficial effect: The present application divides the circular dependency detection into two categories, namely, a first circular dependency detection task and a second circular dependency detection task, when detecting circular dependencies in a microservice system. The first circular dependency detection task is used to detect whether there is a circular dependency between requests that execute the same request task in the microservice system, and the second circular dependency detection task is used to detect whether there is a circular dependency between multiple services in the microservice system. During the detection, a first directed graph representing the service flow of each service that executes the request task and a second directed graph representing the calling relationship between each service in the microservice system are respectively generated, and then the calling relationship existing in the first directed graph and the second directed graph is judged to complete the circular dependency detection. Thereby, the problem that it is difficult to detect and easy to miss when manually detecting circular dependencies in the face of large amounts of data is solved, and the effect of being able to detect whether there is a circular dependency in a microservice system in the face of large amounts of data is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0050] Figure 1 is a flowchart of the steps of the detection method proposed in one embodiment of the present application;

[0051] Figure 2 are structures of two first directed graphs proposed in one embodiment of the present application;

[0052] Figure 3 are structures of two second directed graphs proposed in one embodiment of the present application;

[0053] Figure 4 It is a schematic diagram of the structure of a detection system proposed in another embodiment of the present application. DETAILED DESCRIPTION

[0054] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0055] Embodiment 1

[0056] Reference Figure 1, which shows a flowchart of the steps of a method for detecting circular dependencies in a microservice system in an embodiment of the present invention, such as Figure 1 As shown, the detection method may include the following steps:

[0057] S1, in response to a circular dependency detection request for the microservice system, executing a first circular dependency detection task and a second circular dependency detection task;

[0058] In this embodiment, the circular dependencies in the microservice system are divided into two categories, and the first circular dependency detection task and the second circular dependency detection task are used to detect the two types of circular dependencies in the microservice system. The first circular dependency detection task is to detect whether there is a circular dependency between multiple services that execute the same request task in the microservice system, and the second circular dependency detection task is to detect whether there is a circular dependency between multiple services that execute multiple request tasks in the same microservice system.

[0059] S11, wherein executing the first circular dependency detection task includes:

[0060] S111, obtaining the call information reported by each service executing the same request task in the microservice system, the current timestamp of each service executing the request task, the service identifier of the service, and the service identifiers of other services to be called by the service;

[0061] When a microservice system executes a request task, often a request task requires the cooperation of multiple services to complete, and multiple services executing the same request task call each other through the network interface; the first circular dependency detection task is used to detect whether there is a circular dependency between the services executing the same request task in the microservice system.

[0062] S112, generating a first directed graph representing the service flow of each service executing the requested task based on the current timestamp of each service executing the requested task, the service identifier of the service, and the service identifiers of other services to be called by the service in the call information reported by each service;

[0063] The first directed graph is generated by using the current timestamps and service identifiers of multiple services, and can provide feedback on the service flow between multiple services that execute the same request task.

[0064] S113, determining whether the requested task has a circular dependency based on the first directed graph;

[0065] The first directed graph lists the relationships between multiple services that implement the same request task. By analyzing the first directed graph, it is possible to determine whether there is a circular dependency between the multiple services that execute the same request task.

[0066] S12, wherein executing the second circular dependency detection task includes:

[0067] S121, obtaining the service identifier of each service execution request task in the microservice system and the service identifiers of other services to be called by the service;

[0068] The connection between multiple services in the microservice system can be determined by the service identifier of each service execution request task in the microservice system and the service identifiers of other services to be called by the service.

[0069] S122, generating a second directed graph representing the calling relationship of each service based on the service identifier of each service execution request task and the service identifiers of other services to be called by the service;

[0070] S123: Determine whether there is a circular dependency between the multiple services based on the second directed graph.

[0071] The second directed graph lists the relationships between multiple services that execute multiple request tasks in the same microservice system. By analyzing the second directed graph, it is possible to determine whether there is a circular dependency between multiple services in the same microservice system.

[0072] This embodiment, when detecting circular dependencies in a microservice system, first divides the circular dependency detection into two categories: a first circular dependency detection task and a second circular dependency detection task, wherein the first circular dependency detection task is used to detect whether there is a circular dependency between requests that execute the same request task in the microservice system, and the second circular dependency detection task is used to detect whether there is a circular dependency between multiple services in the microservice system; during the detection, by respectively generating a first directed graph representing the service flow of each service that executes the request task and a second directed graph representing the call relationship between each service in the microservice system, and then judging the call relationship existing in the first directed graph and the second directed graph, the circular dependency detection is completed; thereby solving the problem that it is difficult to detect and easy to miss when manually detecting circular dependencies in the face of a large amount of data, and having the effect of being able to detect whether there is a circular dependency in the microservice system in the face of a large amount of data.

[0073] Embodiment 2

[0074] Reference Figure 1 As shown, a flowchart of a method for detecting a circular dependency in a microservice system in an embodiment of the present application is shown. Figure 1 As shown, the detection method may specifically include the following steps:

[0075] S1, in response to a circular dependency detection request for the microservice system, executing a first circular dependency detection task and a second circular dependency detection task;

[0076] A microservice system splits a complete system into several smaller services. Each service calls other services through a network interface to jointly complete business functions.

[0077] The circular dependency in the microservice system means: if a request task requires service A, service B and service C; service A calls the interface provided by service B, and service B needs to call the interface of service A. At this time, since service A needs to call the interface of B, that is, the ability of service A depends on the ability of service B, and service B needs to call the interface of service A, it means that service B depends on service A, which constitutes a circular dependency. Circular dependency occurs not only between two services, but also between multiple services. For example, service A depends on service B, service B depends on service C, and service C depends on service A, which will also form a circular dependency. This circular dependency exists between various services in the microservice system that perform the same request task.

[0078] There is another type of circular dependency. If multiple request tasks are executed in a microservice system, service A in one of the request tasks needs to call the interface provided by service B of another request task when executing, and service B needs to call the interface of service C of the third request task, and service C needs to call the interface of service A; then, service A, service B and service C also form a circular dependency. Circular dependency occurs not only between two services executing the same request task, but also between multiple services executing different request tasks in a microservice system.

[0079] S11, wherein executing the first circular dependency detection task includes:

[0080] S101, obtaining the call information reported by each service executing the same request task in the microservice system, the current timestamp of each service executing the request task, the service identifier of the service, and the service identifiers of other services to be called by the service;

[0081] When obtaining the call information reported by each service that executes the same request task in the microservice system, it is obtained through the interface provided by the microservice system; if the microservice system uses Spring Cloud, it is obtained through the Filter in Javaweb; if the microservice system uses Service Mesh, it is obtained through Sidecar.

[0082] In this embodiment, a unique identifier is set to determine whether each service of the microservice system is in the same request task.

[0083] The process of setting a unique identifier is as follows:

[0084] Obtaining the call information reported by each service that executes the same request task in the microservice system, including:

[0085] Whenever a service in the microservice system calls an interface of another service, the other service detects whether there is a unique identifier in the call request of the service;

[0086] If it does not exist, a unique identifier is generated and placed in the service;

[0087] When there is no unique identifier in the service, it means that the service may be the starting point of the execution cycle of the same request task, and a new unique identifier needs to be generated;

[0088] If it exists, the unique identifier is placed in the call request generated by another service;

[0089] When a unique identifier exists in a service, it indicates that the service may be an intermediate node in the same request task execution cycle. The unique identifier in the service is transmitted through the previous node in the same request task execution cycle. The unique identifier is then transmitted to the next service through a call request.

[0090] Obtain call information of all services with the same unique identifier.

[0091] In this embodiment, when a request task requires multiple services to process in sequence, the first service generates a unique identifier, and then puts the unique identifier into the call request, and calls the interface of the second service through the call request. After receiving the call request, the second service first obtains the unique identifier from the call request, and then puts the unique identifier into the call request, and calls the interface of the third service through the call request. In the process of transmitting the unique identifier, if the call request received by the second service does not contain the unique identifier, the first service that issues the call request is the starting point of the same request task cycle, and the second service generates a unique identifier and puts it into the first service; if it exists, the first service that issues the call request is the intermediate node of the same request task cycle, and the second service only needs to put the unique identifier into the call request generated by itself to pass the unique identifier to the third service.

[0092] By obtaining all services with the same unique identifier, it is possible to obtain the call information of each service that executes the same request task; this part of the call information can provide basic data for determining the circular dependencies between the various services that execute the same request task in the microservice system.

[0093] S102, generating a first directed graph representing the service flow of each service executing the requested task based on the current timestamp of each service executing the requested task, the service identifier of the service, and the service identifiers of other services to be called by the service in the call information reported by the various services;

[0094] In this embodiment, the call information reported by each service is the basic data for detecting whether there is a circular dependency in the microservice system. In the first circular dependency detection task, the detection target is the circular dependency between the various services that execute the same request task in the microservice system; based on the characteristics of the circular dependency between the various services that execute the same request task in the microservice system, the first step of the detection is to generate a first directed graph, which can represent the service flow of each service that executes one of the request tasks in the microservice system.

[0095] Wherein, generating the first directed graph comprises the following steps:

[0096] Create a group, and put the call information reported by each service into the group;

[0097] In a microservice system, multiple request tasks may be executed at the same time, and multiple request tasks are executed by multiple services. By establishing groups and then putting the call information reported by each service into the group, the group only contains the call information of the service required to execute one of the request tasks. This part of the call information is distinguished by a unique identifier.

[0098] Arrange the multiple call information in the group in sequence according to the sequence of the current timestamps;

[0099] The current timestamp is the time when each service is executed in the microservice system. By sorting the current timestamps, the calling order of multiple services that execute the same request task can be arranged.

[0100] The service identifiers of the calling service and the service identifiers of the called service in the plurality of calling information are sequentially connected according to the arrangement order to obtain the first directed graph.

[0101] like Figure 2 As shown, Figure 2 The structure of two first directed graphs in the embodiment of the present application is shown; in the microservice system, there is a request task consisting of service 1, service 2, service 3 and service 4; the service identifier of service 1 is service 1, the service identifier of service 2 is service 2, the service identifier of service 3 is service 3, and the service identifier of service 4 is service 4; the first directed graph drawn based on service 1, service 2, service 3 and service 4 is as shown in Figure 2 As shown in a and b.

[0102] By successively connecting multiple services that execute the same request task, the first directed graph obtained can feedback the service flow of each service that executes one of the request tasks in the microservice system.

[0103] S103, based on the first directed graph, determining whether the requested task has a circular dependency, including:

[0104] Traversing the first directed graph, and determining whether there is a connection relationship between two services with the same service identifier in the first directed graph;

[0105] If so, there is a circular dependency in the request task.

[0106] like Figure 2 As shown in a, in the first directed graph, service 2 calls service 1, service 3 calls service 2, and service 4 calls service 3. There is no connection relationship between two services with the same service identifier, so in Figure 2 There is no circular dependency in a.

[0107] like Figure 2 As shown in b, in the first directed graph, service 2 calls service 1, service 3 calls service 2, service 4 calls service 3, and service 1 calls service 4. There is a connection relationship between two services with the same service identifier. Figure 2 There is a circular dependency in b. The circular dependency starts from the service with the larger current timestamp of the two services with the same service ID and ends at the service with the smaller current timestamp. Figure 2 As shown in b, the circular dependency starts from service 1 at the top and ends at service 1 at the bottom.

[0108] S12, wherein executing the second circular dependency detection task includes:

[0109] S121, obtaining the service identifier of each service execution request task in the microservice system and the service identifiers of other services to be called by the service;

[0110] When a microservice system is running, there are often multiple request tasks that need to be executed in a microservice system, and one request task requires the cooperation of multiple services to complete; therefore, in a microservice system, there may be a large number of services at the same time, and multiple services that execute different request tasks can call each other through a network interface; in this embodiment, the second circular dependency detection task is used to detect whether there is a circular dependency between the services in the microservice system, and is not limited to whether these services are executing the same request task.

[0111] S122, based on the service identifier of each service execution request task and the service identifiers of other services to be called by the service, generating a second directed graph representing the calling relationship of the services; including:

[0112] According to the service calling relationship between other services called by each service, the service identifiers of the services are connected, wherein the service identifier of the calling service is connected to the service identifier of the called service, to obtain the second directed graph.

[0113] By connecting the service call relationships between other services called by each service, the second directed graph obtained can reflect the relationship between multiple services that execute multiple request tasks in the same microservice system.

[0114] S123: Determine whether there is a circular dependency between the multiple services based on the second directed graph.

[0115] Traversing the second directed graph, and determining whether there is a connection relationship between two services with the same service identifier in the second directed graph;

[0116] If so, there is a circular dependency in the microservice system.

[0117] like Figure 3 As shown, Figure 3 The structures of two second directed graphs in the embodiments of the present application are shown; and Figure 3 The second directed graph in is obtained through step S122; if there are five services, namely, service A, service B, service C, service D and service E, in the microservice system, these five services serve different request tasks respectively, but there is a calling relationship between them.

[0118] like Figure 3 As shown in a, service A calls the interface of service C, service C calls the interface of service D, service D calls the interface of service E, service E calls the interface of service B, and service B calls the interface of service A. Among these five services, there is a calling mode of A—>C—>D—>B—>E—>A. Because the service identifier of service A appears twice in the second directed graph, there is a connection relationship between the two services with the same service identifier; therefore, there is a circular dependency in the microservice system.

[0119] like Figure 3 As shown in b, service A calls the interface of service C, service C calls the interface of service D, service E calls the interface of service D, service E calls the interface of service B, and service B calls the interface of service A; Figure 3In the second directed graph a, there are two service calling methods: B—>A—>C—>D and E—>D. However, in neither of these two calling methods does a service identifier appear twice in the second directed graph. Therefore Figure 3 In b, there is no connection relationship between two services with the same service identifier, and there is a circular dependency in the microservice system.

[0120] In this embodiment, the detection method further includes:

[0121] When it is detected that the request task has a circular dependency, outputting a first warning message;

[0122] When it is detected that there is a circular dependency in the second directed graph, second alarm information of the service with the circular dependency is output.

[0123] The first alarm information and the second alarm information can remind the maintenance personnel of the microservice system that there is a circular dependency in the current microservice system, and the second alarm information can remind the maintenance personnel of the microservice system in which request task the circular dependency is located.

[0124] Each time the second alarm information is output, current service version information of the circularly dependent service in the second directed graph is obtained;

[0125] The current service version information obtained when the second alarm information is output multiple times is compared to determine the version of the service with circular dependency.

[0126] The second alarm information is used to remind maintenance personnel that there is a circular dependency in the current microservice system. If there is a circularly dependent service, the current service version information is obtained. The current service version information can determine the version of the service with the circular dependency. When maintaining the microservice system, the maintenance personnel can use the current service version information to judge the version of the circular dependency in the service, and prompt the service that generates the circular dependency, from which version the circular dependency appears, and to which version of the service the circular dependency continues, so as to perform maintenance.

[0127] This embodiment, when detecting circular dependencies in a microservice system, first divides the circular dependency detection into two categories: a first circular dependency detection task and a second circular dependency detection task, wherein the first circular dependency detection task is used to detect whether there is a circular dependency between requests that execute the same request task in the microservice system, and the second circular dependency detection task is used to detect whether there is a circular dependency between multiple services in the microservice system; during the detection, by respectively generating a first directed graph representing the service flow of each service that executes the request task and a second directed graph representing the call relationship between each service in the microservice system, and then judging the call relationship existing in the first directed graph and the second directed graph, the circular dependency detection is completed; thereby solving the problem that it is difficult to detect and easy to miss when manually detecting circular dependencies in the face of a large amount of data, and having the effect of being able to detect whether there is a circular dependency in the microservice system in the face of a large amount of data.

[0128] Embodiment 3

[0129] Based on the same inventive concept, Figure 4 A schematic diagram of the structure of a circular dependency detection system in a microservice system is shown, referring to Figure 4 As shown, the detection system includes a first acquisition module, a first directed graph generation module, a second acquisition module, a second directed graph generation module, a circular dependency judgment module, an alarm module and a record comparison module, wherein:

[0130] The first acquisition module is used to obtain the call information reported by each service that executes the same request task in the microservice system, the current timestamp of each service executing the request task, the service identifier of the service, and the service identifiers of other services to be called by the service;

[0131] A first directed graph generation module, configured to generate a first directed graph representing the service flow of each service executing the requested task based on the current timestamp of each service executing the requested task, the service identifier of the service, and the service identifiers of other services to be called by the service in the call information reported by each service;

[0132] The second acquisition module is used to obtain the service identifier of each service execution request task in the microservice system, and the service identifiers of other services to be called by the service;

[0133] A second directed graph generating module, configured to generate a second directed graph representing the calling relationship of each service based on the service identifier of each service execution request task and the service identifiers of other services to be called by the service;

[0134] A circular dependency judgment module is used to determine whether there is a circular dependency in the request task based on the first directed graph; and is used to determine whether there is a circular dependency between the multiple services based on the second directed graph.

[0135] The alarm module is used to output a first alarm message when a circular dependency is detected in the request task; and to output a second alarm message of a service with a circular dependency when a circular dependency is detected in the second directed graph.

[0136] The record comparison module is used to compare the current service version information of the service with circular dependency when outputting the second alarm information; if the current service version information of the service with circular dependency is inconsistent, report the record.

[0137] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0138] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0139] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0140] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0141] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0142] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0143] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.

[0144] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal 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 terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0145] Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for detecting circular dependencies in a microservice system, characterized in that: The method comprises: In response to a circular dependency detection request for the microservice system, executing a first circular dependency detection task and a second circular dependency detection task; The step of executing the first circular dependency detection task includes: Obtain the call information reported by each service that executes the same request task in the microservice system, including the current timestamp of each service executing the request task, the service ID of the service, and the service IDs of other services to be called by the service; Based on the current timestamp of each service executing the requested task, the service identifier of the service, and the service identifiers of other services to be called by the service in the call information reported by the services, a first directed graph representing the service flow of each service executing the requested task is generated, including: creating a group, putting the call information reported by the services into the group; arranging the multiple call information in the group in sequence according to the sequence of the current timestamps; and connecting the service identifiers of the calling service and the service identifiers of the called service in the multiple call information in sequence according to the sequence to obtain the first directed graph; Based on the first directed graph, determining whether the request task has a circular dependency includes: traversing the first directed graph to determine whether there is a connection relationship between two services with the same service identifier in the first directed graph; if so, there is a circular dependency in the request task; The step of executing the second circular dependency detection task includes: Obtain the service identifier of each service execution request task in the microservice system, as well as the service identifiers of other services to be called by the service; Based on the service identifier of each service execution request task and the service identifiers of other services to be called by the service, a second directed graph representing the calling relationship of the services is generated, including: according to the service calling relationship between other services called by each service, the service identifiers of the services are connected, wherein the service identifier of the calling service is connected to the service identifier of the called service, to obtain the second directed graph; Based on the second directed graph, determining whether there is a circular dependency between the multiple services includes: traversing the second directed graph to determine whether there is a connection relationship between two services with the same service identifier in the second directed graph; if so, there is a circular dependency in the microservice system.

2. According to a method for detecting circular dependencies in a microservice system according to claim 1, it is characterized in that: Obtaining the call information reported by each service that executes the same request task in the microservice system, including: Whenever a service in the microservice system calls the interface of another service, the other service detects whether there is a unique identifier in the call request of the service; If it does not exist, a unique identifier is generated and placed in the service; If it exists, the unique identifier is placed in the call request generated by another service; Obtain call information of all services with the same unique identifier.

3. A method for detecting circular dependencies in a microservice system according to any one of claims 1-2, characterized in that: The method further comprises: When it is detected that the request task has a circular dependency, outputting a first warning message; When it is detected that there is a circular dependency in the second directed graph, second alarm information of the service with the circular dependency is output.

4. A method for detecting circular dependencies in a microservice system according to claim 3, characterized in that: The method further comprises: Each time the second alarm information is output, current service version information of the circularly dependent service in the second directed graph is obtained; The current service version information obtained when the second alarm information is output multiple times is compared to determine the version of the service with circular dependency.

5. A circular dependency detection system in a microservice system, characterized in that: It includes a first acquisition module, a first directed graph generation module, a second acquisition module, a second directed graph generation module, a circular dependency judgment module, an alarm module and a record comparison module, wherein: The first acquisition module is used to obtain the call information reported by each service that executes the same request task in the microservice system, the current timestamp of each service executing the request task, the service identifier of the service, and the service identifiers of other services to be called by the service; A first directed graph generation module is used to generate a first directed graph representing the service flow of each service that executes the requested task based on the current timestamp of each service executing the requested task, the service identifier of the service, and the service identifiers of other services to be called by the service in the call information reported by each service, including: creating a group, putting the call information reported by each service into the group; arranging multiple call information in the group in sequence according to the sequence of the current timestamps; and connecting the service identifiers of the calling service and the service identifiers of the called service in the multiple call information in sequence according to the arrangement order to obtain the first directed graph; The second acquisition module is used to obtain the service identifier of each service execution request task in the microservice system, and the service identifiers of other services to be called by the service; A second directed graph generating module is used to generate a second directed graph representing the calling relationship of each service based on the service identifier of each service execution request task and the service identifiers of other services to be called by the service, including: connecting the service identifiers of each service according to the service calling relationship between other services called by each service, wherein the service identifier of the calling service is connected to the service identifier of the called service to obtain the second directed graph; A circular dependency judgment module, used to determine whether there is a circular dependency in the request task based on the first directed graph, including: traversing the first directed graph to determine whether there is a connection relationship between two services with the same service identifier in the first directed graph; if so, there is a circular dependency in the request task; used to determine whether there is a circular dependency between multiple services based on the second directed graph, including: traversing the second directed graph to determine whether there is a connection relationship between two services with the same service identifier in the second directed graph; if so, there is a circular dependency in the microservice system; An alarm module, configured to output a first alarm message when a circular dependency is detected in the request task; and output a second alarm message of a service with a circular dependency when a circular dependency is detected in the second directed graph; The record comparison module is used to compare the current service version information of the circularly dependent service when outputting the second alarm information; if the current service version information of the circularly dependent service is inconsistent, report the record.