Application instance restart optimization method and system
By sending notification messages and answer messages in the registry, the application instance restart process is optimized, and the problem of the restart waiting time in the microservice architecture is solved, which improves the restart efficiency and the accuracy of address information, and achieves more efficient release process.
Patent Information
- Application Number
- CN202411062857.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2025-01-03
AI Technical Summary
In the microservice architecture, the access delay or failure occurs due to the short or too long waiting time when the application instance is restarted, and it is difficult for the existing technology to effectively optimize the restart process.
Send notification messages to all application instances through the registration center, delete the address information of the application instance to be restarted, and allow restart after receiving the reply message, ensuring the accurate and complete address information and reducing the broadcast message sending and waiting time of restart notifications.
It improves the efficiency of restarting the application instance, ensures the accuracy and completeness of address information, reduces I/O waiting time and restart waiting time, and improves the overall release efficiency.
Smart Images

Figure CN119248365A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud service technology, and in particular to an optimization method and system for restarting an application instance. Background Art
[0002] At present, in order to support high-throughput and high-concurrency request scenarios, most server-side systems will adopt a microservice architecture, that is, they are divided by business, and different subsystems have their own set of microservice systems. Under the microservice architecture, in order to realize functions such as service discovery and service registration, a registration center needs to be provided. The registration center mainly provides application instance registration and pulls address lists to external application instances. When the application instance is restarted or upgraded, the application instance to be restarted sends a restart command to the registration center, and then automatically restarts after waiting for a certain period of time. However, since there is a cycle for each application instance to pull the address list from the registration center, if the waiting time of the application instance to be restarted is too short, some application instances will not update the local address list, which will cause the application instance to access the application instance to be restarted. Delayed or failed access; if the waiting time of the application instance to be restarted is too long, the restart process will be relatively long. Therefore, there is an urgent need for an optimization method and system for restarting application instances that can solve the above problems. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide an optimization method and system for restarting an application instance, which can effectively reduce the broadcast message sending of application instance restart notification messages, reduce the waiting time of application instances to be restarted, and thus improve the overall publishing efficiency.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0005] An optimization method for restarting an application instance, comprising the steps of:
[0006] S1. The application instance to be restarted sends a restart command to the registration center. The registration center receives the restart command and queries the list of application instances that use the application instance to be restarted from the address list information according to the identification information of the application instance to be restarted, and sends a notification message to all application instances in the application instance list.
[0007] S2. All application instances in the application instance list receive the notification message, delete the address information of the application instance to be restarted in the local cache in advance, and send a response message to the registration center;
[0008] S3. When the registration center receives the response messages from all the application instances in the application instance list, it sends a notification message of allowing restart to the application instance to be restarted, and the application instance to be restarted performs a restart operation.
[0009] In order to solve the above technical problems, another technical solution adopted by the present invention is:
[0010] A system for optimizing restart of an application instance includes an application instance and a registration center. The application instance and the registration center implement various steps of the above-mentioned method for optimizing restart of an application instance.
[0011] The beneficial effects of the present invention are as follows: the present invention provides an optimization method and system for restarting an application instance, wherein the application instance to be restarted sends a restart command to a registration center, the registration center receives the restart command and queries the application instance list using the application instance to be restarted from the address list information according to the identification information of the application instance to be restarted, and sends a notification message to all application instances in the application instance list, all application instances receive the notification message and delete the address information about the application instance to be restarted in the local cache, and send a response message to the registration center, the registration center receives the response messages of all application instances in the application instance list, sends a notification message allowing restart to the application instance to be restarted, and the application instance to be restarted performs a restart operation, ensures that the address information related to the application instance to be restarted is accurate and complete by caching the address list information of the application instance to be restarted, queries other application instances used by the application instance to be restarted according to the identification information of the application instance to be restarted, and communicates with other application instances to delete the address information of the application instance to be restarted in the local cache, reduces the sending of broadcast messages of the restart notification, reduces the I / O waiting time and the waiting time of the application instance to be restarted, and improves the overall publishing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 A flowchart of an optimization method for restarting an application instance according to an embodiment of the present invention;
[0013] Figure 2 A schematic diagram of an optimization system for restarting an application example according to an embodiment of the present invention;
[0014] Description of labels:
[0015] 1. An optimization system for restarting an application instance; 2. Application instance; 3. Registration center. DETAILED DESCRIPTION
[0016] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0017] Please refer to Figure 1 , an embodiment of the present invention provides an optimization method for restarting an application instance, comprising the steps of:
[0018] S1. The application instance to be restarted sends a restart command to the registration center. The registration center receives the restart command and queries the list of application instances that use the application instance to be restarted from the address list information according to the identification information of the application instance to be restarted, and sends a notification message to all application instances in the application instance list.
[0019] S2. All application instances in the application instance list receive the notification message, delete the address information of the application instance to be restarted in the local cache in advance, and send a response message to the registration center;
[0020] S3. When the registration center receives the response messages from all the application instances in the application instance list, it sends a notification message of allowing restart to the application instance to be restarted, and the application instance to be restarted performs a restart operation.
[0021] From the above description, it can be seen that the beneficial effect of the present invention is that: the application instance to be restarted sends a restart command to the registration center, the registration center receives the restart command and queries the application instance list using the application instance to be restarted from the address list information according to the identification information of the application instance to be restarted, and sends a notification message to all application instances in the application instance list, all application instances receive the notification message and delete the address information about the application instance to be restarted in the local cache, and send a reply message to the registration center, the registration center receives the reply messages of all application instances in the application instance list, sends a notification message allowing restart to the application instance to be restarted, and the application instance to be restarted performs a restart operation, ensures that the address information related to the application instance to be restarted is accurate and complete by caching the address list information of the application instance to be restarted, queries other application instances used by the application instance to be restarted according to the identification information of the application instance to be restarted, and communicates with other application instances to delete the address information of the application instance to be restarted in the local cache, reduces the sending of broadcast messages of the restart notification, reduces the I / O waiting time and the waiting time of the application instance to be restarted, and improves the overall publishing efficiency.
[0022] Furthermore, before step S1, the steps include:
[0023] When an application instance is registered, the address list information of the application instance is sent to a registration center, so that the registration center synchronously stores the address list information of the application instance;
[0024] The address list information includes key information and value information, wherein the key information is application instance identification information, and the value information is identification information corresponding to other application instances used by the application instance.
[0025] From the above description, it can be seen that the address list information is automatically generated when the application instance to be restarted registers application information with the registration center, which simplifies configuration and improves registration efficiency; the registration center synchronously stores the address list information to ensure the consistency and reliability of the information of the application instance to be restarted.
[0026] Furthermore, before step S1, the following steps are also included:
[0027] The application instance to be restarted pulls address list information containing identification information of the application instance to be restarted from the registration center, and caches the address list information to the redis cluster.
[0028] From the above description, it can be seen that the application instance to be restarted pulls the address list information containing the identification information of the application instance to be restarted from the registration center, and caches the address list information to the redis cluster, providing a basis for subsequent data query, improving the search speed, and ensuring the reliability and stability of the data during the restart of the application instance.
[0029] Further, querying the list of application instances using the application instance to be restarted from the address list information according to the identification information of the application instance to be restarted includes:
[0030] The registration center queries the corresponding key information from the value information in the redis cluster according to the identification information of the application instance to be restarted, and generates a list of application instances using the application instance to be restarted according to the query result.
[0031] From the above description, it can be seen that by searching the address list information in the form of key-value pairs, other application instances that use the application instance to be restarted can be accurately identified, the propagation of erroneous information can be avoided, and it is ensured that other application instances that use the application instance to be restarted can accurately receive notification messages, thereby improving the efficiency of the application instance restart process.
[0032] Furthermore, the notification message includes application instance identification information corresponding to the application instance to be restarted.
[0033] From the above description, it can be seen that the application instance identification information corresponding to the application instance to be restarted enables other application instances to clearly identify the application instance to be restarted, avoids the deletion error of the address information of the local cache, achieves targeted precise communication, reduces invalid communication volume, and ensures that other application instances can continue to run stably.
[0034] Please refer to Figure 2 Another embodiment of the present invention provides an optimization system for restarting an application instance, including an application instance and a registration center, wherein the application instance and the registration center implement the various steps of the above-mentioned optimization method for restarting an application instance.
[0035] The above-mentioned optimization method and system for restarting an application instance of the present invention are applicable to the restart or upgrade scenario of the application instance, and are described below through specific implementation methods:
[0036] Embodiment 1
[0037] Please refer to Figure 1 , an optimization method for restarting an application instance, comprising the steps of:
[0038] S1. The application instance to be restarted sends a restart command to a registration center. The registration center receives the restart command and queries the list of application instances that use the application instance to be restarted from the address list information according to the identification information of the application instance to be restarted, and sends a notification message to all application instances in the application instance list.
[0039] In this embodiment, the application instance to be restarted notifies the registration center by sending a restart command, so that the registration center queries the list of application instances that use the application instance to be restarted from the address list information according to the identification information of the application instance to be restarted, and sends a notification message to all application instances in the application instance list to ensure that the relevant application instances can receive the application instance restart message and take corresponding measures to deal with the restart event.
[0040] Furthermore, in this embodiment, the step before S1 includes: when the application instance is registered, the address list information of the application instance is sent to the registration center, so that the registration center synchronously stores the address list information of the application instance, the address list information is automatically generated when the application instance is registered, and no manual configuration is required, thereby improving registration efficiency, the address list information includes key information and value information, the key information is the application instance identification information, the value information is the identification information corresponding to other application instances used by the application instance, the identification information is the IP and port combination information of the application instance, and the application instance to be restarted pulls the address list information containing the identification information of the application instance to be restarted in the value information from the registration center.
[0041] For example: if the application instance to be restarted is application instance A, application instance A will pull the address list information containing the identification information of application instance A in the value information from the registration center, and the address list information is composed of two pieces of data of identification information corresponding to application instance A and application instance B, namely, key={IP and port of C}, value={IP and port of A, IP and port of B}; the key information is the identification information of application instance D, and the value information is application instance A and application instance E, namely, key={IP and port of D}, value={IP and port of A, IP and port of E}, and the address list information is cached in the redis cluster to provide a basis for subsequent data query, improve the search speed, and ensure the reliability and stability of data during the restart of the application instance.
[0042] Furthermore, in the present embodiment, a list of application instances using the application instance to be restarted is queried from the address list information according to the identification information of the application instance to be restarted, including: the registration center queries the corresponding key information from the value information in the redis cluster according to the identification information of the application instance to be restarted, and generates a list of application instances using the application instance to be restarted according to the query result.
[0043] For instance, in the above example, the application instance to be restarted is application instance A. The corresponding key information is queried from the value information based on the identification information of application instance A. The list of application instances using application instance A generated by the query result is application instance C and application instance D. By searching the address list information in the form of key-value pairs, other application instances using the application instance to be restarted can be accurately identified, avoiding the propagation of erroneous information, ensuring that other application instances using the application instance to be restarted can accurately receive notification messages, and improving the efficiency of the application instance restart process.
[0044] S2. All application instances in the application instance list receive the notification message, delete the address information about the application instance to be restarted in the local cache in advance, and send a response message to the registration center.
[0045] In this embodiment, all application instances in the application instance list delete the address information about the application instance to be restarted in the local cache in advance according to the received notification message, ensuring that these related application instances no longer use the application instance to be restarted, reducing data inconsistency and potential service errors after the application instance is restarted. At the same time, a response message is sent to the registration center to enable the registration center to confirm that the relevant application instance is ready to process the restart, so that the registration center can proceed to the next step.
[0046] Furthermore, in this embodiment, the notification message includes application instance identification information corresponding to the application instance to be restarted. The application instance identification information corresponding to the application instance to be restarted enables other application instances to clearly identify the application instance to be restarted, avoids deletion errors of locally cached address information, achieves targeted precise communication, reduces invalid communication volume, reduces the waiting time of the application instance to be restarted, and ensures that other application instances can continue to run stably.
[0047] S3. When the registration center receives the response messages from all the application instances in the application instance list, it sends a notification message of allowing restart to the application instance to be restarted, and the application instance to be restarted performs a restart operation.
[0048] In this embodiment, the registration center receives response messages from all application instances in the application instance list, ensuring that all application instances are ready for restart, avoiding service unavailability or other potential problems caused by restart, and ensuring system stability.
[0049] Embodiment 2
[0050] Please refer to Figure 2 An optimization system 1 for restarting an application instance includes an application instance 2 and a registration center 3. The application instance 2 implements each step of an optimization method for restarting an application instance in embodiment 1 with the application instance 2 as the execution subject, and the registration center 3 implements each step of an optimization method for restarting an application instance in embodiment 1 with the registration center 3 as the execution subject.
[0051] In summary, the present invention provides an optimization method and system for restarting an application instance. When an application instance is registered, address list information of the application instance is generated accordingly. The application instance will send the address list information to the registration center so that the registration center can synchronously store the address list information of the application instance. The address list information includes key information and value information. The key information is the application instance identification information, and the value information is the identification information corresponding to other application instances used by the application instance. If the application instance is about to be restarted, the application instance will send a restart command to the registration center. The application instance to be restarted pulls the address list information containing the identification information of the application instance to be restarted in the value information from the registration center, and caches the address list information in a redis cluster. The registration center receives the restart command and queries the corresponding key information from the value information in the redis cluster according to the identification information of the application instance to be restarted. A list of application instances using the application instance to be restarted is generated according to the query result. By searching the address list information in the form of key-value pairs, other application instances using the application instance to be restarted are accurately identified, thereby avoiding Avoid the propagation of erroneous information, ensure that other application instances that use the application instance to be restarted can accurately receive the notification message, and improve the efficiency of the application instance restart process; all application instances in the application instance list receive the notification message, and the notification message contains the application instance identification information corresponding to the application instance to be restarted. Through the application instance identification information corresponding to the application instance to be restarted, all application instances in the application instance list can clearly identify the application instance to be restarted, and pre-delete the address information of the application instance to be restarted in the local cache to avoid data inconsistency caused by the restart of the application instance, and send a response message to the registration center. When the registration center receives the response messages of all application instances in the application instance list, it sends a notification message allowing restart to the application instance to be restarted, and the application instance to be restarted performs the restart operation. By only communicating with other application instances related to the application instance to be restarted, the amount of data sent by the broadcast information of the restart notification is reduced, and invalid communication between irrelevant application instances and the registration center is avoided, thereby reducing the waiting time of the application instance to be restarted, improving the overall publishing efficiency, and ensuring system stability.
[0052] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. An optimization method for restarting an application instance, characterized in that: Includes steps: S1. The application instance to be restarted sends a restart command to the registration center. The registration center receives the restart command and queries the list of application instances that use the application instance to be restarted from the address list information according to the identification information of the application instance to be restarted, and sends a notification message to all application instances in the application instance list. S2. All application instances in the application instance list receive the notification message, delete the address information of the application instance to be restarted in the local cache in advance, and send a response message to the registration center; S3. When the registration center receives the response messages from all the application instances in the application instance list, it sends a notification message of allowing restart to the application instance to be restarted, and the application instance to be restarted performs a restart operation.
2. The optimization method for restarting an application instance according to claim 1, characterized in that: The step S1 includes: When an application instance is registered, the address list information of the application instance is sent to a registration center, so that the registration center synchronously stores the address list information of the application instance; The address list information includes key information and value information, wherein the key information is application instance identification information, and the value information is identification information corresponding to other application instances used by the application instance.
3. The optimization method for restarting an application instance according to claim 2, characterized in that: Before step S1, the following steps are also included: The application instance to be restarted pulls address list information containing identification information of the application instance to be restarted from the registration center, and caches the address list information to the redis cluster.
4. The optimization method for restarting an application instance according to claim 3, characterized in that: Querying a list of application instances that use the application instance to be restarted from the address list information according to the identification information of the application instance to be restarted, including: The registration center queries the corresponding key information from the value information in the redis cluster according to the identification information of the application instance to be restarted, and generates a list of application instances using the application instance to be restarted according to the query result.
5. The optimization method for restarting an application instance according to claim 1, characterized in that: The notification message includes application instance identification information corresponding to the application instance to be restarted.
6. An optimization system for restarting an application instance, characterized in that: It includes an application instance and a registration center, and the application instance and the registration center implement the following steps: S1. The application instance to be restarted sends a restart command to the registration center. The registration center receives the restart command and queries the list of application instances that use the application instance to be restarted from the address list information according to the identification information of the application instance to be restarted, and sends a notification message to all application instances in the application instance list. S2. All application instances in the application instance list receive the notification message, delete the address information of the application instance to be restarted in the local cache in advance, and send a response message to the registration center; S3. When the registration center receives the response messages from all the application instances in the application instance list, it sends a notification message of allowing restart to the application instance to be restarted, and the application instance to be restarted performs a restart operation.
7. The application instance restart optimization system according to claim 6, characterized in that: The step S1 includes: When an application instance is registered, the address list information of the application instance is sent to a registration center, so that the registration center synchronously stores the address list information of the application instance; The address list information includes key information and value information, wherein the key information is application instance identification information, and the value information is identification information corresponding to other application instances used by the application instance.
8. The application instance restart optimization system according to claim 7, characterized in that: Before step S1, the following steps are also included: The application instance to be restarted pulls address list information containing identification information of the application instance to be restarted from the registration center, and caches the address list information in the redis cluster.
9. The application instance restart optimization system according to claim 8, characterized in that: Querying a list of application instances that use the application instance to be restarted from the address list information according to the identification information of the application instance to be restarted, including: The registration center queries the corresponding key information from the value information in the redis cluster according to the identification information of the application instance to be restarted, and generates a list of application instances using the application instance to be restarted according to the query result.
10. The application instance restart optimization system according to claim 6, characterized in that: The notification message includes application instance identification information corresponding to the application instance to be restarted.
Citation Information
Patent Citations
CPU restarting method, communication device and readable storage medium
CN110109772A
Micro-service instance exit method and device, equipment and storage medium
CN112799786A
Communications methods, apparatus and systems for correlating registrations, service requests and calls
US9713112B1
