CN115002194A - Management method and related device for microservice - Google Patents

Management method and related device for microservice Download PDF

Info

Publication number
CN115002194A
CN115002194A CN202210577580.5A CN202210577580A CN115002194A CN 115002194 A CN115002194 A CN 115002194A CN 202210577580 A CN202210577580 A CN 202210577580A CN 115002194 A CN115002194 A CN 115002194A
Authority
CN
China
Prior art keywords
service
service provider
micro
provider
consumer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210577580.5A
Other languages
Chinese (zh)
Inventor
凌晨
顾欣
王鹏培
刘成锋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202210577580.5A priority Critical patent/CN115002194A/en
Publication of CN115002194A publication Critical patent/CN115002194A/en
Pending legal-status Critical Current

Links

Images

Abstract

The application provides a management method and a related device of micro-services, relates to the field of cloud computing, and can be used in the financial field or other fields. The method comprises the following steps: receiving a service logout request from a first service provider; and sending a notice to the service consumer subscribed to the micro service according to the service logout request and the pre-stored subscription information to indicate that the first service provider does not provide the micro service any more. The method utilizes the registration center as a bridge between the service provider and the service consumer, and the service consumer recording each micro service is pre-stored in the registration center. And when the service provider is offline, notifying the corresponding service consumer according to the prestored subscription information. Therefore, the service consumer does not initiate a service request to the offline service provider any more, thereby reducing the possibility of request failure or overtime and improving the availability and the nondestructive property of the service.

Description

