CN115859266A - Micro-service management method, device, medium and computing equipment - Google Patents

Micro-service management method, device, medium and computing equipment Download PDF

Info

Publication number
CN115859266A
CN115859266A CN202211644499.0A CN202211644499A CN115859266A CN 115859266 A CN115859266 A CN 115859266A CN 202211644499 A CN202211644499 A CN 202211644499A CN 115859266 A CN115859266 A CN 115859266A
Authority
CN
China
Prior art keywords
micro
service
task
code
intercepted
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
CN202211644499.0A
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.)
Hangzhou Langhe Technology Co Ltd
Original Assignee
Hangzhou Langhe Technology Co Ltd
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 Hangzhou Langhe Technology Co Ltd filed Critical Hangzhou Langhe Technology Co Ltd
Priority to CN202211644499.0A priority Critical patent/CN115859266A/en
Publication of CN115859266A publication Critical patent/CN115859266A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The embodiment of the invention provides a micro-service management method, a micro-service management device, a micro-service management medium and computing equipment, wherein the method comprises the following steps: monitoring state information of a micro-service management container for deploying micro-services, and determining a micro-service operation method to be intercepted based on the state information; performing method interception on an original code of the executed micro service based on the micro service operation method, skipping to an enhanced code corresponding to the micro service, and executing the enhanced code to preferentially complete a pre-task corresponding to a target task; and responding to the completion of the preposed task, and continuously executing the residual original code after the micro service is intercepted so as to complete the target task. The invention can reduce the abnormal operation probability of the micro-service management system and improve the operation stability of the micro-service management system.

Description

