A microservice system and a microservice registration, discovery and keep-alive method
By introducing controller and proxy modules into the microservice system, hijacking and filtering messages, and implementing message conversion and routing, the problem of heavy pressure on a unified registration center is solved and the performance and stability of the microservice system is improved.
Patent Information
- Application Number
- CN202011479245.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-15
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2040-12-15
AI Technical Summary
In microservice systems, with the expansion of system scale and the increase of heterogeneous microservice frameworks, unified registration centers have poor performance under storage and push pressure, affecting system stability.
The controller and proxy module are adopted to issue preset control policies to the service-side agent and the registration center-side agent through the policy maintenance module, so that the proxy module can hijack and filter messages, realize message conversion and routing, and avoid centralized processing in the unified registration center.
Reduces unnecessary service registration and release traffic, reduces storage and push pressure on the registry center, and improves the performance and reliability of the microservice system.
Smart Images

Figure CN114650317B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a microservice system, a microservice registration method, a microservice discovery method, a microservice keep-alive method and related equipment. Background Art
[0002] In a microservice system, different services call each other through remote communication. In this way, service consumers need to know information such as the address and port of the service provider before accessing other service providers.
[0003] With the expansion of system scale and technological iteration, there are often multiple microservice frameworks (i.e. heterogeneous microservice frameworks) in microservice systems, and different microservice frameworks cannot communicate directly. In order to solve the problem of service intercommunication between heterogeneous microservice frameworks, the current mainstream solution is: add a centralized unified registration center, through which registration information sent by microservices in different microservice frameworks is received; and according to the pre-set information conversion method between different microservice frameworks, the registration information is converted and registered to the registration center of each microservice framework; so that each registration center sends a service list to the microservice of this framework after receiving the subscription request sent by the microservice of this framework; and then the microservice of this framework calls other microservices of this framework or microservices of other frameworks based on the service list.
[0004] However, when the scale of the service cluster is very large, the unified registration center needs to store the addresses of a large number of microservices, and the unified registration center needs to be responsible for registering the microservices in each microservice framework to the registration center in each microservice framework. As a result, the unified registration center has excessive storage and push pressure, which will cause poor performance problems such as the stability of the microservice system. Summary of the invention
[0005] The embodiments of the present invention provide a microservice system, a microservice registration method, a microservice discovery method, a microservice keep-alive method and related devices, which can improve the performance of the microservice system.
[0006] To solve the above technical problems, the present invention is achieved as follows:
[0007] In a first aspect, an embodiment of the present invention provides a microservice system, including:
[0008] N microservices, where N is an integer greater than 1;
[0009] M registration centers, where M is an integer greater than 1;
[0010] a controller; and,
[0011] An agent module connected to the controller, the agent module comprising a service-side agent connected to the N microservices and a registration center-side agent connected to the M registration centers, and the service-side agent is connected to the registration center-side agent respectively;
[0012] Wherein, the controller comprises: a policy maintenance module, the policy maintenance module is used to send a first preset control policy to the service side agent, and send a second preset control policy to the registration center side agent;
[0013] The service-side proxy comprises: a service-side policy filtering unit and a service-side protocol conversion unit, wherein the service-side policy filtering unit filters the sent or received message based on the first preset control policy to forward the sent or received message to a message receiver matching the first preset control policy; the service-side protocol conversion module is used to convert the received message into a data format understandable to the message receiver;
[0014] The registration center side agent includes: a registration center side policy filtering unit and a registration center side protocol conversion unit, wherein the registration center side policy filtering unit filters the sent or received messages based on the second preset control policy to forward the sent or received messages to the message recipient that matches the second preset control policy; the registration center side protocol conversion module is used to convert the received message into a data format that can be understood by the message recipient.
[0015] In a second aspect, an embodiment of the present invention further provides a microservice registration method, the method comprising:
[0016] The target microservice sends a registration request;
[0017] The service-side agent hijacks the registration request, and based on a first preset control strategy, determines a target registration center of the registration request, and converts the registration request into protocol data corresponding to the target registration center;
[0018] The service-side agent sends the registration request to the target registration center through the registration center-side agent.
[0019] In a third aspect, an embodiment of the present invention further provides a microservice discovery method, the method comprising:
[0020] The first microservice sends a service discovery request;
[0021] The service-side agent hijacks the service discovery request, and based on a first preset control strategy, determines a target registration center corresponding to the service discovery request, and converts the service discovery request into protocol data corresponding to the target registration center;
[0022] The service-side agent sends the service discovery request to the registration center-side agent, so that the service discovery request is sent to the target registration center through the registration center-side agent;
[0023] The target registry returns a service list in response to the service discovery request, and the service list is sent to the first microservice through the registry-side agent and the service-side agent.
[0024] In a fourth aspect, an embodiment of the present invention further provides a microservice keep-alive method, the method comprising:
[0025] The registration center side agent hijacks the status detection request sent by the target registration center to the service side agent, converts the status detection request into the protocol data corresponding to the service side agent, and sends it to the service side agent;
[0026] In the case where the status detection request complies with the first preset control strategy, the service-side agent detects the working status of the target microservice based on the status detection request, and feeds back the working status of the target microservice to the target registration center through the registration center-side agent;
[0027] or,
[0028] The service-side agent actively sends a service keep-alive request that can be understood by the target registration center to the target registration center based on a first preset control strategy;
[0029] The registration center-side proxy hijacks the service keep-alive request, and sends the service keep-alive request to the target registration center if the service keep-alive request complies with a second preset control policy.
[0030] In a fifth aspect, an embodiment of the present invention further provides a microservice registration device, including:
[0031] A first sending module, used to send a registration request through a target microservice;
[0032] A first data processing module, configured to hijack the registration request through a service-side proxy, determine a target registration center of the registration request based on a first preset control strategy, and convert the registration request into protocol data corresponding to the target registration center;
[0033] The second sending module is used to send the registration request to the target registration center through a registration center-side agent.
[0034] In a sixth aspect, an embodiment of the present invention further provides a microservice discovery device, including:
[0035] A third sending module is used to send a service discovery request through the first microservice;
[0036] A second data processing module is used to hijack the service discovery request through a service-side proxy, and based on a first preset control strategy, determine a target registration center corresponding to the service discovery request, and convert the service discovery request into protocol data corresponding to the target registration center;
[0037] A fourth sending module, configured to send the service discovery request to the registration center side agent through the service side agent, so as to send the service discovery request to the target registration center through the registration center side agent;
[0038] The fifth sending module is used to return a service list in response to the service discovery request through the target registration center, and the service list is sent to the first microservice through the registration center side agent and the service side agent.
[0039] In a seventh aspect, an embodiment of the present invention further provides a microservice keep-alive device, the microservice keep-alive device comprising: a third data processing module and a detection module, and / or the microservice keep-alive device comprising: a sixth sending module and a fourth data processing module;
[0040] The third data processing module is used to hijack the status detection request sent by the target registration center to the service side agent through the registration center side agent, and convert the status detection request into protocol data corresponding to the service side agent and send it to the service side agent;
[0041] The detection module is used to enable the service-side agent to detect the working status of the target microservice based on the status detection request when the status detection request meets the first preset control strategy, and to feedback the working status of the target microservice to the target registration center through the registration center-side agent;
[0042] The sixth sending module is used to actively send a service keep-alive request that can be understood by the target registration center to the target registration center through the service-side agent based on the first preset control strategy;
[0043] The fourth data processing module is used to hijack the service keep-alive request through the registration center-side agent, and send the service keep-alive request to the target registration center if the service keep-alive request complies with the second preset control policy.
[0044] In the eighth aspect, an embodiment of the present invention further provides a microservice system, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the service registration method as described in the second aspect, or, when executed by the processor, implements the steps of the service discovery method as described in the third aspect, or, when executed by the processor, implements the steps of the service keep-alive method as described in the fourth aspect.
[0045] In the ninth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by the processor, the steps of the service registration method as described in the second aspect are implemented, or, when the computer program is executed by the processor, the steps of the service discovery method as described in the third aspect are implemented, or, when the computer program is executed by the processor, the steps of the service keep-alive method as described in the fourth aspect are implemented.
[0046] In an embodiment of the present invention, N microservices, M registration centers, a controller, a service-side agent corresponding to the microservices, and a registration center-side agent corresponding to the registration center are set in a microservice system, so that a first preset control strategy is issued to the service-side agent through the control center, and a second preset control strategy is issued to the registration center-side agent. In this way, in the process of microservice registration, discovery or call, each service-side agent can hijack the message sent by the corresponding microservice based on the first preset control strategy, and find the message recipient corresponding to the message, so as to convert the message into a data format that the message recipient (microservice or registration center) can understand and send it to the message recipient; the registration center-side agent on the other side can hijack the message received by the corresponding registration center based on the second preset control strategy, and send the message to the corresponding registration center only when the message meets the second preset control strategy. In this way, there is no need to set up a unified registration center. Instead, the proxy module is used to determine the message recipient and be responsible for the protocol data conversion function, so that the message sent by the microservice can be sent to the designated registration center, or the microservice only receives the message sent by the designated registration center, controls the transmission and storage of messages in the network, reduces the performance requirements for the device, and thus improves the reliability of the microservice system. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0048] Figure 1 is a structural diagram of a microservice system provided by an embodiment of the present invention;
[0049] Figure 2 This is a structural diagram of a registration center in a microservice system provided by an embodiment of the present invention;
[0050] Figure 3 It is a structural diagram of a service-side agent or a registration center-side agent in a microservice system provided by an embodiment of the present invention;
[0051] Figure 4a This is a data interaction diagram of a microservice system provided by an embodiment of the present invention in a first application scenario;
[0052] Figure 4b This is a data interaction diagram of a microservice system provided by an embodiment of the present invention in a second application scenario;
[0053] Figure 4c This is a data interaction diagram of a microservice system provided by an embodiment of the present invention in a third application scenario;
[0054] Figure 5 This is a flow chart of a microservice registration method provided by an embodiment of the present invention;
[0055] Figure 6 is a flow chart of a microservice discovery method provided by an embodiment of the present invention;
[0056] Figure 7 This is a flow chart of a microservice keep-alive method provided by an embodiment of the present invention;
[0057] Figure 8 is a structural diagram of a microservice registration device provided by an embodiment of the present invention;
[0058] Fig. 9 is a structural diagram of a microservice discovery device provided by an embodiment of the present invention;
[0059] Fig.10a This is one of the structural diagrams of a microservice keep-alive device provided in an embodiment of the present invention;
[0060] Fig.10b This is the second structural diagram of a microservice keep-alive device provided by an embodiment of the present invention;
[0061] Fig.11 It is a structural diagram of a microservice system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0062] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0063] In the microservice architecture, the granularity of services is very fine, which means that there are more independent services in the microservice system, and services interact through remote communication. Each microservice (referred to as "service") can be independently developed, deployed, upgraded, expanded, and restarted without affecting the final user experience, thus gaining more and more widespread applications.
[0064] In applications, if a microservice system has only a small number of services or the frequency of service deployment is low, all service addresses can be displayed through hard coding or pre-configured files. However, in the face of a microservice system that includes a large number of microservices and frequent online deployment of microservices, and the need to elastically scale the number of microservices according to load conditions, it is normal for the IP address of a microservice to change. Therefore, a mechanism needs to be provided to allow service consumers to obtain the latest microservice information in a timely manner when the IP address of the service provider changes.
[0065] In related technologies, the following process is used to enable service consumers to obtain the latest microservice information in a timely manner when the IP address of the service provider changes:
[0066] Step 1: When the service is started, the service provider registers the service name, IP address, access port and other service metadata information to the registration center;
[0067] Step 2: When the registration center and the service provider cannot maintain heartbeat detection, the service is removed from the registration center;
[0068] Step 3: The service consumer obtains the latest information of the service provider from the registration center to call the service provider based on the latest information.
[0069] However, with the emergence of heterogeneous microservice frameworks and ultra-large-scale microservice clusters, there are often multiple microservice frameworks in a microservice system. Each microservice framework corresponds to a registration center and at least one microservice, and different microservice frameworks can be configured as different network standards or different data protocols, so that a microservice cannot directly call the microservice in another microservice framework. In order to achieve service interoperability between heterogeneous microservice frameworks, related technologies often add a unified registration center to the microservice system to centrally maintain the registration process of microservices of each microservice framework through the unified registration center, that is, to achieve microservice registration and microservice calling through the following process:
[0070] In the first step, the unified registration center receives registration information sent by microservices of different microservice frameworks;
[0071] In the second step, the unified registration center converts the registration information into a data format that each microservice framework can understand according to the pre-stored information conversion method between different microservice frameworks, and sends the converted registration information to the corresponding registration center, so that the registration center of each microservice framework registers the registration information and updates the registration information of the microservice in the service list;
[0072] In the third step, when the registration center of each microservice framework receives the subscription request sent by the microservice of the microservice framework, it directly sends the service list to the microservice of the framework;
[0073] In the fourth step, the microservice of the microservice framework calls other microservices of the microservice framework or microservices of other microservice frameworks according to the received service list.
[0074] For example: when service B goes online, the address, URL interface, data format and other information of service B are reported to the unified registration center for registration in the registration center. Then, when service A needs to call service B, service A searches for the address and interface of service B through the unified registration center, and then calls service B at the address and interface.
[0075] From the above process, it can be seen that in the application scenario with a large number of microservice frameworks, the unified registration center needs to maintain the service list in each microservice framework, and needs to pre-store information such as the data format of each microservice framework to accurately convert the registration information into a data format that each microservice framework can recognize. In this way, when the microservices in the microservice system are frequently updated or frequently called across microservice frameworks, the data processing and data storage volume of the unified registration center is large, and the general unified registration center is difficult to meet the needs. When the unified registration center performs multiple tasks at the same time, it may exceed the processing capacity of the same registration center, which is easy to cause delays or errors. Therefore, it can be seen that the reliability of the microservice system in the related technology is low.
[0076] In this implementation, a controller and a proxy are added to the microservice system, so that the controller can issue control policies to the proxy, and the proxy can hijack the data traffic between the service (including service providers and service consumers) and the registration center, and filter the contacted data traffic, that is, only the hijacked message is sent to the corresponding message receiver, thereby reducing unnecessary service registration and unnecessary publishing traffic; in addition, data format conversion is implemented through the proxy on the message sender side to convert the message into a data format that the message receiver can understand, thereby avoiding centralized data format conversion of each service message in the unified registration center, which makes the storage and push pressure of the unified registration center high, and causes the problem of low reliability of the microservice system.
[0077] See also Figure 1 , is a structural diagram of a microservice system provided by an embodiment of the present invention, such as Figure 1 The microservice system includes: N microservices 11, M registration centers 12, a controller 13, and an agent module 14 connected to the controller 13, wherein N is an integer greater than 1, and M is an integer greater than 1.
[0078] The proxy module 14 includes a service-side proxy 141 connected to the N microservices 11 and a registration center-side proxy 142 connected to the M registration centers 12 , and the service-side proxy 141 is connected to the registration center-side proxy 142 respectively.
[0079] Among them, Figure 2 As shown, the controller 13 includes: a policy maintenance module 131, which is used to send a first preset control policy to the service-side agent 141 and send a second preset control policy to the registration center-side agent 142.
[0080] In implementation, the above-mentioned first preset control strategy may include the data format or data protocol of the microservice 11 connected to the service-side agent, and the registration center 12 associated with the microservice 11, etc. In this way, when the microservice 11 goes online, it only needs to be registered in the associated registration center 12, without having to register in each registration center 12, and in the process of other microservices 11 calling this microservice 11, it is only necessary to search for registration information from the associated registration center 12. In this way, unnecessary service registration and service release can be reduced to reduce resource waste.
[0081] Correspondingly, the above-mentioned second preset control strategy may include capability information of the registration center 12 to which the registration center side agent 142 is connected, for example: the number or range of service registrations that the registration center 12 can accept (including at least one of the address range and protocol range of microservices), etc. In this way, through the registration center side agent 142, the registration center 12 can receive the scope of service registration and service release according to its own capabilities.
[0082] In implementation, the service-side proxy 141 has the same structure as the registration center-side proxy 142. Figure 3 As shown, each proxy includes a policy filtering unit 15 and a protocol conversion unit 16. It should be noted that, Figure 3 In the illustrated embodiment, only the service-side proxy 141 is used as an example for illustration. In implementation, the registration center-side proxy 142 may also include a policy filtering unit 15 and a protocol conversion unit 16, which are not specifically limited here.
[0083] Specifically, the service-side agent 141 includes: a service-side policy filtering unit and a service-side protocol conversion unit, wherein the service-side policy filtering unit filters the sent or received messages based on the first preset control policy to forward the sent or received messages to a message recipient that matches the first preset control policy; the service-side protocol conversion module is used to convert the received messages into a data format that can be understood by the message recipient.
[0084] In addition, the registration center side agent includes: a registration center side policy filtering unit and a registration center side protocol conversion unit, wherein the registration center side policy filtering unit filters the sent or received messages based on the second preset control policy to forward the sent or received messages to the message recipient that matches the second preset control policy; the registration center side protocol conversion module is used to convert the received message into a data format that the message recipient can understand.
[0085] In implementation, the message sender may be any one of the microservice 11 , the registration center 12 , and the controller 13 , and the message receiver may be another one of the microservice 11 , the registration center 12 , and the controller 13 . For example: when the message sender is the target microservice 11 and the message receiver is the registration center 12, the agent on the message sender side (i.e., the service side agent 141) is used to hijack the message sent by the target microservice 11, and according to the first preset control strategy, screen out the target message receiver (i.e., the target registration center 12) from the M registration centers 12, and then convert the message into a data format that the target registration center 12 can understand, and then send the message to the target registration center 12. At this time, the agent on the target registration center side (i.e., the registration center agent 142) is used to hijack the message received by the target registration center 12, and determine whether the message meets the processing conditions of the target registration center 12 based on the second preset control strategy (for example: whether the data format of the message matches the target registration center 12, whether the target registration center 12 has sufficient capacity to process the message, etc.), and if the message meets the processing conditions of the target registration center 12, send the message to the target registration center 12. Of course, in the implementation, the message sender is the target registration center 12, and the message receiver is the microservice 11. At this time, the data interaction process between the agent on the message sender side and the agent on the message receiver side is similar to the data interaction process between the agent on the message sender side and the agent on the message receiver side when the message sender is the target microservice 11 and the message receiver is the registration center 12, and will not be repeated here.
[0086] Another example: when the message sender is the controller 13 and the message receiver is the microservice 11, there is only an agent on the message receiver side. At this time, the service-side agent is used to hijack the message sent to the microservice 11, and verify whether the controller 13 that sends the message to the microservice 11 is a legitimate message sender according to the first preset control strategy, and when it is concluded that the controller 13 is a legitimate message sender, the message is converted into a data format that the target microservice 11 can understand, and then the message is sent to the target microservice 11.
[0087] Of course, in the implementation, the message sender is the registration center 12 or the microservice 11, and the message receiver is the controller 13. At this time, the data interaction process between the agent on the message sender side and the controller 13 corresponds to the data interaction process between the controller 13 and the agent on the message receiver side when the message sender is the controller 13 and the message receiver is the microservice 11. That is, the agent on the message sender side hijacks the message sent by the message sender, and is responsible for converting the message into a data format that can be recognized by the controller 13, and then sending the message to the controller 13. No further details are given here.
[0088] Optionally, the number of the service-side proxies is N, and the N service-side proxies are connected to the N microservices correspondingly, and the number of the registration center-side proxies is M, and the M registration center-side proxies are connected to the M registration centers correspondingly;
[0089] Among them, the target service side agent stores and executes the control strategy of the target microservice, the target registration center side agent stores and executes the control strategy of the target registration center, the target service side agent is connected to the target microservice, the target registration center side agent is connected to the target registration center side agent, the N service side agents include the target service side agent, the M registration center side agents include the target registration center side agent, the target microservice is one of the N microservices that is connected to the target service side agent, and the target registration center is one of the M registration centers that is connected to the target registration center side agent.
[0090] In this implementation, the service-side proxy is connected to the microservices one-to-one, and the registration center-side proxy is connected to the registration center one-to-one. In this way, the proxies of different microservices and different registration centers can be clearly divided, so that each proxy only needs to store and execute the policy of a microservice or a registration center to which it is connected, thereby reducing the work pressure of a single proxy and improving the reliability and stability of the proxy.
[0091] Optional, such as Figure 2 As shown, the controller 13 further includes: a registration center maintenance module 132 , which is used to maintain the registration center lists corresponding to the M registration centers 12 and the status information of the M registration centers 12 .
[0092] Among them, the above-mentioned registration center maintenance module 132 is used to maintain the registration center list corresponding to the M registration centers 12 and the status information of the M registration centers 12. Specifically, it can be understood as follows: when the registration center 12 is online, the registration center list in the registration center maintenance module 132 is updated according to the information of the online registration center 12, so that the registration center list matches the actual online registration center 12; in addition, when the microservices 11 associated with the registration center 12 are increased or decreased (for example: when the microservices in the microservice framework where the registration center is located are updated), the service list of the registration center 12 can also be maintained, and the microservices 11 that need to access the service list can be informed through message push or notification messages.
[0093] For example: periodically send the notification message to the microservices that need to access the service list; or when the service list of the registration center is updated, immediately inform the microservices that need to access the service list by push message, etc.
[0094] In this way, when the microservice 11 receives a message push or notification message, it can obtain the latest service list from the registration center 12 based on the message push or notification message.
[0095] Of course, in a specific implementation, when the service list of the registration center is updated, the registration center may send an update notification to the corresponding microservice, so that the microservice is informed that the service list of the registration center is updated.
[0096] Furthermore, when the service list or status of the first registration center is updated, the registration center maintenance module also notifies the first microservice associated with the first registration center by message push or notification message based on a third preset control strategy, wherein the M registration centers include the first registration center, and the N microservices include the first microservice.
[0097] Among them, the above-mentioned third preset control strategy can be a control strategy pre-configured by the controller corresponding to the first registration center. Based on the third preset control strategy, the controller selects the first microservice associated with the first registration center from N microservices, and notifies the first microservice in accordance with the method specified by the third preset control strategy. The method specified by the above-mentioned third preset control policy can be: periodically pushing messages or sending notification messages; of course, the method specified by the above-mentioned third preset control policy can also be a method of immediately pushing messages or sending notification messages when it is known that the service list of the first registration center is updated.
[0098] In this implementation, when the service list or status of the first registration center is updated, the controller notifies the first microservice based on the third preset control strategy, so that the first microservice obtains updates to the first registration center it is concerned about. In this way, when the first microservice receives a message push or notification message, it can obtain the latest service list from the first registration center based on the message push or notification message.
[0099] Optionally, each agent in the agent module 14 includes a keep-alive module.
[0100] In actual applications, if there is no dynamic change in a preset time interval, the microservice may enter a downtime state. In this implementation, the above-mentioned keep-alive module can be used to prevent the microservice from entering a downtime state, that is, to maintain the normal operation of the microservice. The keep-alive module in this implementation can initiate a microservice keep-alive process at a certain interval to stimulate the corresponding microservice and registration center, thereby realizing the microservice keep-alive function.
[0101] Specifically, the service-side agent 141 further includes: a service-side keep-alive module 17, which is used to actively initiate a service keep-alive process based on the first preset control strategy;
[0102] and / or,
[0103] The registration center-side agent 142 further includes: a registration center-side keep-alive module, which is used to receive a status detection request sent by the registration center, and send the status detection request to the corresponding microservice based on the second preset control strategy.
[0104] It should be noted that if Figure 3 In the embodiment shown, only the service-side proxy 141 is used as an example for illustration. In implementation, the structure of the registration center-side proxy 142 can refer to the following. Figure 3 The structure of the service-side agent 141 is not described in detail here.
[0105] Among them, the service-side keep-alive module 17 is used to actively initiate a service keep-alive process based on the first preset control strategy, which can be understood as: the service-side keep-alive module 17 in the service-side agent 141 (for example: the service-side agent corresponding to the service provider) determines which registration center 12 to send the service keep-alive request to based on the first preset control strategy, and converts the service keep-alive request into a data format that the determined registration center 12 can understand, and then sends the service keep-alive request to the registration center side agent 142 corresponding to the determined registration center 12; when the registration center side agent 142 receives the service keep-alive request, it authenticates the service keep-alive request, that is, verifies whether the service keep-alive request complies with the second preset control strategy. If it complies with the second preset control strategy, it sends the service keep-alive request to the registration center 12, thereby maintaining a normal data interaction state between the target registration center 12 and the microservice 11, that is, realizing the microservice keep-alive process.
[0106] In addition, the above-mentioned registration center side keep-alive module is used to receive the status detection request sent by the registration center, and send the status detection request to the corresponding microservice based on the second preset control strategy. It can be understood as: the registration center initiates the service detection process to issue a status detection request, the registration center side agent hijacks the status detection request, and based on the second preset control strategy, determines which microservice or microservices 11 to send the status detection request to, and converts the status detection request into a data format that the determined microservice 11 can understand, and then sends the service keep-alive request to the service side agent 141 corresponding to the determined microservice 11; when the service side agent 141 receives the status detection request, it authenticates the service keep-alive request, that is, verifies whether the status detection request complies with the first preset control strategy. If it complies with the first preset control strategy, it sends the status detection request to the service side agent 141 to respond to the received service detection request by the microservice 11, that is, return the service status of the corresponding microservice, thereby realizing the microservice keep-alive process.
[0107] In implementation, one of the two methods, namely, the service provider-side agent actively initiates the service keep-alive process and the registration center initiates the service detection process, can be selected or both can be executed at the same time as a specific implementation method for implementing microservice keep-alive, which is not specifically limited here.
[0108] In the microservice system provided by the embodiment of the present invention, a controller and a proxy module are added to realize the conversion of different protocol data through the proxy module, and a control strategy based on the controller configuration, so that the message initiating side proxy is responsible for screening the service target, that is, determining to which message recipients the initiated message is to be sent; and the message receiving side proxy is responsible for authentication, certification, and filtering messages, that is, the receiving side proxy needs to authenticate whether the received request is a request message that the message recipient is willing to serve, etc., thereby reducing the interaction of messages in the system, data storage, etc., thereby improving the stability and reliability of the microservice system.
[0109] The following is Figure 4a As Figure 4c Taking the data interaction diagram of the application scenario shown in the figure as an example, the working process of the microservice system provided by the embodiment of the present invention is illustrated by way of example:
[0110] like Figure 4a As shown, the registration process of the microservice system provided by the embodiment of the present invention may include the following steps:
[0111] Step 401a: After the registration center comes online, it sends an online information report to the controller.
[0112] Among them, the registration center reports its own information to the controller through the online information report, such as address, port, protocol, capacity, etc.
[0113] Step 402a: The proxy at the registration center hijacks the online information report of the registration center, converts it into a data format understandable by the controller, and then sends it to the controller.
[0114] Step 403a: The controller maintains the information of the registration center based on the online information report, and returns a response to the online information report of the registration center.
[0115] The controller maintaining the information of the registration center based on the online information report can be understood as: the controller maintaining the registration center list based on the online information report.
[0116] Step 404a: The proxy at the registration center hijacks the response returned by the controller, converts it into a data format understandable to the registration center, and then sends it to the registration center.
[0117] Step 405a: The controller sends the control policy to the registration center-side agent.
[0118] In this implementation, this step can be triggered when the registration center is online. Of course, in cases such as control policy updates, the step of the controller sending the control policy to the registration center-side agent can also be triggered, which is not specifically limited here.
[0119] In implementation, after the registration center-side agent receives the control policy issued by the controller, the agent is responsible for executing the control policy. In implementation, the above control policy includes but is not limited to: the number and range (address range, protocol range) of acceptable service registrations, etc.
[0120] Step 406a: The registration center-side agent returns a response to the controller in response to the issued control policy.
[0121] Step 407a: The service (including service consumers and service providers) side agent requests the controller for registration center information.
[0122] Step 408a: The controller returns the registration center list to the service-side agent.
[0123] Step 409a: The controller sends the control policy to the service-side agent (including the service consumer and the service provider).
[0124] After receiving the control policy issued by the controller, the service-side agent is responsible for executing the control policy. In implementation, the above control policies include but are not limited to: service registration policies (for example, register all, register only in the same region registration center, register only in the registration center of a microservice architecture, etc.), service discovery policies (for example, obtain the service list on all registration centers, obtain only the service list on the same region registration center, obtain only the service list on the registration center of a microservice architecture), etc.
[0125] Step 410a: The service-side agent returns a response to the controller in response to the issued control policy.
[0126] Step 411a: The service provider initiates a service registration request.
[0127] Step 412a: The service-side agent selects a registration center based on the control policy pre-delivered by the controller, converts the registration request into a data format understandable by the registration center, and then sends the service registration request to the registration center.
[0128] In this step, the service provider does not need to register with every registration center, but only registers with the registration centers that comply with the control policy.
[0129] Step 413a: The agent at the registration center filters the requests received by the registration center based on the control policy pre-issued by the controller, and forwards the requests satisfying the policy to the registration center.
[0130] In this step, the registration center-side agent filters the service registration requests sent to the registration center to send only requests that comply with a preset control policy to the registration center, thereby avoiding sending invalid or unnecessary requests to the registration center.
[0131] For example, assuming that the control policy pre-configured by the registration center is to only support service registration requests of protocol A, if the agent of the registration center receives a service registration request of protocol B, the service registration request of protocol B will not be sent to the registration center, thereby preventing the registration center from responding to requests that do not comply with the control policy.
[0132] Step 414a: The registration center returns a response to the service registration request.
[0133] In this step, the response message of the above service registration request may be returned to the service provider through the registration center-side proxy and the service-side proxy.
[0134] Step 415a: The registration center-side agent transparently transmits the response returned by the registration center to the service-side (service provider) agent.
[0135] In this step, it specifically means that the proxy on the registration center side hijacks the response message returned by the registration center and sends the response message to the microservice, and on the microservice side, the service side proxy can hijack the above response message sent to the microservice.
[0136] Step 416a: The service-side proxy converts the received response into a data format understandable to the service provider and sends it to the service provider.
[0137] The microservice system provided by the embodiment of the present invention is as follows Figure 4a The workflow shown can realize the microservice registration function and effectively reduce the registration of unnecessary registration centers during the microservice registration process.
[0138] like Figure 4b As shown, the microservice discovery process of the microservice system provided by the embodiment of the present invention may include the following steps:
[0139] Step 401b: The service consumer initiates a service discovery request.
[0140] Step 402b: The service-side agent selects a registration center based on the control policy, converts the service discovery request into a data format understandable by the registration center, and then sends it to the registration center-side agent of the selected registration center.
[0141] In implementation, the above control strategy can be Figure 4a In the service registration process, the controller sends the control policy to the service-side agent in advance.
[0142] Step 403b: The registration center-side agent filters the service discovery requests based on the control policy, and forwards the service discovery requests that meet the policy to the registration center.
[0143] In implementation, the above control strategy can be Figure 4a In the service registration process, the controller sends the control policy to the registration center agent in advance.
[0144] Step 404b: The registration center returns the service list of the registration center.
[0145] Step 405b: The registration center-side agent hijacks the service list sent by the registration center, and transparently transmits the service list to the service-side agent.
[0146] Step 406b: The service-side proxy converts the received service list into a data format understandable to the service consumer, and then sends it to the service consumer.
[0147] Through this step, the service consumer can search for the required service from the received service list, and after finding the required service, can initiate a call to the service through steps 407b to 412b. The called service can also be referred to as a service provider. For the sake of distinction, the service-side agent corresponding to the service consumer is referred to as a service consumer-side agent, and the service-side agent corresponding to the service provider is referred to as a service provider-side agent.
[0148] Step 407b: The service consumer initiates a service call request.
[0149] Step 408b: The service consumer-side proxy hijacks the service call request sent by the service consumer, converts it into a data format understandable to the service provider, and sends it to the service provider-side proxy.
[0150] Step 409b: The service provider-side agent filters the service call requests based on the control policy, and sends the service call requests that comply with the control policy to the service provider.
[0151] Step 410b: The service provider returns a service call response.
[0152] Step 411b: The service provider-side proxy transparently transmits the service call response to the service consumer-side proxy.
[0153] Step 412b: The service consumer-side proxy converts the received service call response into a data format understandable to the service consumer and sends it to the service consumer.
[0154] The above steps 410b to 412b may specifically be: the service provider-side proxy hijacks the service call response returned by the service provider and sends the service call response to the service consumer; at this time, the service consumer-side proxy hijacks the service call response received by the service consumer, converts it into a data format that the service consumer can understand, and then conveys the service call response to the service consumer.
[0155] The microservice system provided by the embodiment of the present invention is as follows Figure 4b The workflow shown can realize the microservice discovery and calling functions, and in the process of microservice discovery and calling, it can effectively reduce the service consumers' unnecessary service discovery requests to the registration center, and enable the service provider to respond only to the service call requests that comply with the control policy, thereby greatly reducing the data interaction process.
[0156] like Figure 4c As shown, the microservice keep-alive and registration center update process of the microservice system provided by the embodiment of the present invention may include the following steps:
[0157] Step 401c: The service provider-side agent actively initiates service keep-alive: the agent sends a service keep-alive request that the other party can understand to the registration center-side agent.
[0158] Step 402c: The agent at the registration center side filters the service keep-alive requests based on the control policy to send the service keep-alive requests that comply with the control policy to the registration center.
[0159] Step 403c: The registration center initiates service detection.
[0160] Step 404c: The registration center agent converts the service detection request into a data format that can be understood by the service provider agent.
[0161] Step 405c: The service provider-side agent filters the service detection request based on the policy and returns the service status.
[0162] Step 406c: The registration center test agent converts the service test request response into a data format that the registration center can understand.
[0163] It should be noted that, in implementation, if the service keep-alive process is actively initiated by the service provider, only the above steps 401c and 402c may be executed, without executing steps 403c to 406c; in addition, when the registration center initiates service detection to implement the microservice keep-alive function, only steps 403c to 406c may be executed, without executing steps 401c and 402c.
[0164] In addition, after executing step 401c and step 402c, or executing steps 403c to 406c, if the registration center determines that the service list of the registration center has been updated based on the received service detection request response, the following steps 407c to 416c can be performed to notify the microservices paying attention to the registration center that the service list of the registration center has been updated, so that the microservices can obtain the latest service list from the registration center when necessary.
[0165] Step 407c: The registration center initiates a service list update notification.
[0166] Step 408c: The registration center-side agent hijacks the service list update notification initiated by the registration center, and based on the control policy, converts the service list update notification into a data format understandable by the controller, and then sends it to the controller.
[0167] In implementation, the above control strategy can be Figure 4a In the service registration process, the controller sends the control policy to the registration center agent in advance.
[0168] Step 409c: The controller sends a service list update notification to the service-side agent based on the received service list update notification and the control policy.
[0169] Step 410c: The service-side agent filters the received service list update notifications based on the control policy to send the service list update notifications that comply with the control policy to the corresponding microservices.
[0170] In implementation, the above control strategy can be Figure 4a In the service registration process, the controller sends the control policy to the service-side agent in advance.
[0171] When the microservice needs to obtain the service list corresponding to the service list update notification based on the received service list update notification, the following steps 411c to 416c are executed to update the service list to the latest service list.
[0172] Step 411c: The microservice initiates a request to update the service list.
[0173] Step 412c: The service-side agent selects a registration center based on the control policy, converts the service list update request into a data format understandable to the registration center, and then sends it to the registration center-side agent of the selected registration center.
[0174] Step 413c: The registration center-side agent filters the service list update requests based on the control policy, and forwards the service list update requests that meet the policy to the registration center.
[0175] Step 414c: The registration center returns the service list of the registration center.
[0176] Step 415c: The registration center-side agent transparently transmits the service list to the service-side agent.
[0177] Step 416c: The service-side proxy converts the received service list into a data format understandable to the microservice and sends it to the microservice.
[0178] The microservice system provided by the embodiment of the present invention is as follows Figure 4c The workflow shown can update the service list of the registry center and notify the microservices that follow the registry center after the update. At this time, the microservices can decide whether to obtain the latest service list according to their own needs.
[0179] See also Figure 5 , is a flow chart of a microservice registration method provided in an embodiment of the present application, such as Figure 5 As shown, the microservice registration method may include the following steps:
[0180] Step 501: The target microservice sends a registration request.
[0181] Step 502: The service-side agent hijacks the registration request, and based on a first preset control strategy, determines a target registration center for the registration request, and converts the registration request into protocol data corresponding to the target registration center.
[0182] Among them, the above-mentioned target microservice can be understood as the service provider to be registered, the above-mentioned target registration center can be a registration center selected based on the first preset control strategy, and the protocol data corresponding to the above-mentioned target registration center can be understood as: a data format that can be understood by the target registration center.
[0183] Step 503: The service-side agent sends the registration request to the target registration center through the registration center-side agent.
[0184] The microservice registration method provided in the embodiment of the present invention can be applied to Figure 1 The microservice system in the embodiment shown in the figure can implement each process in the microservice registration method provided in the embodiment of the present invention through the microservice system. For details, please refer to Figure 4a In the illustrated embodiment, the specific implementation process of the microservice registration method in steps 411a to 416a is not repeated here.
[0185] As an optional implementation manner, the service-side agent sends the registration request to the target registration center through the registration center-side agent, including:
[0186] The service-side agent sends the registration request to the target registration center;
[0187] The registration center-side proxy hijacks the registration request sent to the target registration center, and sends the registration request to the target registration center when the registration request complies with a second preset control policy.
[0188] Of course, in implementation, the data transparent transmission function between the service side agent and the registration center side agent can be used to enable the service side agent to transparently transmit the registration request to the registration center side agent, and then the registration center side agent determines whether the registration request complies with the second preset control policy. In this way, when the registration request complies with the second preset control policy, the registration request is sent to the target registration center.
[0189] In this embodiment, the agent on the registration center side also filters the registration requests that need to be sent to the target registration center based on the second preset control policy, so as to only send the registration requests that comply with the second preset control policy to the target registration center. In this way, it can be ensured that the registration requests received by the target registration center are registration requests that meet the processing capabilities of the target registration center and comply with the authentication requirements of the target registration center, thereby improving the reliability and security of the target registration center.
[0190] As an optional implementation manner, the first preset control policy is sent from the controller to the service-side agent, and the second preset control policy is sent from the controller to the registration center-side agent.
[0191] In this embodiment, Figure 1 The method embodiments shown are the same, in that the controller sends control policies to the service-side agent and the registration center-side agent respectively.
[0192] In this way, during implementation, if a microservice or registration center is updated, the control policy can be issued to the updated microservice or registration center based on the control policy, thereby avoiding the need to manually configure the control policy for each microservice or registration center separately, and simplifying the process of configuring the control policy for the microservice and registration center.
[0193] As an optional implementation manner, before the service-side proxy hijacks the registration request and determines the target registration center of the registration request based on the first preset control strategy, the method further includes:
[0194] When the target registration center goes online, it issues an online information report;
[0195] The registration center-side agent hijacks the online information report, converts it into protocol data corresponding to the controller, and then forwards it to the controller;
[0196] The controller maintains a registration center list according to the online information report, and sends a second preset control policy corresponding to the target registration center to the registration center-side agent.
[0197] In this embodiment, Figure 1 In the microservice system shown in the figure, the data transmission process when the registration center goes online is the same and has the same beneficial effects. For details, please refer to Figure 4a Steps 401a to 406a in the data interaction diagram are not described in detail here.
[0198] As an optional implementation manner, after the controller maintains the registration center list according to the online information report, the method further includes:
[0199] The service-side agent sends a registration center list request to the controller;
[0200] The controller sends the registration center list and the first preset control policy to the service-side agent in response to the registration center list request.
[0201] In this implementation, the service-side agent sends a registration center list request to the controller in advance, so that the controller sends the registration center list and control policy based on the request. In this way, when the service-side agent subsequently hijacks the registration request of the microservice, it can determine the target registration center based on the registration center list and control policy, and thus only send the registration request to the target registration center or the registration center server corresponding to the target registration center.
[0202] By using the microservice registration method provided by the embodiment of the present invention, the microservice is registered only in the registration center that complies with the control policy, which can reduce unnecessary registration processes. In addition, during the microservice registration process, the corresponding agent performs protocol data conversion on the message received by the message receiver or sent by the message sender, thereby avoiding centralized data conversion in the registration center, which increases the working pressure of the registration center and causes poor stability and reliability of the registration center.
[0203] See also Figure 6 , is a flow chart of a microservice discovery method provided by an embodiment of the present invention, such as Figure 6 As shown, the microservice discovery method may include the following steps:
[0204] Step 601: The first microservice sends a service discovery request.
[0205] Step 602: The service-side agent hijacks the service discovery request, and based on a first preset control strategy, determines a target registration center corresponding to the service discovery request, and converts the service discovery request into protocol data corresponding to the target registration center.
[0206] Step 603: The service-side agent sends the service discovery request to the registration center-side agent, so that the service discovery request is sent to the target registration center through the registration center-side agent.
[0207] Step 604: The target registry returns a service list in response to the service discovery request, and the service list is sent to the first microservice through the registry-side agent and the service-side agent.
[0208] In implementation, the specific implementation process of the above steps 601 to 604 can refer to the following Figure 4b Steps 401b to 406b in the flowchart shown in FIG. 4 and the microservice discovery method described above are similar to the microservice discovery method described in FIG. Figure 1The microservice system shown has the same beneficial effects when used to perform the microservice discovery process, which will not be described in detail here.
[0209] As an optional implementation, the method further includes:
[0210] The first microservice issues a service call request based on the received service list, wherein the service call request is used to call the second microservice;
[0211] The service-side proxy hijacks the service call request, converts the service call request into protocol data corresponding to the second microservice, and sends the data to the second microservice;
[0212] The second microservice responds to the service call request and issues a service call response message;
[0213] The service-side agent hijacks the service call response information, converts the service call response information into protocol data corresponding to the first microservice, and sends the data to the first microservice.
[0214] In implementation, the first microservice can determine the second microservice that needs to be called based on the service list obtained in step 604, thereby generating a service call request for calling the second microservice. In this way, the service-side agent can convert the service call request into the protocol data corresponding to the second microservice and send it to the second microservice.
[0215] In implementation, the proxy on the second microservice side and the proxy on the first microservice side may be two different proxies, so that the second microservice can receive the service call request sent by the proxy of the first microservice through the proxy on the second microservice side.
[0216] As an optional implementation manner, the first microservice and the second microservice are respectively connected to different service-side proxies;
[0217] A service-side proxy connected to the first microservice, used to hijack the service call request issued by the first microservice, convert the service call request into protocol data corresponding to the second microservice, and then send it to the service-side proxy connected to the second microservice;
[0218] The service-side proxy connected to the second microservice is used to forward the service call request to the second microservice when it is determined that the service call request complies with a preset control policy corresponding to the second microservice.
[0219] In this implementation, the proxy on the second microservice side also needs to further screen the received service call requests to forward only the service call requests that comply with the preset control policy corresponding to the second microservice to the second microservice, thereby preventing the second microservice from receiving invalid, low-security or unresponsive service call requests, thereby improving the reliability and security of the second microservice.
[0220] The microservice discovery method provided in the embodiment of the present invention enables the first microservice to obtain a service list only from a specified target registration center, so as to search for the second microservice to be called from the obtained service list, without having to perform a microservice discovery process in each registration center, thereby reducing the amount of data interaction of the microservice system in the process of executing the microservice discovery process, and being able to discover the second microservice more accurately and quickly.
[0221] See also Figure 7 , is a flow chart of a microservice keep-alive method provided by an embodiment of the present invention, such as Figure 7 As shown, the microservice keep-alive method may include the following steps:
[0222] Step 701: The registration center-side agent hijacks the status detection request sent by the target registration center to the service-side agent, converts the status detection request into protocol data corresponding to the service-side agent, and then sends it to the service-side agent.
[0223] Step 702: When the status detection request complies with the first preset control strategy, the service-side agent detects the working status of the target microservice based on the status detection request, and feeds back the working status of the target microservice to the target registration center through the registration center-side agent.
[0224] or,
[0225] Step 703: The service-side agent actively sends a service keep-alive request that can be understood by the target registration center to the target registration center based on the first preset control strategy.
[0226] This step can be specifically understood as: the service-side agent determines the time when a service keep-alive request needs to be initiated based on the first preset control strategy, and determines to which target registration center or centers the service keep-alive request needs to be sent, thereby converting the service keep-alive request into a data format that the target registration center can understand, and then sending it to the corresponding target registration center.
[0227] Step 704: The proxy at the registration center hijacks the service keep-alive request, and sends the service keep-alive request to the target registration center if the service keep-alive request complies with a second preset control policy.
[0228] It should be noted that the above steps 701 and 702 correspond to an implementation method in which the registration center initiates the keep-alive process, and the above steps 703 and 704 correspond to an implementation method in which the service-side agent actively initiates the keep-alive process.
[0229] In implementation, in the same microservice keep-alive process, only the above steps 701 and 702 may be executed, or only the above steps 703 and 704 may be executed, or the above steps 701 to 704 may be executed simultaneously.
[0230] The microservice keep-alive method provided in the embodiment of the present invention can be applied to Figure 1 The microservice system shown in Figure 1 The microservice system shown in FIG. 1 has the same process in executing the microservice keep-alive process and can achieve the same beneficial effects. For details, please refer to FIG. Figure 4c Steps 401c to 406c in the data interaction process shown are not repeated here.
[0231] As an optional implementation manner, after the service-side agent feeds back the working status of the target microservice to the target registration center through the registration center-side agent, the method further includes:
[0232] When the target registration center determines that the service list has been updated based on the working status of the target microservice, the target registration center sends a first service list update notification to the controller through the registration center-side agent based on the second preset control strategy;
[0233] The controller responds to the first service list update notification and sends a second service list update notification to the target microservice through the service-side agent based on a third preset control strategy, where the third preset control strategy is a control strategy pre-configured in the controller.
[0234] In implementation, the target registration center may send the first service list update notification to the controller through the registration center-side agent periodically or immediately upon learning that the service list has been updated, which is not specifically limited here.
[0235] The target registration center sends the first service list update notification to the controller through the registration center side agent based on the second preset control strategy. It can be understood that: the target registration center sends a first service list update notification, the registration center side agent hijacks the first service list update notification, and converts the first service list update notification into a data format that the controller can understand based on the second preset control strategy, and then sends it to the controller.
[0236] In addition, the above-mentioned controller responds to the first service list update notification and sends a second service list update notification to the target microservice through the service side agent based on a third preset control strategy. It can be understood that: the controller responds to the first service list update notification and sends a second service list update notification to the service side agent at a specific time. When the service side agent receives the second service list update notification, the service side agent performs security verification on the controller that sends the second service list update notification based on the second preset control strategy, so that if the controller passes the security verification, the second service list update notification is converted into a data format that can be recognized by the target microservice corresponding to the service side agent, and then sent to the target microservice.
[0237] In implementation, the third preset control strategy may be a control strategy pre-stored by the controller, and based on the third preset control strategy, it can be determined when to send the second service list update notification to the service-side agent.
[0238] The various steps in this embodiment can be specifically referred to as follows Figure 4c Steps 407c to 410c in the data interaction diagram are not described in detail here.
[0239] As an optional implementation manner, after the controller responds to the first service list update notification and sends a second service list update notification to the target microservice through the service-side agent based on a third preset control strategy, the method further includes:
[0240] The target microservice issues a request to update the service list;
[0241] The service-side agent hijacks the service list update request, and based on the first preset control strategy, determines the target registration center corresponding to the service list update request, and after converting the service list update request into protocol data corresponding to the target registration center, sends the service list update request to the target registration center through the registration center-side agent;
[0242] The target registration center returns a service list to the target microservice through the service-side agent and the registration center-side agent in response to the service list update request.
[0243] In this implementation, after receiving the second service list update notification, the target microservice can issue a service list update request according to its own needs, for example, issuing a service list update request when it is necessary to call the service provider involved in the second service list update notification.
[0244] In addition, after hijacking the update service list request issued by the target microservice, the service-side agent can determine when to execute according to the first preset control strategy: determine the target registration center corresponding to the update service list request, and convert the update service list request into protocol data corresponding to the target registration center, and then send the update service list request to the target registration center through the registration center side agent, for example: periodic execution or immediate execution when the above-mentioned update service list request is hijacked.
[0245] The above-mentioned sending of the service list update request to the target registration center through the registration center side agent can be understood as: the service side agent sends the service list update request to the target registration center, the registration center side agent corresponding to the target registration center hijacks the service list update request, and when the registration center side agent determines that the service list update request complies with the second preset control policy of the target registration center, it sends the service list update request to the target registration center.
[0246] The above-mentioned target registration center responds to the request to update the service list and returns the service list to the target microservice through the service side agent and the registration center side agent. It can be understood that: the target registration center responds to the request to update the service list and feeds back the service list, the registration center side agent hijacks the service list issued by the target registration center, and sends the service list to the service side agent through the data transparent transmission function between the service side agent, so that the service side agent converts the service list into a data format that can be recognized by the target microservice and sends it to the target microservice.
[0247] The process of updating the service list of the above target microservice can be specifically referred to as follows Figure 4c Steps 411c to 416c in the data interaction process are not described in detail here.
[0248] The microservice keep-alive method provided in the embodiment of the present invention can be triggered by a registration center or a service-side agent to implement a microservice keep-alive process.
[0249] See also Figure 8 , is a structural diagram of a microservice registration device provided by an embodiment of the present invention, such as Figure 8 As shown, the microservice registration device 800 includes:
[0250] The first sending module 801 is used to send a registration request through a target microservice;
[0251] The first data processing module 802 is used to hijack the registration request through a service-side proxy, determine a target registration center of the registration request based on a first preset control strategy, and convert the registration request into protocol data corresponding to the target registration center;
[0252] The second sending module 803 is used to send the registration request to the target registration center through the registration center-side agent.
[0253] Optionally, the second sending module 803 includes:
[0254] A first sending unit, configured to send the registration request to the target registration center through the service-side agent;
[0255] The first data processing unit is used to hijack the registration request sent to the target registration center through a registration center-side agent, and send the registration request to the target registration center if the registration request complies with a second preset control policy.
[0256] Optionally, the first preset control policy is sent from the controller to the service-side agent, and the second preset control policy is sent from the controller to the registration center-side agent.
[0257] Optionally, the microservice registration device 800 further includes:
[0258] A reporting module, used to issue an online information report when the target registration center comes online;
[0259] A first forwarding module, configured to hijack the online information report through the registration center-side agent, convert it into protocol data corresponding to the controller, and then forward it to the controller;
[0260] The first sending module is used to maintain the registration center list according to the online information report through the controller, and send a second preset control policy corresponding to the target registration center to the registration center side agent.
[0261] Optionally, the microservice registration device 800 further includes:
[0262] A first request module, used to send a registration center list request to the controller through the service-side agent;
[0263] The first response module is used to respond to the registration center list request through the controller and send the registration center list and the first preset control strategy to the service-side agent.
[0264] The microservice registration device 800 provided in the embodiment of the present invention can implement the following Figure 5 The various processes in the illustrated method embodiment can achieve the same beneficial effects, and will not be described again here to avoid repetition.
[0265] See also Fig. 9, is a structural diagram of a microservice discovery device provided by an embodiment of the present invention, such as Fig. 9 As shown, the microservice discovery device 900 includes:
[0266] The third sending module 901 is used to send a service discovery request through the first microservice;
[0267] The second data processing module 902 is used to hijack the service discovery request through the service-side proxy, and determine the target registration center corresponding to the service discovery request based on the first preset control strategy, and convert the service discovery request into protocol data corresponding to the target registration center;
[0268] The fourth sending module 903 is used to send the service discovery request to the registration center side agent through the service side agent, so as to send the service discovery request to the target registration center through the registration center side agent;
[0269] The fifth sending module 904 is used to return a service list in response to the service discovery request through the target registration center, and the service list is sent to the first microservice through the registration center side agent and the service side agent.
[0270] Optionally, the microservice discovery device 900 further includes:
[0271] A second request module, configured to issue a service call request based on the received service list through the first microservice, wherein the service call request is used to call a second microservice;
[0272] A second forwarding module is used to hijack the service call request through a service-side proxy, convert the service call request into protocol data corresponding to the second microservice, and then send it to the second microservice;
[0273] A second response module, configured for the second microservice to respond to the service call request and issue a service call response message;
[0274] The third forwarding module is used for the service-side proxy to hijack the service call response information, convert the service call response information into protocol data corresponding to the first microservice, and then send it to the first microservice.
[0275] Optionally, the first microservice and the second microservice are connected to different service-side proxies respectively;
[0276] The service-side proxy connected to the first microservice is used to hijack the service call request issued by the first microservice, convert the service call request into protocol data corresponding to the second microservice, and then send it to the service-side proxy connected to the second microservice;
[0277] The service-side proxy connected to the second microservice is used to forward the service call request to the second microservice when it is determined that the service call request complies with a preset control policy corresponding to the second microservice.
[0278] The microservice discovery device 900 provided in the embodiment of the present invention can achieve the following Figure 6 The various processes in the illustrated method embodiment can achieve the same beneficial effects, and will not be described again here to avoid repetition.
[0279] Please refer to FIG. 10 , which is a structural diagram of a microservice keep-alive device provided in an embodiment of the present invention.
[0280] In an optional embodiment, if Fig.10a As shown, the microservice keep-alive device 1000 includes: a third data processing module 1001 and a detection module 1002 .
[0281] The third data processing module 1001 is used to hijack the status detection request sent by the target registration center to the service side agent through the registration center side agent, and convert the status detection request into the protocol data corresponding to the service side agent and send it to the service side agent;
[0282] The detection module 1002 is used to detect the working status of the target microservice based on the status detection request by the service-side agent when the status detection request complies with the first preset control strategy, and to feedback the working status of the target microservice to the target registration center through the registration center-side agent.
[0283] In another optional embodiment, if Fig.10b As shown, the microservice keep-alive device 1000 includes: a sixth sending module 1003 and a fourth data processing module 1004 .
[0284] The sixth sending module 1003 is used to actively send a service keep-alive request that can be understood by the target registration center to the target registration center through the service-side agent based on the first preset control strategy;
[0285] The fourth data processing module 1004 is used to hijack the service keep-alive request through the registration center-side proxy, and send the service keep-alive request to the target registration center if the service keep-alive request complies with the second preset control policy.
[0286] It should be noted that, in another implementation, the microservice keep-alive device 1000 may include the third data processing module 1001, the detection module 1002, the sixth sending module 1003 and the fourth data processing module 1004 at the same time, which is not specifically limited here.
[0287] Optionally, the microservice keep-alive device 1000 further includes:
[0288] A seventh sending module, configured to enable the target registration center to send a first service list update notification to the controller through the registration center-side agent based on the second preset control strategy when the target registration center determines that the service list has been updated based on the working status of the target microservice;
[0289] A third response module is used to respond to the first service list update notification through the controller, and send a second service list update notification to the target microservice through the service-side agent based on a third preset control strategy, where the third preset control strategy is a control strategy pre-configured in the controller.
[0290] Optionally, the microservice keep-alive device 1000 further includes:
[0291] A third request module, used to issue a service list update request through the target microservice;
[0292] a fourth forwarding module, configured to hijack the service list update request through the service side agent, determine the target registration center corresponding to the service list update request based on the first preset control strategy, and convert the service list update request into protocol data corresponding to the target registration center, and then send the service list update request to the target registration center through the registration center side agent;
[0293] The fourth response module is used to respond to the request to update the service list through the target registration center, and return the service list to the target microservice through the service-side agent and the registration center-side agent.
[0294] The microservice keep-alive device 1000 provided in the embodiment of the present invention can achieve the following Figure 7 The various processes in the illustrated method embodiment can achieve the same beneficial effects, and will not be described again here to avoid repetition.
[0295] See also Fig.11 , is a structural diagram of a microservice system 1100 provided in an embodiment of the present application, the microservice system 1100 includes a processor 1101, a memory 1102, and a computer program stored in the memory 1102 and executable on the processor 1101, and when the computer program is executed by the processor 1101, the following is implemented Figure 5 , Figure 6 or Figure 7 Each step in the method embodiment is described.
[0296] In the embodiment of the present invention, the cloud computing platform 1100 can realize Figures 1 to 7 The various processes in any one of the method embodiments have the same beneficial effects and will not be described again here to avoid repetition.
[0297] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, which implements the above-mentioned Figures 1 to 7 The various processes in any one of the method embodiments can achieve the same technical effect, and to avoid repetition, they will not be described here.
[0298] The computer-readable storage medium is, for example, a ROM, RAM, a magnetic disk or an optical disk.
[0299] 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.
[0300] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0301] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
Claims
1. A microservice system, It is characterized in that include: N microservices, where N is an integer greater than 1; M registration centers, where M is an integer greater than 1; Controller; as well as, An agent module connected to the controller, the agent module comprising a service-side agent connected to the N microservices and a registration center-side agent connected to the M registration centers, and the service-side agent is connected to the registration center-side agent respectively; Wherein, the controller comprises: a policy maintenance module, the policy maintenance module is used to send a first preset control policy to the service side agent, and send a second preset control policy to the registration center side agent; The service-side proxy includes: a service-side policy filtering unit and a service-side protocol conversion unit, wherein the service-side policy filtering unit filters the sent or received message based on the first preset control policy to forward the sent or received message to a message receiver matching the first preset control policy; the service-side protocol conversion unit is used to convert the received message into a data format understandable to the message receiver; The registration center side agent includes: a registration center side policy filtering unit and a registration center side protocol conversion unit, wherein the registration center side policy filtering unit filters the sent or received message based on the second preset control policy to forward the sent or received message to a message receiver matching the second preset control policy; the registration center side protocol conversion unit is used to convert the received message into a data format understandable to the message receiver; The controller further includes: a registration center maintenance module, configured to maintain a registration center list corresponding to the M registration centers and status information of the M registration centers; When the service list or status of the first registration center is updated, the registration center maintenance module further notifies the first microservice associated with the first registration center by message push or notification message based on a third preset control strategy, wherein the M registration centers include the first registration center, and the N microservices include the first microservice.
2. The system according to claim 1, It is characterized in that The number of the service-side proxies is N, and the N service-side proxies are connected to the N microservices correspondingly; the number of the registration center-side proxies is M, and the M registration center-side proxies are connected to the M registration centers correspondingly; Among them, the target service side agent stores and executes the control strategy of the target microservice, the target registration center side agent stores and executes the control strategy of the target registration center, the target service side agent is connected to the target microservice, the target registration center side agent is connected to the target registration center, the N service side agents include the target service side agent, the M registration center side agents include the target registration center side agent, the target microservice is one of the N microservices that is connected to the target service side agent, and the target registration center is one of the M registration centers that is connected to the target registration center side agent.
3. The system according to claim 1, It is characterized in that The service-side agent further includes: a service-side keep-alive module, configured to actively initiate a service keep-alive process based on the first preset control strategy; and / or, The registration center-side agent also includes: a registration center-side keep-alive module, which is used to receive a status detection request sent by the registration center, and send the status detection request to the corresponding microservice based on the second preset control strategy.
4. A microservice registration method, It is characterized in that The method comprises: The target microservice sends a registration request; The service-side agent hijacks the registration request, and based on a first preset control strategy, determines a target registration center of the registration request, and converts the registration request into protocol data corresponding to the target registration center; The service-side agent sends the registration request to the target registration center through the registration center-side agent; The service-side agent sends the registration request to the target registration center through the registration center-side agent, including: The service-side agent sends the registration request to the target registration center; The registration center-side proxy hijacks the registration request sent to the target registration center, and sends the registration request to the target registration center when the registration request complies with a second preset control policy.
5. The microservice registration method according to claim 4, It is characterized in that The first preset control strategy is sent from the controller to the service-side agent, and the second preset control strategy is sent from the controller to the registration center-side agent.
6. The microservice registration method according to claim 4, It is characterized in that Before the service-side proxy hijacks the registration request and determines the target registration center of the registration request based on the first preset control strategy, the method further includes: When the target registration center goes online, it issues an online information report; The registration center-side agent hijacks the online information report, converts it into protocol data corresponding to the controller, and then forwards it to the controller; The controller maintains a registration center list according to the online information report, and sends a second preset control policy corresponding to the target registration center to the registration center-side agent.
7. The microservice registration method according to claim 6, It is characterized in that After the controller maintains the registration center list according to the online information report, the method further includes: The service-side agent sends a registration center list request to the controller; The controller sends the registration center list and the first preset control policy to the service-side agent in response to the registration center list request.
8. A microservice discovery method, It is characterized in that The method comprises: The first microservice sends a service discovery request; The service-side agent hijacks the service discovery request, and based on a first preset control strategy, determines a target registration center corresponding to the service discovery request, and converts the service discovery request into protocol data corresponding to the target registration center; The service-side agent sends the service discovery request to the registration center-side agent, so that the service discovery request is sent to the target registration center through the registration center-side agent; The target registry returns a service list in response to the service discovery request, and the service list is sent to the first microservice through the registry-side agent and the service-side agent; The method further comprises: The first microservice issues a service call request based on the received service list, wherein the service call request is used to call the second microservice; The service-side proxy hijacks the service call request, converts the service call request into protocol data corresponding to the second microservice, and sends the data to the second microservice; The second microservice responds to the service call request and issues a service call response message; The service-side agent hijacks the service call response information, converts the service call response information into protocol data corresponding to the first microservice, and sends the data to the first microservice.
9. The microservice discovery method according to claim 8, It is characterized in that The first microservice and the second microservice are respectively connected to different service-side proxies; The service-side proxy connected to the first microservice is used to hijack the service call request issued by the first microservice, convert the service call request into protocol data corresponding to the second microservice, and then send it to the service-side proxy connected to the second microservice; The service-side proxy connected to the second microservice is used to forward the service call request to the second microservice when it is determined that the service call request complies with a preset control policy corresponding to the second microservice.
10. A microservice keep-alive method, It is characterized in that The method comprises: The registration center side agent hijacks the status detection request sent by the target registration center to the service side agent, converts the status detection request into the protocol data corresponding to the service side agent, and sends it to the service side agent; In the case where the status detection request complies with the first preset control strategy, the service-side agent detects the working status of the target microservice based on the status detection request, and feeds back the working status of the target microservice to the target registration center through the registration center-side agent; and / or, The service-side agent actively sends a service keep-alive request that can be understood by the target registration center to the target registration center based on a first preset control strategy; The registration center-side proxy hijacks the service keep-alive request, and sends the service keep-alive request to the target registration center if the service keep-alive request complies with a second preset control policy; The method further comprises: When the target registration center determines that the service list has been updated based on the working status of the target microservice, the target registration center sends a first service list update notification to the controller through the registration center-side agent based on the second preset control strategy; The controller responds to the first service list update notification and sends a second service list update notification to the target microservice through the service-side agent based on a third preset control strategy, where the third preset control strategy is a control strategy pre-configured in the controller.
11. The microservice keep-alive method according to claim 10, It is characterized in that After the controller sends a second service list update notification to the target microservice through the service-side proxy based on a third preset control strategy in response to the first service list update notification, the method further includes: The target microservice issues a request to update the service list; The service-side agent hijacks the service list update request, and based on the first preset control strategy, determines the target registration center corresponding to the service list update request, and after converting the service list update request into protocol data corresponding to the target registration center, sends the service list update request to the target registration center through the registration center-side agent; The target registration center returns a service list to the target microservice through the service-side agent and the registration center-side agent in response to the service list update request.
12. A microservice registration device, It is characterized in that include: A first sending module, used to send a registration request through a target microservice; A first data processing module, configured to hijack the registration request through a service-side proxy, determine a target registration center of the registration request based on a first preset control strategy, and convert the registration request into protocol data corresponding to the target registration center; A second sending module, used to send the registration request to the target registration center through a registration center-side agent; The second sending module includes: A first sending unit, configured to send the registration request to the target registration center through the service-side agent; The first data processing unit is used to hijack the registration request sent to the target registration center through a registration center-side agent, and send the registration request to the target registration center if the registration request complies with a second preset control policy.
13. A microservice discovery device, It is characterized in that include: A third sending module is used to send a service discovery request through the first microservice; A second data processing module is used to hijack the service discovery request through a service-side proxy, and based on a first preset control strategy, determine a target registration center corresponding to the service discovery request, and convert the service discovery request into protocol data corresponding to the target registration center; A fourth sending module, configured to send the service discovery request to the registration center side agent through the service side agent, so as to send the service discovery request to the target registration center through the registration center side agent; A fifth sending module, configured to return a service list in response to the service discovery request through the target registration center, and the service list is sent to the first microservice through the registration center side agent and the service side agent; A second request module, configured to issue a service call request based on the received service list through the first microservice, wherein the service call request is used to call a second microservice; A second forwarding module is used to hijack the service call request through a service-side proxy, convert the service call request into protocol data corresponding to the second microservice, and then send it to the second microservice; A second response module, configured for the second microservice to respond to the service call request and issue a service call response message; The third forwarding module is used for the service-side proxy to hijack the service call response information, convert the service call response information into protocol data corresponding to the first microservice, and then send it to the first microservice.
14. A microservice keep-alive device, It is characterized in that The microservice keep-alive device comprises: a third data processing module and a detection module, and / or, the microservice keep-alive device comprises: a sixth sending module and a fourth data processing module; The third data processing module is used to hijack the status detection request sent by the target registration center to the service side agent through the registration center side agent, and convert the status detection request into protocol data corresponding to the service side agent and send it to the service side agent; The detection module is used to enable the service-side agent to detect the working status of the target microservice based on the status detection request when the status detection request meets the first preset control strategy, and to feedback the working status of the target microservice to the target registration center through the registration center-side agent; The sixth sending module is used to actively send a service keep-alive request that can be understood by the target registration center to the target registration center through the service-side agent based on the first preset control strategy; The fourth data processing module is used to hijack the service keep-alive request through the registration center-side proxy, and send the service keep-alive request to the target registration center if the service keep-alive request complies with the second preset control policy; The microservice keep-alive device also includes: A seventh sending module, configured to enable the target registration center to send a first service list update notification to the controller through the registration center-side agent based on the second preset control strategy when the target registration center determines that the service list has been updated based on the working status of the target microservice; A third response module is used to respond to the first service list update notification through the controller, and send a second service list update notification to the target microservice through the service-side agent based on a third preset control strategy, where the third preset control strategy is a control strategy pre-configured in the controller.
15. A microservice system, It is characterized in that The method comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the microservice registration method according to any one of claims 4 to 7, or, when executed by the processor, implements the steps of the microservice discovery method according to any one of claims 8 to 9, or, when executed by the processor, implements the steps of the microservice keep-alive method according to any one of claims 10 to 11.
16. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the microservice registration method according to any one of claims 4 to 7 are implemented, or when the computer program is executed by the processor, the steps of the microservice discovery method according to any one of claims 8 to 9 are implemented, or when the computer program is executed by the processor, the steps of the microservice keep-alive method according to any one of claims 10 to 11 are implemented.