Management method and related device for microservice
Technical Field
The present application relates to the field of cloud computing technologies, and in particular, to a management method and a related apparatus for micro services.
Background
With the rapid development of the internet, the tasks to be processed are heavier and heavier, and the past single application program cannot meet the increasing technical requirements. For this situation, the micro-service architecture is in operation. The micro-service architecture is a new technology for deploying applications in the cloud, and the application upgrading and expanding are facilitated by decomposing the applications into smaller and loosely-coupled micro-services.
Each microservice may be provided by one or more service providers and may be subscribed to by one or more service consumers. However, in some scenarios, a long connection state is not maintained between the service provider and its corresponding service consumer, and therefore, the service provider cannot know which service consumers are connected to it, and cannot send a logoff notification to the corresponding service consumers. This may result in service requests from service consumers failing or timing out, reducing the availability and non-destructiveness of the service.
Disclosure of Invention
The application provides a management method and a related device of micro-services, so as to reduce the possibility of micro-service request failure or overtime and improve the usability and the nondestructive property of the micro-services.
In a first aspect, the present application provides a method for managing a microservice, applied to a registry connected to at least one service provider registered with the registry and at least one service consumer subscribing to the microservice through the registry, each of the at least one service provider being configured to provide the microservice, the method comprising: receiving a service logout request from a first service provider, wherein the service logout request is used for requesting logout of the first service provider and the micro-service provided by the first service provider from a registration center, and the first service provider is any one of at least one service provider; according to the service logout request and the pre-stored subscription information, sending a notice to a service consumer who subscribes the micro service to indicate that the first service provider does not provide the micro service any more; the subscription information records service consumers subscribing to each micro service.
By the method, the registry is used as a bridge between the service provider and the service consumer, and the service consumer recording each micro service is pre-stored in the registry. And when the service provider is offline, notifying the corresponding service consumer according to the prestored subscription information. Therefore, the service consumer does not initiate a service request to the offline service provider any more, thereby reducing the possibility of request failure or overtime and improving the availability and the nondestructive property of the service.
With reference to the first aspect, in some possible implementations of the first aspect, the method further includes: updating a pre-stored service list according to the service logout request, wherein the service list comprises the corresponding relation between each service provider in at least one service provider and the micro service provided by the service provider, and the updated service list does not comprise the corresponding relation between a first service provider and the micro service provided by the first service provider; sending a notification to a service consumer subscribed to the microservice to indicate that the first service provider is no longer providing the microservice, comprising: and sending the updated service list to the service consumer subscribed to the micro service so as to indicate that the first service provider does not provide the micro service any more through the updated service list.
With reference to the first aspect, in some possible implementations of the first aspect, the method further includes: receiving a service subscription request from at least one service consumer, the service subscription request requesting to obtain an up-to-date service list; sending an updated list of services to service consumers subscribed to the microservice, comprising: and sending an updated service list to at least one service consumer based on the service subscription request received last time, wherein the updated service list is the latest service list.
With reference to the first aspect, in some possible implementations of the first aspect, sending a notification to a service consumer subscribed to the micro service to indicate that the first service provider no longer provides the micro service includes: and sending an offline notification to the service consumer subscribed to the micro service, wherein the offline notification is used for notifying the first service provider that the first service provider is offline, and the offline first service provider does not provide the micro service any more.
With reference to the first aspect, in some possible implementations of the first aspect, before receiving a service logout request from the first service provider, the method further includes: receiving a service registration request from at least one service provider, wherein the service registration request from each service provider is used for requesting to register the microservice provided by each service provider in a registration center; and generating a service list according to the service registration request from at least one service provider, wherein the service list comprises the corresponding relation of each service provider in the at least one service provider and the micro-service provided by the service provider.
With reference to the first aspect, in some possible implementations of the first aspect, the method further includes: receiving a service subscription request from at least one service consumer, the service subscription request from each service consumer requesting subscription of a microservice from at least one service provider; generating subscription information based on the service list and a service subscription request from at least one service consumer.
In a second aspect, the present application provides a management method for a microservice, which is applied to a service provider, the service provider being connected to a registry and at least one service consumer, the service provider being a service provider registered in the registry and configured to provide microservices, and the at least one service consumer being configured to subscribe to the microservices from the registry, the method including: sending a service logout request to a registry, wherein the service logout request is used for requesting to logout the micro-service provided by a service provider from the registry; and after the service logout request is sent, closing the micro service, wherein the time interval between the sending of the service logout request and the closing of the micro service is more than the preset time length.
With reference to the second aspect, in some possible implementation manners of the second aspect, the preset duration is related to an effective duration of a service list, the service list includes a correspondence relationship between at least one service provider and the micro service provided by each service provider, and at least one service provider is a service provider connected to a registry.
In a third aspect, the present application provides a management method for a micro service, which is applied to a service consumer, where the service consumer is connected to at least one service provider and a registry, where the at least one service provider is a service provider registered in the registry and is used to provide the micro service, and the service consumer subscribes, in the registry, to the micro service provided by a first service provider of the at least one service provider, and the method includes: receiving a notification from the registry indicating that the first service provider is no longer providing microservice; and updating a local service list based on the notification, wherein the service list comprises the corresponding relation of each service provider in at least one service provider and the micro-service provided by the service provider.
With reference to the third aspect, in some possible implementations of the third aspect, receiving a notification from the registry, the notification indicating that the first service provider is no longer providing the microservice, includes: and receiving an offline notification from the registry, wherein the offline notification is used for notifying the first service provider that the first service provider is offline, and the offline first service provider does not provide the micro service any more.
With reference to the third aspect, in some possible implementations of the third aspect, receiving a notification from the registry, the notification indicating that the first service provider is no longer providing the microservice, includes: receiving a service list from the registry, the service list from the registry not including the first service provider and the microservice provided by the first service provider to indicate that the first service provider no longer provides the microservice.
With reference to the third aspect, in some possible implementation manners of the third aspect, before the receiving the service list from the registry, the method further includes: and sending a service subscription request to the registration center, wherein the service subscription request is used for requesting an up-to-date service list.
With reference to the third aspect, in some possible implementations of the third aspect, the method further includes: when a service consumer accesses a registry, a service list is obtained from the registry.
In a fourth aspect, the present application provides a management apparatus for microservices, the apparatus comprising a transceiver module; the receiving and sending module is used for receiving a service logout request from a first service provider, the service logout request is used for requesting to logout the first service provider and the micro-service provided by the first service provider from a registration center, and the first service provider is any one of at least one service provider; according to the service logout request and the pre-stored subscription information, sending a notice to a service consumer who subscribes the micro service to indicate that the first service provider does not provide the micro service any more; the subscription information records service consumers subscribing to each micro service.
In a fifth aspect, the present application provides a management apparatus for microservices, the apparatus comprising a transceiver module and a processing module; the receiving and sending module is used for sending a service logout request to the registration center, wherein the service logout request is used for requesting to logout the micro-service provided by the service provider from the registration center; the processing module is used for closing the micro-service after sending the service logout request, wherein the time interval between the sending of the service logout request and the closing of the micro-service is longer than the preset time length.
In a sixth aspect, the present application provides a management apparatus for microservices, the apparatus comprising a transceiver module and a processing module; the receiving and sending module is used for receiving a notice from the registration center, and the notice is used for indicating that the first service provider does not provide the microservice any more; the processing module is used for updating a local service list based on the notification, wherein the service list comprises the corresponding relation of each service provider in at least one service provider and the micro-service provided by the service provider.
In a seventh aspect, the present application provides a management apparatus for microservices, including a memory and a processor, where the memory is used to store a computer program, and the processor is used to execute the computer program to perform any one of the possible implementation manners of the first aspect to the third aspect and the first aspect to the third aspect.
In an eighth aspect, the present application provides a computer-readable storage medium comprising a computer program which, when run on a computer, causes the computer to perform the method of any one of the possible implementations of the first to third aspects and the first to third aspects.
In a ninth aspect, the present application provides a computer program product comprising a computer program that, when run on a computer, causes the computer to perform the method of any one of the possible implementations of the first to third aspects and the first to third aspects.
It should be understood that the fourth aspect to the ninth aspect of the present application correspond to the technical solutions of the first aspect to the third aspect of the present application, and the beneficial effects obtained by the aspects and the corresponding possible embodiments are similar, and are not described again.
It should be noted that the management method of the micro service and the related device provided by the present application can be applied to the management of the micro service in the financial field, such as the management of the micro service in the financial field, and can also be applied to the management of the micro service in any field other than the financial field.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
Fig. 1 is a schematic view of a scenario of a management method for a microservice provided in an embodiment of the present application;
FIG. 2 is a schematic flow chart diagram of a method for managing microservices provided by an embodiment of the present application;
FIG. 3 is a flowchart illustrating an implementation manner of a management method for micro services according to an embodiment of the present application;
FIG. 4 is a flowchart illustrating another implementation manner of a management method for micro services according to an embodiment of the present application;
FIG. 5 is a schematic block diagram of a management apparatus for microservices provided by an embodiment of the present application;
FIG. 6 is another schematic block diagram of a management apparatus for microservices provided by embodiments of the present application;
fig. 7 is another schematic block diagram of a management apparatus for microservices provided by an embodiment of the present application.
With the above figures, there are shown specific embodiments of the present application, which will be described in more detail below. These drawings and written description are not intended to limit the scope of the inventive concepts in any manner, but rather to illustrate the inventive concepts to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
To make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments.
Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the embodiments of the present application, the terms "first", "second", and the like are used for distinguishing similar objects, and are not necessarily used for describing a particular order or sequence. Furthermore, the terms "comprises" and any variations thereof, are intended to cover non-exclusive inclusions.
During the release or update of the micro-service, the micro-service will stop the service and the corresponding service provider will go offline. If the service provider immediately goes offline when stopping the service, the micro service being processed is disabled, and the subsequent service consumer may still send a service request to the service provider, however, the service provider is offline, the request fails or times out, and the micro service availability and the micro service non-loss are reduced.
In the existing scheme, a service provider actively sends an offline notification to a service consumer connected to the service provider when stopping service, and after receiving the offline notification, the service consumer shields the service provider according to the offline notification. However, in some scenarios, the service provider and its corresponding service consumer do not maintain a long connection state, and therefore, the service provider cannot send offline notifications to all service consumers, and some service consumers may not be aware that the service provider is offline.
In view of this, the present application provides a management method for micro services, which uses a registry as a bridge between a service provider and a service consumer, and prestores, in the registry, the service consumer recording each micro service. And when the service provider is offline, notifying the corresponding service consumer according to the prestored subscription information. Therefore, the service consumer does not initiate a service request to the offline service provider any more, so that the probability of failure or overtime of the micro-service request can be reduced, and the usability and the lossiness of the micro-service can be improved.
Fig. 1 is a scene schematic diagram of a management method of a microservice provided in an embodiment of the present application.
As shown in fig. 1, the scenario includes a service provider 101, a service consumer 102, and a registry 103.
The service provider 101 is a server that provides a microservice, and can perform operations such as service registration, renewal, and logoff with the registry 103. The registered data includes information related to the microservice, such as an application name, an Internet Protocol (IP) address of an instance, a port, a domain name, and the like.
The service consumer 102 is a service consumer who calls a microservice, acquires call information of the service provider 101 from the registry 103, and communicates with the service provider 101 by remote call.
The registry 103 stores a service list, which is a database containing network addresses of service instances provided by the service provider 101, and the service provider 101 can provide a plurality of service instances.
The calling information reported by the service provider 101 includes a network address of the service instance, and the registration center 103 stores the received network address of the service instance in the service list.
Alternatively, the service provider 101 may provide a plurality of service instances, where the plurality of service instances respectively correspond to a plurality of network addresses; when a service consumer 102 initiates a service request, a call may be initiated to one of the plurality of service instances using a load balancing algorithm for the plurality of network addresses present for the target service.
Alternatively, service consumer 102 or service provider 101 may periodically synchronize and cache a list of services from registry 103, and may initiate a call to a service through the cached list of services when communication between service consumer 102 or service provider 101 and registry 103 is interrupted.
As an example, the implementation of the service discovery function may use a "Eureka" framework, the service provider 101 and the service consumer 102 may include a "Eureka Client", and the registry 103 may include a "Eureka Server". Wherein, the 'Eureka Server' is a registration center of a service discovery framework, and adopts an application-level service discovery mode; the "Eureka Client" is a Client module encapsulated for simplifying interaction with the "Eureka Server".
Optionally, the service discovery may also choose to use the "Consul" or "Zookeeper" framework.
The following describes the technical solutions of the present application and how to solve the above technical problems with specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 2 is a flowchart illustrating a management method for a microservice provided by an embodiment of the present application, where the method is applied to a registry, the registry being connected to at least one service provider registered in the registry and at least one service consumer subscribing to the microservice through the registry, and each service provider in the at least one service provider is used for providing the microservice. Here, a registry, for example, the registry 103 in fig. 1, may be a component configured in the registry, or may be a functional module or software for implementing part or all of the functions of the registry. This is not a limitation of the present application.
In this embodiment of the present application, the registry may be pre-stored with subscription information, and the subscription information may be used to record the service consumer of each micro service. The registry may further have a service list prestored therein, where the service list includes a correspondence relationship between each service provider and the microservices provided by the service provider among at least one service provider registered in the registry.
The individual steps in method 200 are described in detail below.
In step 210, a service logoff request is received from a first service provider.
The service logout request is used for requesting the registry to logout a first service provider and the micro-service provided by the first service provider, wherein the first service provider is any one of at least one service provider.
As an example, the service provider 1 (i.e., an example of a first service provider) may send a service logout request to the registry in the event that the service provider 1 goes offline.
Optionally, the registry updates the service list according to a service logout request received from the first service provider, where the updated service list does not include a correspondence between the first service provider and the microservice provided by the first service provider.
An example, the original service list is: the service provider 1, the service provider 2, and the service provider 3 correspond to "user services"; the service provider 4, the service provider 5, and the service provider 6 correspond to "commodity services". The updated list is: the service provider 2 and the service provider 3 correspond to "user service"; the service provider 4, the service provider 5, and the service provider 6 correspond to "commodity services".
In step 220, a notification is sent to the service consumer subscribed to the micro service according to the service logout request and the pre-stored subscription information to indicate that the first service provider no longer provides the micro service.
Optionally, sending a notification to the service consumer subscribed to the microservice to indicate that the first service provider is no longer providing the microservice may be in the form of: sending the updated service list to a service consumer subscribing to the micro-service to indicate that the first service provider no longer provides the micro-service through the updated service list; or sending an offline notification to the service consumer who subscribes the micro service, wherein the offline notification is used for notifying the first service provider that the first service provider is offline, and the offline first service provider does not provide the micro service any more.
After receiving the notification, the service consumer updates the locally stored service list according to the content of the notification.
As an example, the original subscription relationship of the service consumer to the microserver is: service consumer 1 subscribes to "user services"; service consumer 2 subscribes to "user service" and "commodity service"; the service consumer 3 subscribes to "commodity services". After the service provider 1 goes offline, the registry sends an updated service list to the service consumers subscribed to the "user services". For example, a service list of updated "user services" is sent to the service consumer 1 and the service consumer 2, including the service provider 2 and the service provider 3; since the service consumer 3 is not subscribed to "user services", there is no need to send an updated list of services to the service consumer 3. The service consumer 1 and the service consumer 2 replace the originally stored service list with the updated service list.
As another example, the original subscription relationship of the service consumer to the microserver is: service consumer 1 subscribes to "user services"; service consumer 2 subscribes to "user service" and "commodity service"; the service consumer 3 subscribes to "commodity service". After the service provider 1 goes offline, the registry sends an offline notification of the service provider 1 to the service consumers subscribed to the "user service", and both the service consumers 1 and 2 delete the service provider 1 from the originally stored service list. Since the service consumer 3 does not subscribe to "user services", the service consumer 3 does not need to update the originally stored list of services.
The registry sends a notification to the service consumer to update the local service list of the service consumer, and the service consumer may not receive the notification due to network reasons and other factors, so that the locally stored service list cannot be updated.
In order to avoid this as much as possible, a deactivation mechanism may be introduced, that is, a validity duration is set for the service list stored by the service consumer, that is, the service list stored by the service consumer is not always valid, but has a validity duration. When the service list is stored on the service consumer for a time longer than its effective duration, the service list is invalidated.
It will be appreciated that regardless of the form in which the locally stored service list is updated, the validity of the service list will be re-timed after the service list update.
Before the service list is invalid, if a service consumer needs to call the micro service, the service consumer can directly inquire a locally stored service list and call the corresponding micro service by a corresponding service provider according to the locally stored service list; and after the service list is invalid, if the service consumer needs to invoke the micro-service, the service consumer sends a service subscription request to the registration center again, and the registration center returns the service list to the service consumer who subscribes the micro-service according to the service subscription request so as to update the service list locally stored by the service consumer.
Based on the above invalidation mechanism, even if the registry has not sent a new service list to the service consumer all the time, the service list will be invalidated as long as the time that the service list is stored in the service consumer exceeds its validity time. When the service consumer needs to call the micro-service again, the subscription request is sent to the registration center again to update the local service list.
And the first service provider does not close the micro-service immediately after sending the service logout request to the registry, but closes the micro-service after waiting for a period of time. The waiting time period should be slightly longer than the effective duration of the service list, so that it can be ensured that during the waiting time period of the first service provider without closing the microservice, the service consumer updates the local service list, knows that the first service provider will be offline, and does not initiate a new service request to the first service provider.
Therefore, a time period may be preset, and the preset time period is related to the effective time period of the service list. The first service provider may close the microservice after waiting for more than the preset amount of time.
It should be understood that the preset duration may be variable, for example, in a time period when the service provider frequently changes the online and the offline, such as a project production period, the preset duration may be shorter, which is beneficial to sensing the change of the service provider in time and shortening the time for the service provider to stop the service; and in the time period of stable operation of the service, the service list is basically unchanged, the preset time can be longer, and the performance of the server is saved.
Based on the method, the registry is used as a bridge between the service provider and the service consumer. And the service consumer recording each micro service is prestored in the registration center. And when the service provider is offline, notifying the corresponding service consumer according to the prestored subscription information. Therefore, the service consumer does not initiate a service request to the offline service provider any more, thereby reducing the possibility of request failure or overtime and improving the availability and the nondestructive property of the service.
Prior to step 210, the service provider may complete registration of the microservices that it provides at a registry. The registry receives a service registration request from at least one service provider and generates a service list according to the service registration request. The service registration request is used for requesting registration of the corresponding relationship between each service provider and the micro service provided by the service provider in the registration center, namely, the registration center can record the corresponding relationship between each service provider and the micro service provided by the service provider according to the service registration request; the service list includes a correspondence of each of the at least one service provider and the microservices that it provides.
An example, microservices include "user services" and "commodity services," each provided by 3 service providers, respectively. The service provider 1, the service provider 2, and the service provider 3 correspond to "user services"; the service provider 4, the service provider 5, and the service provider 6 correspond to "commodity services".
When a service consumer subscribes to the micro service for the first time, a service subscription request is sent to the registry, and the service subscription request is used for requesting to pull a provider list subscribed to the micro service from the registry. And after receiving the service subscription request, the registration center generates subscription information according to the service list and the service subscription request.
As an example, such subscription information may be maintained in the form of a mapping. The service consumer 1 sends a service subscription request: subscription "user services"; the service consumer 2 sends a service subscription request: subscription to "user services" and "goods services"; the service consumer 3 sends a service subscription request: subscribe to "goods services".
Thus, the subscription information is: the user service corresponds to a consumption service party 1 and a service consumption party 2; the "commodity service" corresponds to the service consumer 2 and the service consumer 3.
As another example, such subscription information may also be stored in the form of an event listener. The registry establishes an Event 1 "Event-P1" for the microservice of "user service" and an Event Listener "Event-P1-Listener-C1" for the Event "Event-P1" to inform the service consumer 1 about the Event "Event-P1" for the microservice of "user service". Similarly, there are Event listeners "Event-P1-Lister-C2", "Event-P1-Lister-C3" for the service consumers 2, 3; aiming at the microservice of the commodity service, Event 2, Event-P2, Event-P2, Listener-C1 and other Event listeners are established, and the details are not repeated herein.
After the subscription information is generated by the registry, the corresponding service list can be sent to each service consumer. For example, a service list is transmitted to the service consumer 1, and "user service" includes the service provider 1, the service provider 2, and the service provider 3; the service consumer 2 sends a service list, the "user service" includes the service provider 1, the service provider 2 and the service provider 3, and the "commodity service" includes the service provider 4, the service provider 5 and the service provider 6; the service consumer 3 sends a list of services, "commodity services" including the service provider 4, the service provider 5 and the service provider 6.
After receiving the service list, each service consumer can initiate a request to a corresponding service provider according to the service list under the condition that a certain micro service needs to be called.
Each service consumer may also periodically obtain a service list from the registry based on the failure mechanism described above, and update the local service list based on the last obtained service list. In this manner, each service consumer may also invoke the microservice based on the latest service list. Therefore, the method is beneficial to avoiding initiating a service request to the offline service provider, reducing the possibility of request failure or overtime and improving the availability and the nondestructive property of the service.
Fig. 3 is a flowchart illustrating an implementation manner of a management method for a microservice provided in an embodiment of the present application.
In step 301, the service provider sends a service logout request to the registry;
in step 302, the registry sends a notification to the service consumer indicating that the service provider is no longer providing microservices;
in step 303, the service consumer updates the local service list based on the notification;
in step 304, after the service provider sends the service logout request, the service provider closes the microservice after the interval time is longer than the preset time.
It can be understood that, since the registry can send the notification to the service consumer in time after receiving the service cancellation request of the service provider, the offline service provider can be quickly notified to the service consumer, a service request is prevented from being initiated to the offline service provider, and the possibility of request failure or timeout is reduced.
Fig. 4 is a flowchart illustrating another implementation manner of a management method for a microservice provided in an embodiment of the present application.
In step 401, the service provider sends a service logout request to the registry;
in step 402, the registry updates a local list of services;
in step 403, the registry sends a notification failure to the service consumer;
in step 404, after the service list locally stored by the service consumer is invalid, the micro service needs to be called, and a service subscription request is sent to the registration center again;
in step 405, the registry sends a notification to the service consumer indicating that the service provider is no longer providing microservices;
in step 406, the service consumer updates the local service list based on the notification;
in step 407, after the service provider sends the service logout request, the service provider closes the microservice after the interval time is longer than the preset time.
It should be understood that, in the flows shown in fig. 3 and fig. 4, specific implementation of each step can refer to the related description related to fig. 2, and for brevity, will not be described again here.
Fig. 5 is a schematic block diagram of a management apparatus for a microservice provided in an embodiment of the present application. The device may be the registration center 103 in fig. 1, and as shown in fig. 5, the management device 500 of the microservice may include a transceiver module 510.
The transceiver module 510 may be configured to receive a service logout request from a first service provider, where the service logout request is used to request logout of the first service provider and a microservice provided by the first service provider from a registry, where the first service provider is any one of at least one service provider; according to the service logout request and the pre-stored subscription information, sending a notice to a service consumer who subscribes the micro service to indicate that the first service provider does not provide the micro service any more; the subscription information records service consumers subscribing to each micro service.
Optionally, the management apparatus 500 of the microservice may further include a processing module 520.
Optionally, the processing module 520 may be further configured to update a pre-stored service list according to the service logout request, where the service list includes a corresponding relationship between each service provider in at least one service provider and the micro service provided by the service provider, and the updated service list does not include a corresponding relationship between a first service provider and the micro service provided by the service provider.
Optionally, the transceiver module 510 is further configured to send the updated service list to the service consumer subscribed to the micro service, so as to indicate that the first service provider no longer provides the micro service through the updated service list.
Optionally, the transceiver module 510 is further configured to receive a service subscription request from at least one service consumer, where the service subscription request is used to request to obtain an up-to-date service list; and sending an updated service list to at least one service consumer based on the service subscription request received last time, wherein the updated service list is the latest service list.
Optionally, the transceiver module 510 may be configured to send an offline notification to a service consumer subscribed to the micro service, where the offline notification is used to notify that the first service provider is offline, and the offline first service provider no longer provides the micro service.
Optionally, the transceiver module 510 is further configured to receive a service registration request from at least one service provider, where the service registration request from each service provider is used to request registration of the microservice provided by each service provider in a registry; the processing module 520 may be further configured to generate a service list according to the service registration request from the at least one service provider, where the service list includes a corresponding relationship between each service provider of the at least one service provider and the microservice provided by the service provider.
Optionally, the transceiver module 510 is further configured to receive a service subscription request from at least one service consumer, the service subscription request from each service consumer being used to request a subscription to a microservice from at least one service provider; the processing module 520 may be further configured to generate subscription information based on the service list and a service subscription request from at least one service consumer.
Fig. 6 is another schematic block diagram of a management apparatus for microservices provided by an embodiment of the present application. The device may be the service provider 101 in fig. 1, and as shown in fig. 6, the management device 600 of the microservice may include a transceiver module 610 and a processing module 620.
The transceiver module 610 may be configured to send a service logout request to the registry, where the service logout request is used to request to logout a microservice provided by a service provider from the registry; the processing module 620 may be configured to close the micro-service after sending the service logout request, where a time interval between sending the service logout request and closing the micro-service is greater than a preset time duration.
The device may also be the service consumer 102 in fig. 1, and as shown in fig. 6, the management device 600 of the microservice may include a transceiver module 610 and a processing module 620.
Wherein the transceiver module 610 is operable to receive a notification from the registry indicating that the first service provider is no longer providing microservice; the processing module 620 may be configured to update a local service list based on the notification, where the service list includes a correspondence between each of the at least one service provider and the microservice provided by the service provider.
Fig. 7 is another schematic block diagram of a management apparatus for microservices provided by an embodiment of the present application. As shown in fig. 7, the apparatus 700 may include at least one processor 710 for implementing the functions of the management apparatus of the microservice in the method provided by the present application. For details, reference is made to the detailed description in the method example, which is not repeated herein.
The apparatus 700 may also include a memory 720 for storing program instructions and/or data. A memory 720 is coupled to the processor 710. The coupling in this application is an indirect coupling or communication connection between devices, units or modules, and may be in an electrical, mechanical or other form, and is used for information interaction between the devices, units or modules. The processor 710 may operate in conjunction with the memory 720. Processor 710 may execute program instructions stored in memory 720. At least one of the at least one memory may be included in the processor.
The apparatus 700 may also include a communication interface 730 for communicating with other devices over a transmission medium, such that the apparatus used in the apparatus 700 may communicate with other devices. The communication interface 730 may be, for example, a transceiver, an interface, a bus, a circuit, or a device capable of performing a transceiving function. Processor 710 may utilize communication interface 730 to send and receive data and/or information and may be used to implement the management methods of microservices described in the embodiments corresponding to fig. 2, 3, or 4.
The specific connection medium between processor 710, memory 720 and communication interface 730 is not limited in this application. In fig. 7, processor 710, memory 720 and communication interface 730 are connected by bus 740. The bus 740 is shown in fig. 7 by a thick line, and the connection manner between other components is only for illustrative purposes and is not limited thereto. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 7, but that does not indicate only one bus or one type of bus.
In the embodiments of the present application, the processor may be a general purpose processor, a digital signal processor, an application specific integrated circuit, a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof, and may implement or perform the methods, steps, and logic blocks disclosed in the present application. A general purpose processor may be a microprocessor or any conventional processor or the like. The steps of a method disclosed in connection with the present application may be embodied directly in a hardware processor, or in a combination of the hardware and software modules in the processor.
According to the method provided by the present application, there is also provided a computer-readable storage medium storing program code, which when run on a computer, causes the computer to perform the management method of the microservice described in the embodiment corresponding to fig. 2, fig. 3 or fig. 4.
In accordance with the methods provided herein, the present application also provides a computer program product comprising: computer program code. When the computer program code runs on a computer, the computer is caused to perform the method for managing a microservice as described in the embodiments corresponding to fig. 2, fig. 3 or fig. 4.
The solutions provided in the present application may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the procedures or functions described in accordance with the present application are generated, in whole or in part. The computer may be a general purpose computer, special purpose computer, computer network, network appliance, terminal device, or other programmable apparatus. The computer instructions may be stored on a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website, computer, server, or data center to another website, computer, server, or data center via wire, such as coaxial cable, fiber optic, Digital Subscriber Line (DSL), or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium such as a Digital Video Disc (DVD), or a semiconductor medium, among others.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (15)