Micro-service management method, device, medium and computing equipment
Technical Field
The embodiment of the invention relates to the technical field of computer application, in particular to a micro-service management method, a micro-service management device, a micro-service management medium and a computing device.
Background
This section is intended to provide a background or context to the embodiments of the invention that are recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
Microservice technology is a software development technology whose architecture is a variant of the Service Oriented Architecture (SOA) architecture. The microservice technology advocates dividing a single application into a set of small services (called microservices), and the microservices are coordinated and matched with each other to provide corresponding services for users. Each microservice runs in an independent process corresponding to the microservice and can be independently deployed into a production environment, a class production environment, etc., and the microservices communicate with each other using a lightweight communication mechanism (usually a HTTP-based RESTful API). Micro-services are built around specific business functions, one micro-service performing one business function.
Because the micro-services are independently operated, the micro-services can be updated, deployed and expanded aiming at each micro-service so as to meet the requirements on specific functions of the application program. On the basis, the micro-service has the advantages of high development efficiency, simplicity in deployment, flexibility in expansion, reusability of codes, capability of flexibly coping with faults and the like. Thus, microservices are now being used more and more widely. In this case, how to effectively manage the micro-services becomes a problem of great concern.
Disclosure of Invention
In this context, embodiments of the present invention are intended to provide a microservice management method, apparatus, medium and computing device.
In a first aspect of embodiments of the present invention, there is provided a method for micro-service management, the method including:
monitoring state information of a micro-service management container for deploying micro-services, and determining a micro-service operation method to be intercepted based on the state information;
performing method interception on an original code of the executed micro service based on the micro service operation method, skipping to an enhanced code corresponding to the micro service, and executing the enhanced code to preferentially complete a front task corresponding to a target task;
and responding to the completion of the preposed task, and continuously executing the residual original code after the micro service is intercepted so as to complete the target task.
In a second aspect of embodiments of the present invention, there is provided a microservice management apparatus, the apparatus comprising:
the monitoring module is used for monitoring the state information of the micro-service management container for deploying the micro-service and determining the micro-service operation method to be intercepted based on the state information;
the enhancement module is used for intercepting an original code of the executed micro service based on the micro service operation method, jumping to an enhancement code corresponding to the micro service, and executing the enhancement code to preferentially complete a front task corresponding to a target task;
and the execution module is used for responding to the completion of the preposed task and continuously executing the residual original codes after the micro service is intercepted so as to complete the target task.
In a third aspect of embodiments of the present invention, there is provided a medium having stored thereon a computer program that, when executed by a processor, implements any of the above-described microservice management methods.
In a fourth aspect of embodiments of the present invention, there is provided a computing device comprising:
a processor;
a memory for storing a processor executable program;
wherein, the processor realizes any one of the above micro-service management methods by running the executable program.
According to the embodiment of the invention, before a target task is executed, based on a micro-service operation method determined according to state information of a micro-service management container for deploying micro-services, original codes of the executed micro-services are intercepted by a method, and jump to enhancement codes corresponding to the micro-services, the enhancement codes are executed to complete a preposed task corresponding to the target task preferentially, and then after the preposed task is completed, the rest original codes after the micro-services are intercepted are continuously executed to complete the target task.
By adopting the mode, the micro-service management process can be optimized, and the preposed task corresponding to the target task is ensured to be completed before the target task is executed, so that the abnormal operation probability of the micro-service management system can be reduced, and the operation stability of the micro-service management system is improved.
Drawings
The above and other objects, features and advantages of exemplary embodiments of the present invention will become readily apparent from the following detailed description read in conjunction with the accompanying drawings. Several embodiments of the invention are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which:
FIG. 1 is a schematic diagram illustrating an online flow of a microservice in the related art;
FIG. 2 is a schematic diagram schematically illustrating a micro-service offline flow in the related art;
FIG. 3 schematically illustrates a diagram of a microservice management scenario according to an embodiment of the invention;
FIG. 4 schematically illustrates a flow chart of a method of microservice management according to an embodiment of the present invention;
FIG. 5 schematically illustrates a flow chart of a microservice online method according to an embodiment of the present invention;
FIG. 6 is a schematic diagram schematically illustrating an on-line flow of a microservice according to an embodiment of the present invention;
FIG. 7 schematically illustrates a flow chart of a microservice offline method in accordance with an embodiment of the present invention;
FIG. 8 schematically illustrates a diagram of a microservice offline flow in accordance with an embodiment of the present invention;
FIG. 9 schematically shows a schematic view of a medium according to an embodiment of the invention;
FIG. 10 schematically illustrates a block diagram of a microservice management apparatus according to an embodiment of the present invention;
FIG. 11 schematically shows a schematic diagram of a computing device according to an embodiment of the invention.
In the drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
Detailed Description
The principles and spirit of the present invention will be described with reference to a number of exemplary embodiments. It is understood that these embodiments are given solely for the purpose of enabling those skilled in the art to better understand and to practice the invention, and are not intended to limit the scope of the invention in any way. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
As will be appreciated by one skilled in the art, embodiments of the present invention may be embodied as a system, apparatus, device, method, or computer program product. Thus, the present invention may be embodied in the form of: entirely hardware, entirely software (including firmware, resident software, micro-code, etc.), or a combination of hardware and software.
According to the embodiment of the invention, a micro-service management method, a micro-service management device, a micro-service management medium and a computing device are provided.
In this document, any number of elements in the drawings is by way of example and not by way of limitation, and any nomenclature is used solely for differentiation and not by way of limitation.
The principles and spirit of the present invention are explained in detail below with reference to several exemplary embodiments of the present invention.
Summary of The Invention
Spring is a lightweight container framework for Control Inversion (IoC, inversion of Control) and Aspect Oriented Programming (AOP). This framework was originally designed to solve the problem of heavy and cumbersome EJB (Enterprise Java Beans) development, spring uses a basic JavaBean to accomplish what was previously only possible with EJBs, providing a simple and practical solution for J2EE (Java 2Platform Enterprise Edition). Spring improves coding efficiency and reduces overall development time, because it is lightweight, it can efficiently use system resources and provide an excellent development experience. Spring is responsible for infrastructure, eliminating cumbersome configuration work, allowing developers to focus on the business logic of the application.
Spring Boot is an extension of the Spring framework that eliminates the XML configuration required to set up an application. The Spring Boot may be viewed as a Spring-based suite that pre-assembles a series of components of Spring such that a Spring-based Java application may be developed with as little code and configuration as possible.
The Spring Cloud is a development kit of a micro-service architecture implemented based on Spring Boot. Spring Cloud is an ordered collection of a series of frameworks. The Spring Cloud skillfully simplifies the development of infrastructure of a distributed system by utilizing the development convenience of the Spring Boot, such as components of service registration, service discovery, configuration center, message bus, load balancing, breaker, data monitoring and the like, and can realize one-key starting and deployment by adopting the development style of the Spring Boot.
Writing an application program using the Spring framework is simple because a great deal of cumbersome processes are processed by replacing a developer with a Spring container, which can be said to be the core of the Spring framework. The Spring container is used to manage objects.
Among springs, an object that constitutes a Java application backbone and is managed by a Spring container based on IoC technology is called bean. beans are objects instantiated, assembled and managed by Spring containers. That is, the Spring container creates objects, connects objects, configures objects, and manages the entire lifecycle of objects from creation to destruction.
Java is an object-oriented programming language, and objects are the core of object-oriented application programming. The objects cooperate with each other to realize the functions of the application program together.
Java objects are members (also called instances) of Java classes. Each object has an identity, an action, and a state. The state of an object is stored in fields (variables) and methods (functions) show the behavior of the object. Objects are created at runtime from templates, also referred to as classes.
Thus, for any one microservice developed using Spring Cloud, the microservice deployment requires the assistance of Spring containers. Instantiation and initialization of the service function and component dependence of the micro service are completed by the Spring container, namely after the Spring container is started, the micro service can be deployed to provide the service function corresponding to the micro service externally. Correspondingly, if the service function corresponding to the micro service is to be stopped being provided, the Spring container executes closing operation, and the destroying method of the component instances in the Spring container is executed in sequence to clear the deployed micro service.
In the micro service architecture, in order to enable each micro service to provide a service function corresponding to the micro service, the micro service needs to be on-line processed first. Accordingly, if the service function corresponding to the micro service is to be stopped being provided, the micro service needs to be offline.
For any one microservice (business service), other microservices (caller services) may call the microservice to use the business function corresponding to the microservice.
Referring to fig. 1, fig. 1 schematically illustrates a schematic diagram of an online process of a micro-service in the related art.
As shown in fig. 1, after the Spring container corresponding to the service is started, a micro service registration component in the service needs to immediately initiate a service registration request to a registration center to complete service registration of the service in the registration center, and the service needs to expose an API of the service through a heartbeat mechanism, so that other caller services can obtain the API through the registration center and communicate with the service through the API. Meanwhile, the service needs to execute a specific service initialization task, such as a service preheating task like loading a cache, loading a database connection, etc., so as to provide a service function corresponding to the service to the outside after the service preheating task is completed.
In practical application, after the registration center completes the service registration of the service, the service can be considered to be on-line, and other calling party services can communicate with the service. However, at this time, the service preheating task of the service may not be completed yet, and the service may not be able to provide the service function corresponding to the service yet, thereby causing communication abnormality between other caller services and the service, and causing link fluctuation of the micro-service management system.
Referring to fig. 2, fig. 2 schematically illustrates a schematic diagram of a micro-service offline flow in the related art.
As shown in fig. 2, when the Spring container corresponding to the above-mentioned service is ready to start to close, the micro-service registration component in the service immediately initiates a service logout request to the registry, so as to complete service logout of the service in the registry. Meanwhile, the Spring container corresponding to the service performs closing operation, and the destruction methods of the component instances in the Spring container are sequentially performed.
In practical application, the service logout of the service is completed in the registration center, and after the Spring container corresponding to the service is closed, the service is considered to be offline, and the service stops providing the service function corresponding to the micro service. However, other caller services usually periodically obtain the instance data of the business service from the registry, flush the instance data of the business service to the local cache, and if not, clear the locally cached instance data of the business service. Therefore, during the period from the service being offline to the local cache being updated, the instance data of the business service still remains in the local cache of each caller service, but the business service has stopped providing the business function corresponding to the business service, thereby causing communication abnormality of other caller services and the business service, and causing link fluctuation of the micro-service management system.
The invention provides a technical scheme for micro-service management, which is used for optimizing a micro-service management process. In the technical scheme, before a target task is executed, a method interception is performed on an original code of the executed micro service based on a micro service operation method determined according to state information of a micro service management container for deploying the micro service, the executed original code jumps to an enhanced code corresponding to the micro service, the enhanced code is executed to preferentially complete a pre-task corresponding to the target task, and after the pre-task is completed, the residual original code of the micro service after being intercepted is continuously executed to complete the target task.
By adopting the mode, the micro-service management process can be optimized, and the preposed task corresponding to the target task is ensured to be completed before the target task is executed, so that the abnormal operation probability of the micro-service management system can be reduced, and the operation stability of the micro-service management system is improved.
Having described the general principles of the invention, various non-limiting embodiments of the invention are described in detail below.
Application scene overview
Referring to fig. 3, fig. 3 schematically shows a schematic diagram of a micro-service management scenario according to an embodiment of the present invention.
As shown in FIG. 3, in the above-described micro-service management scenario, a server and at least one client (e.g., clients 1-N) accessing the server through any type of wired or wireless network may be included.
The server can be deployed on a server comprising an independent physical host or a server cluster consisting of a plurality of independent physical hosts; or, the server may be a server built based on a cloud computing service.
The client may correspond to a terminal device such as a smart phone, a tablet Computer, a notebook Computer, a PC (Personal Computer), a pda (Personal Digital Assistants), a wearable device (e.g., smart glasses, a smart watch, etc.), a smart car-mounted device, or a game machine.
The developer can develop the application program through the client and distribute the developed application program to the server.
The server can be used as a micro-service management system, provides an operating environment for the micro-service and manages the micro-service.
In specific implementation, for any one micro service, the state information of the micro service management container for deploying the micro service can be monitored, and the micro service to be intercepted can be determined based on the state information
Figure BDA0004009176390000081
A service operation method.
In the case that the micro service operation method to be intercepted is determined, the method interception can be performed on the original code of the executed micro service based on the micro service operation method. Wherein the original code of the micro-service comprises an original operation method of the micro-service. And after the interception, jumping to the enhancement code corresponding to the micro service and executing the enhancement code. Wherein the enhancement code comprises a micro-service operation method for optimizing the management flow of the micro-service; by executing the enhanced code, the pre-task corresponding to the target task can be completed preferentially.
When the pre-task is completed, it may be determined that the execution of the micro-service operation method included in the enhanced code is completed, and therefore, in response to the completion of the pre-task, the remaining original code after the micro-service is intercepted may be continuously executed to complete the target task.
Exemplary method
A method for microservice management according to an exemplary embodiment of the invention is described below with reference to fig. 4-8 in connection with the application scenario of fig. 3. It should be noted that the above application scenarios are merely illustrated for the convenience of understanding the spirit and principles of the present invention, and the embodiments of the present invention are not limited in this respect. Rather, embodiments of the present invention may be applied to any scenario where applicable.
Referring to fig. 4, fig. 4 schematically shows a flowchart of a micro-service management method according to an embodiment of the present invention.
In some embodiments, the development framework for microservices in the present invention may be a Spring Cloud framework; the micro-service management container for deploying individual micro-services may be a Spring container.
The micro-service management method can comprise the following steps:
step 401: monitoring state information of a micro-service management container for deploying micro-services, and determining a micro-service operation method to be intercepted based on the state information.
In this embodiment, for any one microservice, in order to optimize the management flow of the microservice, the original operation method of the microservice may be intercepted, and after the interception, the microservice operation method for optimizing the management flow of the microservice is executed first, and then the remaining original operation method is executed continuously after the execution of the microservice operation method is completed.
Specifically, the state information of the micro-service management container for deploying the micro-service may be monitored, and the micro-service operation method to be intercepted may be determined based on the state information.
Step 402: and carrying out method interception on the executed original code of the micro service based on the micro service operation method, skipping to an enhanced code corresponding to the micro service, and executing the enhanced code to preferentially complete a front task corresponding to a target task.
In this embodiment, in the case that the micro-service operation method to be intercepted is determined, method interception may be performed on the original code of the executed micro-service based on the micro-service operation method. Wherein the original code of the micro-service comprises an original operation method of the micro-service. And after interception, jumping to the enhancement code corresponding to the micro service and executing the enhancement code. Wherein the enhancement code comprises a micro-service operation method for optimizing the management flow of the micro-service; by executing the enhanced code, the pre-task corresponding to the target task can be completed preferentially.
In some embodiments, the Java Agent corresponding to the micro service may be specifically started, jump to an enhanced code in the Java Agent, and execute the enhanced code to preferentially complete the pre-task.
In practical applications, java Agent (also called Java Agent, java probe) technology allows a user to build an Agent that is independent of the application using Java Agent. The Java Agent is essentially a jar package. For a common jar package, the package is started through a main function of a specified class, but Java agents cannot be started independently and must be run attached to a Java application program. The Java Agent can be used for modifying the Java application program in the running process of the Java application program. The Java Agent, while acting as an application independent Agent, may assist in monitoring, running, and even replacing applications on a JVM (Java Virtual Machine).
Therefore, by changing the task execution flow of the micro-service in operation through the Java Agent, the management flow of the micro-service can be optimized by changing the logic related to the micro-service in operation of the micro-service according to the non-invasive bytecode enhancement function provided by the Java Agent on the premise of not modifying the original code in the application program deployment package of the micro-service.
Further, in some embodiments, based on the Java Agent technology, when the method interception is performed on the executed original code of the micro service based on the micro service running method, data generated when the context of the micro service running method is executed in the executed original code of the micro service may be collected. From the collected data, methods in the original code of the microservice being executed and about to be executed can be determined, and therefore method interception of the original code of the microservice being executed can be performed based on the collected data.
Step 403: and responding to the completion of the preposed task, and continuously executing the residual original code after the micro service is intercepted so as to complete the target task.
In this embodiment, when the pre-task is completed, it may be determined that the execution of the micro-service operation method included in the enhanced code is completed, and therefore, in response to the completion of the pre-task, the remaining original code after the micro-service is intercepted may be continuously executed to complete the target task.
According to the embodiment of the invention, before the target task is executed, the method interception is performed on the executed original code of the micro service based on the micro service operation method determined according to the state information of the micro service management container for deploying the micro service, the enhanced code corresponding to the micro service is skipped to, the enhanced code is executed to preferentially complete the pre-task corresponding to the target task, and after the pre-task is completed, the residual original code after the micro service is intercepted is continuously executed to complete the target task.
By adopting the mode, the micro-service management process can be optimized, and the preposed task corresponding to the target task is ensured to be completed before the target task is executed, so that the abnormal operation probability of the micro-service management system can be reduced, and the operation stability of the micro-service management system is improved.
In some embodiments, the target task may be an online task of the microservice. Accordingly, the preceding task may be a service warm-up task of the microservice.
On the basis of fig. 4, referring to fig. 5, fig. 5 schematically shows a flowchart of a micro-service online method according to an embodiment of the present invention.
The micro-service online method can comprise the following steps:
step 501: in response to the completion of the start of the micro-service management container for deploying the micro-service, determining a start method of a micro-service registration component in the micro-service as a micro-service operation method to be intercepted.
Step 502: and carrying out method interception on the executed original code of the micro service based on the starting method of the micro service registration component, skipping to the enhanced code corresponding to the micro service, executing the enhanced code, and blocking the starting of the micro service registration component so as to complete the service preheating task of the micro service preferentially.
Step 503: and responding to the completion of the service preheating task, continuously executing the residual original codes after the micro service is intercepted, and performing service registration on the micro service based on the micro service registration component to complete the online task.
Specifically, by monitoring the state information of the micro service management container for deploying the micro service, it can be determined whether the micro service management container is started up completely. In this case, in response to completion of the start of the micro-service management container, the start method of the micro-service registration component in the micro-service may be determined as the micro-service operation method to be intercepted.
Further, in some embodiments, in order to enable the micro-service registration component to easily determine whether the micro-service management container is started up completely, the micro-service management container may issue an event indicating that the micro-service management container is started up completely after the micro-service management container is started up completely. The microservice registration component may subscribe to the event, so that the event may be acquired after the microservice management container publishes the event, and the start of the microservice management container is determined to be completed based on the event.
It should be noted that the micro service may perform service registration or service logout in a registry corresponding to the micro service management container, and the micro service registration component may be configured to initiate service registration or service logout for the micro service with the registry.
Under the condition that the micro service operation method to be intercepted is determined, the method interception can be carried out on the original code of the executed micro service based on the starting method of the micro service registration component, the jump is made to the enhancement code corresponding to the micro service, the enhancement code is executed, the starting of the micro service registration component is blocked, and the service preheating task of the micro service is completed preferentially.
In this case, the method for starting the microservice registration module may be a method for starting a service registration procedure of the microservice registration module for the microservice. Accordingly, blocking the start of the micro service registration component is to block the start of the service registration process.
Further, in some embodiments, when the start of the micro service registration component is blocked, the start of the micro service registration component may be specifically blocked, and an environment variable indicating the state information of the service preheating task is detected until it is detected that the environment variable indicates that the service preheating task is completed.
After the registration center completes the service registration of the micro service, the micro service can be considered to complete the online, so that the delayed online of the micro service can be realized by blocking the starting of the service registration process of the micro service. The configurable delay online of the micro service can be realized by setting the environment variable and determining the time for blocking the start of the service registration process based on the environment variable, that is, the user can configure the online delay time of the micro service by selecting a specific environment variable.
Subsequently, in response to the completion of the service preheating task, the remaining original codes of the micro service after being intercepted are continuously executed, and the micro service is registered based on the micro service registration component, so that the online task of the micro service is completed.
Further, in some embodiments, when the microservice registration component performs service registration on the microservice, specifically, a service registration request may be sent to the registry on the basis of the microservice registration component, so as to perform service registration on the microservice in the registry.
Referring to fig. 6 in conjunction with fig. 5, fig. 6 schematically illustrates a schematic diagram of an online process of a microservice according to an embodiment of the present invention.
As shown in fig. 6, after the Spring container corresponding to the service is started, the micro service registration component in the service does not immediately initiate a service registration request to the registration center, but first waits for the service to complete the service preheating task of the service through blocking, and then initiates a service registration request to the registration center after the service preheating task is completed, so as to complete service registration of the service in the registration center, and the service needs to expose the API of the service through a heartbeat mechanism, so that other calling party services can obtain the API through the registration center and communicate with the service through the API.
After the registration center completes the service registration of the service, the service can be considered to be on-line.
The micro-service online mode can preferentially execute the service preheating task of the micro-service, and initiate service registration aiming at the micro-service to the registration center after the service preheating task is completed, so as to realize the delayed online of the micro-service. That is, it may be ensured that the service warm-up task for the microservice has been completed before service registration for the microservice is initiated with the registry. Therefore, after the micro-service can normally provide the service function corresponding to the micro-service, the service caller of the micro-service can communicate with the micro-service, thereby avoiding the problem of abnormal communication between the service caller and the micro-service when the micro-service is on line and eliminating the hidden trouble of link fluctuation of the micro-service management system.
In some embodiments, the target task may be an offline task of the microservice. Accordingly, the pre-task may be a data clearing task for a service invoker of the microservice.
On the basis of fig. 4, referring to fig. 7, fig. 7 schematically shows a flowchart of a micro-service offline method according to an embodiment of the present invention.
The micro-service offline method can comprise the following steps:
step 701: in response to a closing method of a micro-service management container for deploying micro-services being triggered, determining the closing method of the micro-service management container as a micro-service operation method to be intercepted.
Step 702: and performing method interception on the executed original code of the micro service based on the closing method of the micro service management container, jumping to an enhanced code corresponding to the micro service, executing the enhanced code, and blocking the closing of the micro service management container so as to complete the data clearing task of the service calling party of the micro service preferentially.
Step 703: and responding to the completion of the data clearing task of the service calling party of the micro service, continuously executing the residual original codes after the micro service is intercepted, and closing the micro service management container to complete the offline task.
Specifically, by monitoring the status information of the micro service management container for deploying the micro service, it can be determined whether the closing method of the micro service management container is triggered. In this case, the method for closing the microservice management container may be determined as the microservice operation method to be intercepted in response to the method for closing the microservice management container being triggered.
Under the condition that the micro-service operation method to be intercepted is determined, the method interception can be carried out on the executed original code of the micro-service based on the closing method of the micro-service management container, the micro-service operation method jumps to the enhancement code corresponding to the micro-service, the enhancement code is executed, the micro-service management container is blocked from being closed, and the data clearing task of the service calling party of the micro-service is completed preferentially.
In an actual application, the data removal task of the service caller of the micro service may be that the service caller of the micro service removes the locally cached instance data of the micro service when the instance data of the micro service is not acquired.
Further, in some embodiments, when the micro service management container is blocked from being closed, the micro service management container may be specifically blocked from being closed until the blocking duration reaches a preset threshold. Or, specifically, the micro service management container may be blocked from being closed, and an environment variable indicating the state information of the data purge task is detected until the environment variable is detected to indicate that the data purge task is completed.
The method comprises the steps that service logout of the micro service is completed in a registration center, and the micro service management container for deploying the micro service is closed, the micro service can be considered to be offline, so that the delayed offline of the micro service can be realized by blocking the closing of the micro service management container. Whether the blocking duration threshold value is set or the environment variable is set, and the closing duration of the blocking micro-service management container is determined based on the environment variable, the configurable delay offline of the micro-service can be realized, namely, a user can delay the offline of the micro-service by selecting a specific blocking duration threshold value or environment variable
Figure BDA0004009176390000141
The configuration is made long.
Further still, in some embodiments, since the data clearing task may be clearing locally cached instance data of the microservice by a service invoker of the microservice, for the microservice, the threshold may be an update period of the local cache of the service invoker.
Subsequently, in response to the completion of the data clearing task of the service caller of the micro service, the remaining original codes of the intercepted micro service are continuously executed, and the micro service management container is closed to complete the offline task of the micro service.
Further, in some embodiments, when the micro service management container is closed, a destruction method corresponding to the micro service management container may be specifically called to destroy the micro service deployed in the micro service management container.
In practical applications, the destruction method corresponding to the micro service management container may be a destruction method of the component instance in the micro service deployed in the micro service management container.
Further, in some embodiments, in response to the closing method of the micro service management container being triggered, not only the closing method of the micro service management container may be intercepted, but also a service logout may be performed on the micro service based on a micro service registration component in the micro service.
Specifically, a service logout request may be sent to a registry corresponding to the microservice management container based on the microservice registration component, so as to perform service logout on the microservice in the registry. After the registration center completes service logout of the micro-service, a service caller of the micro-service can clear locally cached instance data of the micro-service because the instance data of the micro-service cannot be acquired from the registration center.
Referring to fig. 8, fig. 8 schematically shows a schematic diagram of a microservice offline flow according to an embodiment of the present invention.
As shown in fig. 8, when the Spring container corresponding to the business service is ready to start to close, the micro-service registration component in the business service immediately initiates a service logout request to the registry, so as to complete service logout of the business service in the registry. Meanwhile, the Spring container corresponding to the service does not immediately execute the closing operation, but first waits for other caller services to finish clearing the locally cached instance data of the service through blocking, and then executes the closing operation to sequentially finish the destroying method of each component instance in the Spring container.
And finishing service logout of the business service in the registration center, and finishing closing the Spring container corresponding to the business service, namely finishing offline of the business service.
In the method for downloading the micro-service, a service caller of the micro-service can preferentially execute a data clearing task, and the micro-service management container for deploying the micro-service is closed after the data clearing task is finished, so that the delayed downloading of the micro-service is realized. That is, it can be ensured that the data clearing task of the service invoker of the micro-service has been completed before the micro-service management container begins to close. Therefore, before the service caller of the micro service clears the locally cached instance data of the micro service, the micro service can still normally provide the service function corresponding to the micro service, thereby avoiding the problem of abnormal communication between the service caller and the micro service when the micro service is offline, and eliminating the hidden trouble of link fluctuation of the micro service management system.
Exemplary Medium
Having described the method of the exemplary embodiment of the present invention, the medium for microservice management of the exemplary embodiment of the present invention will be described with reference to fig. 9.
In the present exemplary embodiment, the above-described method may be implemented by a program product, such as a portable compact disc read only memory (CD-ROM) and including program code, and may be executed on a device, such as a personal computer. However, the program product of the present invention is not limited in this regard and, in the present document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium.
A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
A readable signal medium may include a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RE, etc., or any suitable combination of the foregoing.
Program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the C programming language or similar programming languages. The program code may execute entirely on the user computing device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
Exemplary devices
Having described the medium of an exemplary embodiment of the present invention, an apparatus for micro-service management of an exemplary embodiment of the present invention will next be described with reference to fig. 10.
For the implementation process of the functions and actions of each module in the following apparatus, reference is made to the implementation process of the corresponding step in the above method, which is not described herein again. For the device embodiments, they substantially correspond to the method embodiments, and so reference may be made to some of the descriptions of the method embodiments for their relevant points.
Referring to fig. 10, fig. 10 schematically illustrates a micro-service management device according to an embodiment of the present invention.
The micro-service management device may include:
the monitoring module 1001 is used for monitoring state information of a micro-service management container for deploying micro-services and determining a micro-service operation method to be intercepted based on the state information;
the enhancing module 1002 is configured to perform method interception on an original code of the executed micro service based on the micro service running method, jump to an enhancing code corresponding to the micro service, and execute the enhancing code to preferentially complete a pre-task corresponding to a target task;
and the execution module 1003 is configured to, in response to completion of the pre-task, continue to execute the remaining original codes after the micro service is intercepted, so as to complete the target task.
Optionally, the target task is an online task of the microservice;
the monitoring module is specifically configured to:
in response to the completion of the starting of the micro-service management container for deploying the micro-service, determining the starting method of the micro-service registration component in the micro-service as the micro-service running method to be intercepted.
Optionally, the enhancement module is specifically configured to:
and carrying out method interception on the executed original code of the micro service based on the starting method of the micro service registration component, skipping to the enhanced code corresponding to the micro service, executing the enhanced code, and blocking the starting of the micro service registration component so as to complete the service preheating task of the micro service preferentially.
Optionally, the execution module is specifically configured to:
and responding to the completion of the service preheating task, continuously executing the residual original codes after the micro service is intercepted, and performing service registration on the micro service based on the micro service registration component to complete the online task.
Optionally, the target task is an offline task of the micro service;
the monitoring module is specifically configured to:
in response to a closing method of a micro-service management container for deploying micro-services being triggered, determining the closing method of the micro-service management container as a micro-service operation method to be intercepted.
Optionally, the enhancement module is specifically configured to:
and performing method interception on the executed original code of the micro service based on the closing method of the micro service management container, jumping to an enhanced code corresponding to the micro service, executing the enhanced code, and blocking the closing of the micro service management container so as to complete the data clearing task of the service calling party of the micro service preferentially.
Optionally, the execution module is specifically configured to:
and responding to the completion of the data clearing task of the service calling party of the micro service, continuously executing the residual original codes after the micro service is intercepted, and closing the micro service management container to complete the offline task.
Optionally, the execution module is specifically configured to:
and calling a destroying method corresponding to the micro-service management container, and destroying the micro-service deployed in the micro-service management container.
Optionally, the enhancement module is specifically configured to:
and starting the Java Agent corresponding to the micro service, jumping to the enhancement code in the Java Agent, and executing the enhancement code.
Optionally, the enhancement module is specifically configured to:
collecting data generated when the context of the micro service operation method is executed in the executed original code of the micro service, and carrying out method interception on the executed original code of the micro service based on the data.
Optionally, the development framework of the microservice is a Spring Cloud framework; the micro-service management container is a Spring container.
Optionally, the monitoring module is specifically configured to:
in response to an event which is issued by a micro service management container for deploying micro services and indicates that the micro service management container is started completely, a starting method of a micro service registration component in the micro services is determined as a micro service running method to be intercepted.
Optionally, the enhancement module is specifically configured to:
and blocking the starting of the micro-service registration component, and detecting an environment variable used for indicating the state information of the service preheating task until the environment variable is detected to indicate that the service preheating task is completed.
Optionally, the enhancement module is specifically configured to:
blocking the micro service management container from being closed until the blocking time reaches a preset threshold value; alternatively, the first and second electrodes may be,
and blocking the micro service management container from closing, and detecting an environment variable used for indicating the state information of the data clearing task until the environment variable is detected to indicate that the data clearing task is completed.
Optionally, the threshold is an update period of a local cache of the service invoker.
Optionally, the execution module is specifically configured to:
and sending a service registration request to a registration center corresponding to the micro-service management container based on the micro-service registration component so as to perform service registration on the micro-service in the registration center.
Optionally, the monitoring module is further configured to:
and in response to the closing method of the micro-service management container being triggered, performing service logout on the micro-service based on a micro-service registration component in the micro-service.
Optionally, the monitoring module is specifically configured to:
and sending a service logout request to a registration center corresponding to the micro-service management container based on the micro-service registration component so as to perform service logout on the micro-service in the registration center.
Exemplary computing device
Having described the methods, media, and apparatus of exemplary embodiments of the present invention, a computing device for microservice management of exemplary embodiments of the present invention is described next with reference to fig. 11.
The computing device 1100 shown in FIG. 11 is only one example and should not be taken to limit the scope of use and functionality of embodiments of the present invention.
As shown in fig. 11, computing device 1100 is embodied in the form of a general purpose computing device. Components of computing device 1100 may include, but are not limited to: the at least one processing unit 1101, the at least one storage unit 1102, and a bus 1103 connecting different system components (including the processing unit 1101 and the storage unit 1102).
The bus 1103 includes a data bus, a control bus, and an address bus.
The storage unit 1102 may include readable media in the form of volatile memory, such as Random Access Memory (RAM) 11021 and/or cache memory 11022, and may further include readable media in the form of non-volatile memory, such as Read Only Memory (ROM) 11023.
The memory unit 1102 may also include a program/utility 11025 having a set (at least one) of program modules 11024, such program modules 11024 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
Computing device 1100 can also communicate with one or more external devices 1104 (e.g., keyboard, pointing device, etc.).
Such communication may occur via input/output (I/O) interfaces 1105. Moreover, computing device 1100 may also communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the internet) via network adapter 1106. As shown in fig. 11, the network adapter 1106 communicates with the other modules of the computing device 1100 over a bus 1103. It should be understood that although not shown in the figures, other hardware and/or software modules may be used in conjunction with the computing device 1100, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
It should be noted that although in the above detailed description several units/modules or sub-units/modules of the microservice management apparatus are mentioned, such division is merely exemplary and not mandatory. Indeed, the features and functions of two or more of the units/modules described above may be embodied in one unit/module according to embodiments of the invention. Conversely, the features and functions of one unit/module described above may be further divided into embodiments by a plurality of units/modules.
Moreover, while the operations of the method of the invention are depicted in the drawings in a particular order, this does not require or imply that the operations must be performed in this particular order, or that all of the illustrated operations must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions.
While the spirit and principles of the invention have been described with reference to several particular embodiments, it is to be understood that the invention is not limited to the disclosed embodiments, nor is the division of aspects, which is for convenience only as the features in such aspects may not be combined to benefit. The invention is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.