1. A method for managing microservices, applied to a registry connected to at least one service provider registered with the registry and to at least one service consumer subscribing to microservices through the registry, each of the at least one service provider being adapted to provide microservices, the method comprising:
receiving a service logout request from a first service provider, wherein the service logout request is used for requesting to logout the first service provider and the micro service provided by the first service provider from the registry, and the first service provider is any one of the at least one service provider;
sending a notice to a service consumer subscribing the micro service according to the service logout request and prestored subscription information so as to indicate that the first service provider does not provide the micro service any more; and the subscription information records service consumers subscribing to each micro service.
2. The method of claim 1, wherein the method further comprises:
updating a pre-stored service list according to the service logout request, wherein the service list comprises the corresponding relation between each service provider in the at least one service provider and the micro service provided by the service provider, and the updated service list does not comprise the corresponding relation between the first service provider and the micro service provided by the first service provider;
the sending a notification to a service consumer subscribed to the microservice to indicate that the first service provider is no longer providing the microservice, comprising:
sending an updated service list to a service consumer subscribed to the micro-service to indicate, by the updated service list, that the first service provider is no longer providing the micro-service.
3. The method of claim 2, wherein the method further comprises:
receiving a service subscription request from the at least one service consumer, the service subscription request requesting to obtain an up-to-date service list;
the sending the updated service list to the service consumers subscribed to the micro-service comprises:
and sending the updated service list to the at least one service consumer based on the service subscription request received last time, wherein the updated service list is the latest service list.
4. The method of claim 1, wherein said sending a notification to a service consumer subscribed to the microservice to indicate that the first service provider is no longer providing the microservice comprises:
and sending an offline notification to a service consumer subscribing the micro service, wherein the offline notification is used for notifying the first service provider that the micro service is offline, and the offline first service provider does not provide the micro service any more.
5. The method of any of claims 1-4, wherein prior to said receiving a service logoff request from a first service provider, the method further comprises:
receiving a service registration request from the at least one service provider, the service registration request from each service provider being used for requesting registration of the microservice provided by each service provider in the registry;
and generating a service list according to the service registration request from the at least one service provider, wherein the service list comprises the corresponding relation of each service provider in the at least one service provider and the micro-service provided by the service provider.
6. The method of claim 5, wherein the method further comprises:
receiving a service subscription request from the at least one service consumer, the service subscription request from each service consumer requesting a subscription to a microservice from the at least one service provider;
and generating the subscription information according to the service list and a service subscription request from the at least one service consumer.
7. A method for managing microservices, applied to a service provider connected to a registry and to at least one service consumer, the service provider being a service provider registered in the registry and adapted to provide microservices, the at least one service consumer being adapted to subscribe to microservices from the registry, the method comprising:
sending a service logout request to the registry, wherein the service logout request is used for requesting to logout the micro-service provided by the service provider from the registry;
and after the service logout request is sent, closing the micro service, wherein the time interval between the sending of the service logout request and the closing of the micro service is longer than the preset time length.
8. The method of claim 7, wherein the predetermined duration is associated with a duration of validity of a service list, the service list including at least one service provider corresponding to the microservices provided by each service provider, the at least one service provider being a service provider connected to the registry.
9. A method for managing microservices, applied to a service consumer connected to at least one service provider and to a registry, the at least one service provider being a service provider registered in the registry for providing microservices, the service consumer subscribing to a microservices provided by a first service provider of the at least one service provider in the registry, the method comprising:
receiving a notification from the registry indicating that the first service provider is no longer providing the microservice;
and updating a local service list based on the notification, wherein the service list comprises the corresponding relation of each service provider in the at least one service provider and the micro-service provided by the service provider.
10. An apparatus for managing microservices, comprising:
a transceiver module, configured to receive a service logout request from a first service provider, where the service logout request is used to request logout of the first service provider and a micro service provided by the first service provider from the registry, and the first service provider is any one of the at least one service provider; sending a notice to a service consumer subscribing the micro service according to the service logout request and prestored subscription information so as to indicate that the first service provider does not provide the micro service any more; and the subscription information records service consumers subscribing to each micro service.
11. An apparatus for managing microservices, comprising:
the system comprises a receiving and sending module, a service logout module and a service logout module, wherein the receiving and sending module is used for sending a service logout request to a registration center, and the service logout request is used for requesting to logout the micro service provided by a service provider from the registration center;
and the processing module is used for closing the micro-service after the service logout request is sent, wherein the time interval between the sending of the service logout request and the closing of the micro-service is longer than the preset time length.
12. An apparatus for managing microservices, comprising:
a transceiver module for receiving a notification from a registry indicating that a first service provider is no longer providing microservice;
and the processing module is used for updating a local service list based on the notification, wherein the service list comprises the corresponding relation of each service provider in at least one service provider and the micro-service provided by the service provider.
13. A management device for micro-services, comprising a memory and a processor, wherein,
the memory is used for storing a computer program;
the processor is configured to execute the computer program to implement the method according to any one of claims 1 to 9.
14. A computer-readable storage medium, comprising a computer program which, when run on a computer, causes the computer to perform the method of any one of claims 1 to 9.
15. A computer program product, comprising a computer program which, when executed, causes a computer to perform the method of any one of claims 1 to 9.
CN202210577580.5A 2022-05-25 2022-05-25 Management method and related device for microservice Pending CN115002194A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210577580.5A CN115002194A (en) 2022-05-25 2022-05-25 Management method and related device for microservice

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210577580.5A CN115002194A (en) 2022-05-25 2022-05-25 Management method and related device for microservice