Claims (10)

1. A method of microservice management, the method comprising:
monitoring state information of a micro-service management container for deploying micro-services, and determining a micro-service operation method to be intercepted based on the state information;
performing method interception on an original code of the executed micro service based on the micro service operation method, skipping to an enhanced code corresponding to the micro service, and executing the enhanced code to preferentially complete a front task corresponding to a target task;
and responding to the completion of the preposed task, and continuously executing the residual original codes after the micro service is intercepted so as to complete the target task.
2. The method of claim 1, the target task being an online task of the microservice;
the method for monitoring the state information of the micro-service management container for deploying the micro-service and determining the micro-service operation to be intercepted based on the state information comprises the following steps:
in response to the completion of the start of the micro-service management container for deploying the micro-service, determining a start method of a micro-service registration component in the micro-service as a micro-service operation method to be intercepted.
3. The method of claim 2, wherein the method intercepting the executed original code of the micro service based on the micro service running method, jumping to the enhancement code corresponding to the micro service, and executing the enhancement code to preferentially complete the pre-task corresponding to the target task comprises:
and intercepting an original code of the executed micro service based on the starting method of the micro service registration component, skipping to an enhanced code corresponding to the micro service, executing the enhanced code, and blocking the starting of the micro service registration component so as to complete a service preheating task of the micro service preferentially.
4. The method of claim 3, the continuing to execute the remaining original code after the microservice is intercepted to complete the target task in response to completion of the pre-task, comprising:
and responding to the completion of the service preheating task, continuously executing the residual original codes after the micro service is intercepted, and performing service registration on the micro service based on the micro service registration component to complete the online task.
5. The method of claim 1, the target task being an off-line task of the microservice;
the method for monitoring the state information of the micro-service management container for deploying the micro-service and determining the micro-service operation to be intercepted based on the state information comprises the following steps:
in response to a closing method of a micro-service management container for deploying micro-services being triggered, determining the closing method of the micro-service management container as a micro-service operation method to be intercepted.
6. The method of claim 5, wherein the method intercepting the executed original code of the micro service based on the micro service running method, jumping to the enhancement code corresponding to the micro service, and executing the enhancement code to preferentially complete the pre-task corresponding to the target task comprises:
and performing method interception on the executed original code of the micro service based on the closing method of the micro service management container, jumping to an enhanced code corresponding to the micro service, executing the enhanced code, and blocking the closing of the micro service management container so as to complete the data clearing task of the service calling party of the micro service preferentially.
7. The method of claim 6, said continuing to execute remaining original code after the microservice is intercepted in response to completion of the pre-task to complete the target task, comprising:
and responding to the completion of the data clearing task of the service calling party of the micro service, continuously executing the residual original codes after the micro service is intercepted, and closing the micro service management container to complete the offline task.
8. A microservice management apparatus, the apparatus comprising:
the monitoring module is used for monitoring the state information of a micro-service management container for deploying micro-services and determining a micro-service operation method to be intercepted based on the state information;
the enhancement module is used for intercepting an original code of the executed micro service based on the micro service operation method, jumping to an enhancement code corresponding to the micro service, and executing the enhancement code to preferentially complete a front task corresponding to a target task;
and the execution module is used for responding to the completion of the preposed task and continuously executing the residual original codes after the micro service is intercepted so as to complete the target task.
9. A medium having stored thereon a computer program which, when executed by a processor, implements the method of any one of claims 1 to 7.
10. A computing device, comprising:
a processor;
a memory for storing a processor executable program;
wherein the processor implements the method of any one of claims 1 to 7 by running the executable program.
CN202211644499.0A 2022-12-20 2022-12-20 Micro-service management method, device, medium and computing equipment Pending CN115859266A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211644499.0A CN115859266A (en) 2022-12-20 2022-12-20 Micro-service management method, device, medium and computing equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211644499.0A CN115859266A (en) 2022-12-20 2022-12-20 Micro-service management method, device, medium and computing equipment