Publications (1)

Publication Number Publication Date
CN115002194A true CN115002194A (en) 2022-09-02

Family

ID=83029590

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210577580.5A Pending CN115002194A (en) 2022-05-25 2022-05-25 Management method and related device for microservice

Country Status (1)

Country Link
CN (1) CN115002194A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108134766A (en) * 2016-12-01 2018-06-08 阿里巴巴集团控股有限公司 A kind of method, apparatus, system, server and client for servicing publication
CN109725920A (en) * 2018-12-29 2019-05-07 咪咕文化科技有限公司 A kind of update method of Service Instance, device and storage medium
CN110489248A (en) * 2019-08-22 2019-11-22 中国工商银行股份有限公司 System-down method, service calling method, device and storage medium
CN113542319A (en) * 2020-04-15 2021-10-22 华为技术有限公司 Service providing entity change notification method, device and system used in Dubbo framework
CN113986316A (en) * 2021-12-27 2022-01-28 北京结慧科技有限公司 Automatic deployment method of micro-service

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108134766A (en) * 2016-12-01 2018-06-08 阿里巴巴集团控股有限公司 A kind of method, apparatus, system, server and client for servicing publication
CN109725920A (en) * 2018-12-29 2019-05-07 咪咕文化科技有限公司 A kind of update method of Service Instance, device and storage medium
CN110489248A (en) * 2019-08-22 2019-11-22 中国工商银行股份有限公司 System-down method, service calling method, device and storage medium
CN113542319A (en) * 2020-04-15 2021-10-22 华为技术有限公司 Service providing entity change notification method, device and system used in Dubbo framework
CN113986316A (en) * 2021-12-27 2022-01-28 北京结慧科技有限公司 Automatic deployment method of micro-service