Publications (1)

Publication Number Publication Date
CN115859266A true CN115859266A (en) 2023-03-28

Family

ID=85674706

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211644499.0A Pending CN115859266A (en) 2022-12-20 2022-12-20 Micro-service management method, device, medium and computing equipment

Country Status (1)

Country Link
CN (1) CN115859266A (en)

Similar Documents

Publication Publication Date Title
US9823921B2 (en) Selectively hotpatching only a selection of processes of a running instance of an application that match a selection criteria
US9904585B1 (en) Error handling in executing workflow state machines
US9766927B1 (en) Data flow management in processing workflows
CN109308241B (en) Method and device for monitoring starting process of application program, terminal equipment and storage medium
US10719352B2 (en) System and method for in-process namespace switching
US20130318512A1 (en) Hot Pluggable Extensions for Access Management System
US8806475B2 (en) Techniques for conditional deployment of application artifacts
KR20200070085A (en) Method and apparatus for processing information
US10380365B2 (en) Choreographed distributed execution of programs
US10970141B2 (en) Integrating transaction processing system interfaces with event-driven polyglot runtime modules
JP2023538938A (en) Compilation strategies for shareable application snapshots
CN111597027A (en) Application program starting method, device, equipment and storage medium
CN112153126A (en) Deployment and node management method and system for K8S cluster
WO2022223437A1 (en) Software upgrading using dynamic link library injection
US10102008B2 (en) Managed boot process system
CN115686500A (en) Exposing cloud APIs based on supported hardware
CN113626095A (en) Switching method and switching system of configuration center, electronic equipment and storage medium
US9965538B2 (en) Early thread return with secondary event writes
JP2011100448A (en) System and method for providing service quality in multi-event processing environment, and computer program
CN111563253A (en) Intelligent contract operation method, device, equipment and storage medium
CN115859266A (en) Micro-service management method, device, medium and computing equipment
CN115495289A (en) Equipment state switching control method, device, equipment and computer storage medium
CN112379973B (en) Heavy load method and device
US11520866B2 (en) Controlling processor instruction execution
CN108062224A (en) Data read-write method, device and computing device based on file handle

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 310052 Room 301, Building No. 599, Changhe Street Network Business Road, Binjiang District, Hangzhou City, Zhejiang Province

Applicant after: Hangzhou NetEase Shuzhifan Technology Co.,Ltd.

Address before: 310052 Room 301, Building No. 599, Changhe Street Network Business Road, Binjiang District, Hangzhou City, Zhejiang Province

Applicant before: HANGZHOU LANGHE TECHNOLOGY Ltd.