Similar Documents

Publication Publication Date Title
US10834049B2 (en) Systems and methods for dynamically registering endpoints in a network
JP5107377B2 (en) Apparatus and associated method for facilitating delivery and processing of push content
CN110601981A (en) Service routing method, service provider cloud domain and service calling cloud domain
CN114048046B (en) Service calling method and device and load balancing equipment
CN109302437B (en) Method and device for redirecting website
CN112565406B (en) Gray release method, gray release system and electronic equipment
CN110505318B (en) Uniform resource locator addressing method and device, and network system
EP2974159B1 (en) Method, device and system for voice communication
CN111212099A (en) Micro-service management method and device
EP2686981B1 (en) Method and system for managing contact information in a universal plug and play home network environment
US20040230943A1 (en) System and method for managing information technology resources
US20070150540A1 (en) Presence and peer launch pad
CN110730197A (en) Service discovery method and system
CN109743367B (en) Service processing method and device, electronic equipment and readable storage medium
CN115834668B (en) Cluster node control method, device, equipment, storage medium and program product
CN115002194A (en) Management method and related device for microservice
CN113553206B (en) Data event execution method and device, electronic equipment and computer readable medium
CN115629909A (en) Service data processing method and device, electronic equipment and storage medium
CN112953719B (en) Token authentication method and device
CN104346228A (en) Application program sharing method and terminal
CA3084093C (en) Exchange, communication system, registration method, and program
CN109120692B (en) Method and apparatus for processing requests
CN113742617A (en) Cache updating method and device
US8046419B2 (en) Method of processing open asynchronous application service event and open web service gateway implementing the same
US20240089339A1 (en) Caching across multiple cloud environments

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination