Service Offline Method, System, Device and Storage Medium

By sending a status update request to the service registration node and waiting for the gateway node to confirm the downline status, the problem of forwarding the request after the gateway node is offline for business services is solved, and the continuity and stability of the service request is achieved.

CN115811545BActive Publication Date: 2025-08-01HANGZHOU EZVIZ SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111069707.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-13
Publication Date
2025-08-01
Estimated Expiration
2041-09-13

AI Technical Summary

Technical Problem

In the C/S structure, the gateway node will still forward the service request to it within a certain period of time after it is offline for service, resulting in failure of processing. Although the existing technology can reduce the impact by setting the minimum time interval, there are still problems with business requests in a short time.

Method used

By sending a status update request to the service registration node, waiting for the first time to allow the gateway node to obtain the downline status of the target service service, and then sending a service downline message to the service node, ensuring that the service service is known to be downline status before it is downline.

Benefits of technology

It effectively avoids the impact of gateway nodes on business requests when business services are offline, ensuring business continuity and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115811545B_ABST
    Figure CN115811545B_ABST
Patent Text Reader

Abstract

An embodiment of the present application discloses a service offline method, system, device, and storage medium, belonging to the field of computer technology. The method includes: sending a status update request to a service registration node, where the status update request is used to request the service registration node to update the status of a target business service to be taken offline to an offline status. Waiting for a first duration to enable a gateway node to obtain from the service registration node that the status of the target business service is the offline status. In the case where the waiting for the first duration ends, sending a service offline message to a service node deploying the target business service. By setting the status of the target business service to the offline status before taking the target business service offline and enabling the gateway node to obtain the offline status of the target business service, and then taking the target business service offline, the embodiment of the present application avoids the impact of taking the target business service offline on business requests.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the field of computer technology, and particularly to a service offlining method, system, device, and storage medium. Background Art

[0002] In a C / S (client / server) architecture, one or more service nodes and a gateway node are usually deployed on the server side, and one or more business services are deployed on each service node. When the gateway node receives a business request from the client, it forwards the business request to the corresponding business service to complete the processing of the business request. However, in some cases, it may be necessary to update a business service, and in this case, the business service needs to be offlined first.

[0003] In the related art, the gateway node obtains the status of each business service at regular time intervals, so as to select the business services in the online state and forward the business requests to the business services in the online state. However, after a certain business service is offlined, the gateway node can obtain the status of the business service as offlined only after a certain time interval. And within this time interval, the gateway node may still forward business requests to this business service, resulting in the failure of business request processing. To solve this problem, the above time interval is usually set to the minimum value. In this way, after offlining this business service, the gateway node can obtain the status of this business service as offlined in the shortest time. However, since the above minimum value is still greater than zero, the business requests will still be affected for a short time after offlining this business service. Summary of the Invention

[0004] Embodiments of the present application provide a service offlining method, system, device, and storage medium, which can solve the problem of affecting business requests after offlining services in the related art. The technical solutions are as follows:

[0005] On the one hand, a service offlining method is provided, and the method includes:

[0006] Sending a status update request to a service registration node, where the status update request is used to request the service registration node to update the status of a target business service to be offlined to the offlined state;

[0007] Waiting for a first duration to enable the gateway node to obtain the status of the target business service as offlined from the service registration node;

[0008] When the waiting for the first duration ends, sending a service offlining message to the service node where the target business service is deployed, where the service offlining message is used to instruct the service node to offline the target business service.

[0009] Optionally, the second duration is the time interval for the service registration node to refresh the first service list, the third duration is the time interval for the gateway node to refresh the second service list, the first service list is used to record the status of the target business service, and the second service list is used to record the business services that are allowed to process business requests.

[0010] Optionally, the service registration node includes a first-level cache and a second-level cache. The first-level cache is used to store the first service list, and the second-level cache is used to store the offline status of the target business service obtained in response to the status update request. The second duration is less than the time interval for the first-level cache to default-refresh the first service list.

[0011] Optionally, the second service list includes a service status list and a load balancing list. The service status list is used to record the status of each business service obtained from the service registration node, and the load balancing list is used to record the business services in the online status in the service status list. The third duration is the sum of the refresh time interval of the service status list and the refresh time interval of the load balancing list.

[0012] Optionally, after sending the service offline message to the service node where the target business service is deployed, it further includes:

[0013] Sending a service deletion request to the service registration node, where the service deletion request is used to request the service registration node to delete the relevant data of the target business service;

[0014] After the service registration node deletes the relevant data of the target business service, sending a service publishing message to the service node, where the service publishing message is used to instruct the service node to redeploy the target business service.

[0015] Optionally, the target business service is a microservice, and the service registration node is a node deployed with the Eureka service.

[0016] On the other hand, a service offline device is provided, and the device includes:

[0017] A first sending module, configured to send a status update request to a service registration node, where the status update request is used to request the service registration node to update the status of the target business service to be offline to an offline status;

[0018] A waiting module, configured to wait for a first duration to enable the gateway node to obtain the status of the target business service as offline from the service registration node;

[0019] A second sending module, configured to send a service offline message to a service node where the target business service is deployed when the waiting for the first duration ends, where the service offline message is used to instruct the service node to take the target business service offline.

[0020] Optionally, the first duration is greater than or equal to the sum of a second duration and a third duration, the second duration is the time interval for the service registration node to refresh a first service list, the third duration is the time interval for the gateway node to refresh a second service list, the first service list is used to record the status of the target business service, and the second service list is used to record business services that are allowed to process business requests.

[0021] Optionally, the service registration node includes a first-level cache and a second-level cache, the first-level cache is used to store the first service list, the second-level cache is used to store the offline status of the target business service obtained by responding to the status update request, and the second duration is less than the time interval for the first-level cache to default refresh the first service list.

[0022] Optionally, the second service list includes a service status list and a load balancing list, the service status list is used to record the status of each business service obtained from the service registration node, the load balancing list is used to record the online business services in the service status list, and the third duration is the sum of the refresh time interval of the service status list and the refresh time interval of the load balancing list.

[0023] Optionally, the apparatus further includes:

[0024] A third sending module, configured to send a service deletion request to the service registration node, where the service deletion request is used to request the service registration node to delete relevant data of the target business service;

[0025] A fourth sending module, configured to send a service publishing message to the service node after the service registration node deletes the relevant data of the target business service, where the service publishing message is used to instruct the service node to redeploy the target business service.

[0026] Optionally, the target business service is a microservice, and the service registration node is a node where the Eureka service is deployed.

[0027] On the other hand, a service offline system is provided, and the system includes: a service publishing node, a service registration node, a gateway node, and at least one service node;

[0028] The service publishing node is configured to send a status update request to the service registration node;

[0029] The service registration node is used to receive the status update request and update the status of the target business service to be taken offline to the offline status;

[0030] The service publishing node is further used to wait for a first duration;

[0031] During the process that the service publishing node waits for the first duration, the gateway node is used to obtain from the service registration node that the status of the target business service is the offline status;

[0032] When the waiting for the first duration ends, the service publishing node is further used to send a service offline message to the service nodes among the at least one service node where the target business service is deployed;

[0033] The service node where the target business service is deployed is used to receive the service offline message and take the target business service offline.

[0034] Optionally, the service publishing node is further used to send a service deletion request to the service registration node;

[0035] The service registration node is further used to receive the service deletion request and delete the relevant data of the target business service;

[0036] After the service registration node deletes the relevant data of the target business service, the service publishing node is further used to send a service publishing message to the service nodes where the target business service is deployed;

[0037] The service node where the target business service is deployed is further used to receive the service publishing message and redeploy the target business service.

[0038] On the other hand, a computer device is provided. The computer device includes a memory and a processor. The memory is used to store a computer program, and the processor is used to execute the computer program stored on the memory to implement the steps of the service offline method described above.

[0039] On the other hand, a computer-readable storage medium is provided. The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the service offline method described above are implemented.

[0040] On the other hand, a computer program product containing instructions is provided. When the instructions run on a computer, the computer is made to execute the steps of the service offline method described above.

[0041] The technical solution provided by the embodiments of the present application can at least bring the following beneficial effects:

[0042] When taking offline a target business service, the service publishing node first requests the service registration node to update the status of the target business service to the offline status, and then waits for a first period of time to enable the gateway node to obtain the offline status of the target business service. In this way, when taking offline the target business service, the gateway node already knows the offline status of the target business service. At this time, the gateway node will stop forwarding service requests to the target business service, so that the service requests will not be affected. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following described drawings are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained according to these drawings.

[0044] Figure 1 is a schematic diagram of an implementation environment provided by an embodiment of the present application;

[0045] Figure 2 is a flowchart of a service offline method provided by an embodiment of the present application;

[0046] Figure 3 is a flowchart of another service offline method provided by an embodiment of the present application;

[0047] Figure 4 is a schematic structural diagram of a service offline device provided by an embodiment of the present application;

[0048] Figure 5 is a schematic structural diagram of a server provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0049] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the following will further describe the embodiments of the present application in detail with reference to the drawings.

[0050] Before explaining the service offline method provided by the embodiment of the present application in detail, the implementation environment provided by the embodiment of the present application will be introduced first.

[0051] Please refer to Figure 1 , Figure 1 which is a schematic diagram of an implementation environment shown according to an exemplary embodiment. The implementation environment includes a service publishing node 101, a service registration node 102, a gateway node 103, and at least one service node 104 ( Figure 1The at least one service node is schematically represented by a service node). Among them, the service publishing node 101 is communicatively connected to the service registration node 102 and the at least one service node 104, the service registration node 102 is communicatively connected to the gateway node 103 and the at least one service node 104, and the gateway node 103 is communicatively connected to the at least one service node 104. This communication connection can be a wired or wireless connection, and the embodiments of the present application do not limit this.

[0052] The service publishing node 101 is used to publish a new version of the business service when receiving a service publishing instruction. Among them, the service publishing instruction can be triggered by a publisher clicking a button on the service publishing node, or by executing a command on the service publishing node. Of course, it can also be triggered by other means, and the embodiments of the present application do not limit this.

[0053] The service registration node 102 is used to receive registration requests for each business service and complete the registration of each business service, and regularly refresh the status of each business service. The gateway node 103 is used to regularly obtain the status of each business service from the service registration node 102 and forward corresponding business requests to the business services in the online state. The service node 104 is used to deploy one or more business services.

[0054] Next, taking the target business service as an example, the process of taking the target business service offline by the cooperation of the service publishing node 101, the service registration node 102, the gateway node 103, and the at least one service node 104 is described below.

[0055] The service publishing node 101 sends a status update request to the service registration node 102. After receiving the status update request, the service registration node 102 updates the status of the target business service to the offline state. After the service publishing node 101 sends the status update request, wait for a first duration. During this first duration, the gateway node 103 can obtain from the service registration node 102 that the status of the target business service is the offline state. After that, the service publishing node 101 sends a service offline message to the service node 104. After receiving the service offline message, the service node 104 takes the target business service offline.

[0056] Among them, each of the service publishing node 101, the service registration node 102, the gateway node 103, and the service node 104 can be an independent server, or a server cluster or a distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms, or a cloud computing service center.

[0057] Of course, each of the service publishing node 101, the service registration node 102, the gateway node 103, and the service node 104 can also be a module. These four modules can be deployed on the same server or on different servers. The embodiments of the present application do not limit this.

[0058] It should be noted that the system architecture and business scenarios described in the embodiments of the present application are for more clearly explaining the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those of ordinary skill in the art know that with the evolution of the system architecture and the emergence of new business scenarios, the technical solutions provided by the embodiments of the present application are equally applicable to similar technical problems.

[0059] Next, a detailed explanation of the service offline method provided by the embodiments of the present application will be given.

[0060] Figure 2 is a flowchart of a service offline method provided by the embodiments of the present application. This method is applied to Figure 1 the service publishing node 101 shown in. Please refer to Figure 2 . This method includes the following steps.

[0061] S201. The service publishing node sends a status update request to the service registration node. This status update request is used to request the service registration node to update the status of the target business service to be taken offline to the offline status.

[0062] In some embodiments, the service publishing node can generate a status update request. This status update request carries the identifier and status of the target business service, and the status of the target business service carried by this status update request is the offline status. Then the service publishing node sends this status update request to the service registration node. In this way, after the service registration node receives this status update request, it can update the status of the target business service to the offline status based on the identifier of the target business service.

[0063] Among them, the identifier of the target business service can be the host name and port number of the service node where the target business service is located. Of course, the identifier of the target business service can also be other information used to uniquely identify the target business service. For example, a number can be assigned to each business service in advance, or a service name can be assigned to each business service, as long as the numbers or service names corresponding to different business services are different.

[0064] It should be noted that in the case where multiple business services are deployed in a service node, different business services correspond to different port numbers. In this way, a business service can be uniquely identified by the host name and port number. In addition, the service publishing node can store the identifiers of each business service in advance. When it is necessary to take the target business service offline, the service publishing node can obtain the identifier of the target business service. Of course, the identifiers of each business service can also be stored in the maintenance node, and this maintenance node is used to regularly maintain each business service. In this way, when it is necessary to take the target business service offline, the service publishing node can obtain the identifier of the target business service from the maintenance node.

[0065] For example, assume that the identifier of the target business service is the host name and port number, and the host name corresponding to the target business service is a.b.c.d, and the port number is xxxx. The status update request generated based on this host name and port number is as follows:

[0066] HTTP PUT / eureka / apps / COLA-WEB-DEMO / hostname:a.b.c.d:xxxx / status?value=DOWN.

[0067] Among them, value=DOWN means that the request is to update the status of the target business service to the offline status.

[0068] S202. The service publishing node waits for the first duration to enable the gateway node to obtain the status of the target business service as the offline status from the service registration node.

[0069] Based on the above description, the gateway node regularly obtains the status of each business service from the service registration node. Therefore, after the service publishing node requests the service registration node to update the status of the target business service to the offline status, the service publishing node can wait for the first duration. In this way, it can be ensured that the gateway node can obtain the status of the target business service as the offline status from the service registration node.

[0070] Among them, the first duration is greater than or equal to the sum of the second duration and the third duration. The second duration is the time interval for the service registration node to refresh the first service list, and the third duration is the time interval for the gateway node to refresh the second service list. The first service list is used to record the status of the target business service, and the second service list is used to record the business services allowed to process business requests.

[0071] That is to say, the service registration node refreshes the first service list every second duration, and the gateway node refreshes the second service list every third duration. Therefore, the maximum duration for the gateway node to obtain the status of the target business service as offline from the service registration node is the sum of the second duration and the third duration. When the first duration is greater than or equal to the sum of the second duration and the third duration, waiting for the first duration can ensure that the gateway node obtains the status of the target business service as offline from the service registration node.

[0072] In some embodiments, the service registration node includes a first-level cache and a second-level cache. The first-level cache is used to store the first service list, and the second-level cache is used to store the offline status of the target business service obtained by responding to the status update request. The second duration is less than the time interval for the first-level cache to default refresh the first service list.

[0073] That is to say, when the service registration node includes a first-level cache and a second-level cache, after receiving the status update request, the service registration node stores the identifier and offline status corresponding to the target business service in the second-level cache. After reaching the refresh time interval of the first-level cache, the service registration node obtains the identifier and offline status corresponding to the target business service from the second-level cache, and updates the status of the target business service in the first service list stored in the first-level cache to offline status.

[0074] Among them, the time interval for the first-level cache to default refresh the first service list is the default configuration of the service registration node, and its value is usually relatively large. Therefore, reducing the default refresh time interval of the first-level cache to obtain the second duration can update the status of the target business service to offline status in the first service list in a shorter time and reduce the waiting time of the service publishing node.

[0075] In some embodiments, the second service list includes a service status list and a load balancing list. The service status list is used to record the status of each business service obtained from the service registration node, and the load balancing list is used to record the business services in the online status in the service status list. The third duration is the sum of the refresh time interval of the service status list and the refresh time interval of the load balancing list.

[0076] That is, when the second service list includes a service status list and a load balancing list, after the refresh time interval of the service status list is reached, the gateway node obtains the status of the target business service as offline from the service registration node and refreshes the service status list. Then, after the refresh time interval of the load balancing list is reached, the gateway node obtains the status of the target business service as offline from the service status list and deletes the target business service from the load balancing list.

[0077] Among them, the refresh time interval of the load balancing list is greater than or equal to the refresh time interval of the service status list, which can ensure that when the refresh time interval of the load balancing list is reached, the status of each business service in the service status list is the latest status.

[0078] It should be noted that the refresh time interval of the first-level cache, the refresh time interval of the service status list, and the refresh time interval of the load balancing list can all be modified through relevant configurations. For example, the above refresh time intervals can be modified to the minimum value, so that the first duration can be reduced.

[0079] Exemplarily, when the service node deploys the business service based on the SpringCloud framework, for a certain version of the SpringCloud framework, the relevant configurations of the refresh time interval of the first-level cache, the refresh time interval of the service status list, and the refresh time interval of the load balancing list are as follows:

[0080] eureka.server.response-cache-update-intervals-ms=1000

[0081] eureka.client.registry-fetcch-interval-seconds=1

[0082] spring.cloud.loadbalancer.cache.ttl=2s

[0083] Among them, eureka.server.response-cache-update-intervals-ms=1000 indicates that the refresh time interval of the first-level cache is 1 second, eureka.client.registry-fetcch-interval-seconds=1 indicates that the refresh time interval of the service status list is 1 second, and spring.cloud.loadbalancer.cache.ttl=2s indicates that the refresh time interval of the load balancing list is 2 seconds.

[0084] S203. When the waiting for the first time period ends, the service publishing node sends a service offline message to the service node where the target business service is deployed, and the service offline message is used to instruct the service node to take the target business service offline.

[0085] When the waiting for the first time period ends, the gateway node has obtained the status of the target business service as offline from the service registration node, and the gateway node has also stopped sending business requests to the target business service. At this time, a service offline message is sent to the service node where the target business service is deployed to instruct the service node to take the target business service offline. In this case, taking the target business service offline will not affect business requests.

[0086] In the case where multiple business services are deployed on one service node, the service offline message carries the identifier of the target business service. In this way, after receiving the service offline message, the service node takes the target business service offline according to the identifier of the target business service.

[0087] Since each business service includes one or more running instances, each running instance corresponds to a running process, and each running process corresponds to a process ID. That is, each business service corresponds to the process ID of one or more running processes. Therefore, the service node can determine the process ID of one or more running processes corresponding to the target business service according to the identifier of the target business service and the pre-stored correspondence between the identifier and the process ID, and then close the running processes corresponding to the one or more process IDs, thus realizing taking the target business service offline.

[0088] In the case where one business service is deployed on one service node, the service offline message may not carry the identifier of the target business service. In this way, after receiving the service offline message, the service node can directly close the running processes on the service node to realize taking the target business service offline.

[0089] Exemplarily, the command kill pid or kill - 9 pid can be used to close the processes corresponding to the one or more process IDs, where pid is the process ID.

[0090] Optionally, after sending the service offline message to the service node where the target business service is deployed, it further includes: sending a service deletion request to the service registration node, and the service deletion request is used to request the service registration node to delete the relevant data of the target business service. After the service registration node deletes the relevant data of the target business service, a service publishing message is sent to the service node, and the service publishing message is used to instruct the service node to redeploy the target business service.

[0091] After the service registration node updates the status of the target business service to the offline status, relevant data of the target business service still remains in the service registration node. During actual testing, it is found that the relevant data of the target business service may cause the status of the target business service to be abnormal after redeployment. Therefore, it is necessary to send a service deletion request to this service registration node to request the service registration node to delete the relevant data of the target business service. After that, a service publishing message is sent to this service node, and the service publishing message carries the identifier corresponding to the target business service. After receiving the service publishing message, this service node redeploys the target business service.

[0092] It should be noted that the above-mentioned target business service can be a microservice or a monolithic service. When the target business service is a microservice, this service registration node is a node deployed with the Eureka service.

[0093] Among them, the service node usually deploys microservices based on the SpringCloud framework. The Eureka service provided by this SpringCloud framework can be used for the registration and status management of microservices. In this case, this service registration node is a node deployed with the Eureka service.

[0094] Exemplarily, when the service node deploys microservices based on the SpringCloud framework, this service registration node can be an Eureka Server, and this gateway node can be a SpringCloud gateway. As Figure 3 shown, taking microservices as an example, the service offline method provided by the embodiments of the present application is exemplarily described. This method includes steps S301 - S308.

[0095] S301. The service publishing node receives the publishing instruction of the target microservice to be taken offline. Among them, this publishing instruction is triggered by the publisher.

[0096] S302. The service publishing node obtains the host name and port number of the target microservice, and generates a status update request. This status update request carries the host name and port number of the target microservice. Then, it calls the interface of the Eureka Server and sends this status update request to the Eureka Server.

[0097] S303. The Eureka Server receives this status update request and updates the status of the target microservice to be taken offline to the offline status.

[0098] When the Eureka Server includes a first-level cache and a second-level cache, after receiving the status update request, the Eureka Server stores the status of the target microservice as the offline status in the second-level cache. After reaching the refresh time interval of the first-level cache, the Eureka Server obtains the offline status of the target microservice from the second-level cache and updates the status of the target microservice stored in the first-level cache to the offline status.

[0099] S304. The service publishing node waits for a first duration to wait for the status of the target microservice in the microservice list of the SpringCloud gateway to be refreshed to the offline status.

[0100] S305. During the process of the service publishing node waiting for the first duration, after reaching the service acquisition time interval, the SpringCloud gateway obtains the status of the target microservice from the Eureka Server as the offline status, refreshes the status of the target microservice in the microservice list to the offline status, and stops forwarding business requests to the target microservice.

[0101] Among them, the first duration is the sum of the cache refresh time interval and the service acquisition time interval. The default cache refresh time interval of the Eureka Server is 90 seconds. The cache refresh time interval and the service acquisition time interval can be modified to reduce the first duration, thereby accelerating the publishing speed of the target microservice.

[0102] S306. The service publishing node sends a service offline message to the service node to instruct the service node to take the target microservice offline. Among them, the kill-9 command can be used to force the target microservice offline.

[0103] S307. The service publishing node sends an HTTP DELETE request to the Eureka Server to request the Eureka Server to delete the relevant data of the target microservice from the Eureka Server. Among them, the purpose of this step is to prevent the Eureka Server from being unable to delete the relevant data of the target microservice in case of an abnormal situation or entering the protection mode of the Eureka Server, resulting in an abnormal status of the target microservice after redeployment.

[0104] S308. The service publishing node sends a service publishing message to the service node to instruct the service node to redeploy the target microservice.

[0105] It should be noted that after the service node redeploys the target business service, it can send a service registration request to the service registration node. After receiving the service registration request, the service registration node completes the registration of the target business service, then records the target business service in the first service list, and sets the status of the target business service in the first service list to the online status. After reaching the third time period, the gateway node obtains the online status of the target business service from the service registration node and records the online status of the target business service in the second service list. After that, the gateway node forwards the corresponding business request to the target business service.

[0106] Based on the above description, in some embodiments, the second service list includes a service status list and a load balancing list. In this case, after reaching the refresh time interval of the service status list, the gateway node obtains the online status of the target business service from the service registration node and records it in the service status list. Then, after reaching the refresh time interval of the load balancing list, the gateway node obtains the online status of the target business service from the service status list and records it in the load balancing list. After that, the gateway node forwards the corresponding business request to the target business service.

[0107] In the embodiments of the present application, by sending a status update request to the service registration node to request the service registration node to update the status of the target business service to be taken offline to the offline status, and then waiting for the first time period to ensure that the gateway node obtains the offline status of the target business service from the service registration node. In this way, the gateway node stops forwarding business requests to the target business service. At this time, when requesting the service node to take the target business service offline, it will not affect the business requests.

[0108] Figure 4 It is a schematic structural diagram of a service offline device provided by the embodiments of the present application. The service offline device can be implemented by software, hardware, or a combination of both to be part or all of the service publishing node. The service publishing node can be Figure 1 the service publishing node 101 shown in the figure. Please refer to Figure 3 , the device includes: a first sending module 401, a waiting module 402, and a second sending module 403.

[0109] The first sending module 401 is used to send a status update request to the service registration node, and the status update request is used to request the service registration node to update the status of the target business service to be taken offline to the offline status;

[0110] The waiting module 402 is used to wait for the first time period to enable the gateway node to obtain the offline status of the target business service from the service registration node;

[0111] The second sending module 403 is configured to send a service offline message to a service node where a target business service is deployed when the waiting for the first duration ends. The service offline message is used to instruct the service node to take the target business service offline.

[0112] Optionally, the first duration is greater than or equal to the sum of the second duration and the third duration. The second duration is the time interval for the service registration node to refresh the first service list, and the third duration is the time interval for the gateway node to refresh the second service list. The first service list is used to record the status of the target business service, and the second service list is used to record the business services allowed to process business requests.

[0113] Optionally, the service registration node includes a first-level cache and a second-level cache. The first-level cache is used to store the first service list, and the second-level cache is used to store the offline status of the target business service obtained by responding to the status update request. The second duration is less than the time interval for the first-level cache to default-refresh the first service list.

[0114] Optionally, the second service list includes a service status list and a load balancing list. The service status list is used to record the status of each business service obtained from the service registration node, and the load balancing list is used to record the online business services in the service status list. The third duration is the sum of the refresh time interval of the service status list and the refresh time interval of the load balancing list.

[0115] Optionally, the apparatus further includes:

[0116] A third sending module, configured to send a service deletion request to the service registration node. The service deletion request is used to request the service registration node to delete the relevant data of the target business service;

[0117] A fourth sending module, configured to send a service publishing message to the service node after the service registration node deletes the relevant data of the target business service. The service publishing message is used to instruct the service node to redeploy the target business service.

[0118] Optionally, the target business service is a microservice, and the service registration node is a node where the Eureka service is deployed.

[0119] In the embodiments of the present application, by sending a status update request to the service registration node to request the service registration node to update the status of the target business service to be taken offline to the offline status, and then waiting for the first duration to ensure that the gateway node obtains the status of the target business service as the offline status from the service registration node. In this way, the gateway node stops forwarding business requests to the target business service. At this time, when requesting the service node to take the target business service offline, it will not affect the business requests.

[0120] It should be noted that: when the service offline device provided in the above embodiments is used to offline a service, only the division of the above functional modules is used for illustration. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the service offline device provided in the above embodiments and the embodiments of the service offline method belong to the same concept. For the specific implementation process, please refer to the method embodiments and will not be elaborated here.

[0121] Figure 5 FIG. 4 is a schematic structural diagram of a server provided by an embodiment of the present application. The server may be the above service publishing node. The server 500 includes a central processing unit (CPU) 501, a system memory 504 including a random access memory (RAM) 502 and a read-only memory (ROM) 503, and a system bus 505 connecting the system memory 504 and the central processing unit 501. The server 500 further includes a basic input / output system (I / O system) 506 for transmitting information between various components within the computer, and a mass storage device 507 for storing an operating system 513, application programs 514, and other program modules 515.

[0122] The basic input / output system 506 includes a display 508 for displaying information and input devices 509 such as a mouse and a keyboard for user input. Both the display 508 and the input devices 509 are connected to the central processing unit 501 through an input / output controller 510 connected to the system bus 505. The basic input / output system 506 may further include an input / output controller 510 for receiving and processing inputs from multiple other devices such as a keyboard, a mouse, or an electronic stylus. Similarly, the input / output controller 510 also provides outputs to a display screen, a printer, or other types of output devices.

[0123] The mass storage device 507 is connected to the central processing unit 501 through a mass storage controller (not shown) connected to the system bus 505. The mass storage device 507 and its associated computer-readable medium provide non-volatile storage for the server 500. That is to say, the mass storage device 507 may include a computer-readable medium (not shown) such as a hard disk or a CD-ROM drive.

[0124] Without loss of generality, computer-readable media can include computer storage media and communication media. Computer storage media includes volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes RAM, ROM, EPROM, EEPROM, flash memory or other solid-state storage technologies, CD-ROM, DVD or other optical storage, magnetic tape cartridges, tapes, disk storage or other magnetic storage devices. Of course, those skilled in the art will know that computer storage media is not limited to the above several types. The above-mentioned system memory 504 and mass storage device 507 can be collectively referred to as memory.

[0125] According to various embodiments of the present application, the server 500 can also be connected to a remote computer on the network through a network such as the Internet. That is, the server 500 can be connected to the network 512 through the network interface unit 511 connected to the system bus 505. Or rather, the network interface unit 511 can also be used to connect to other types of networks or remote computer systems (not shown).

[0126] The above-mentioned memory further includes one or more programs, and one or more programs are stored in the memory and configured to be executed by the CPU.

[0127] In some embodiments, a service offline system is further provided, and the system includes: a service publishing node, a service registration node, a gateway node, and at least one service node;

[0128] The service publishing node is used to send a status update request to the service registration node. The service registration node is used to receive the status update request and update the status of the target business service to be taken offline to the offline status. The service publishing node is further used to wait for a first duration. During the process that the service publishing node waits for the first duration, the gateway node is used to obtain from the service registration node that the status of the target business service is the offline status. When the waiting for the first duration ends, the service publishing node is further used to send a service offline message to the service nodes in which the target business service is deployed. The service nodes in which the target business service is deployed are used to receive the service offline message and take offline the target business service.

[0129] Optionally, the service publishing node is further used to send a service deletion request to the service registration node. The service registration node is further used to receive the service deletion request and delete the relevant data of the target business service. After the service registration node deletes the relevant data of the target business service, the service publishing node is further used to send a service publishing message to the service nodes in which the target business service is deployed. The service nodes in which the target business service is deployed are further used to receive the service publishing message and redeploy the target business service.

[0130] In some embodiments, a computer-readable storage medium is further provided. A computer program is stored in the storage medium, and when the computer program is executed by a processor, the steps of the service offline method in the above embodiments are implemented. For example, the computer-readable storage medium may be a ROM, a RAM, a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0131] It should be noted that the computer-readable storage medium mentioned in the embodiments of the present application may be a non-volatile storage medium, in other words, it may be a non-transitory storage medium.

[0132] It should be understood that all or part of the steps of implementing the above embodiments can be realized by software, hardware, firmware, or any combination thereof. When implemented by software, it can be realized in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. The computer instructions can be stored in the above computer-readable storage medium.

[0133] That is, in some embodiments, a computer program product containing instructions is further provided. When it runs on a computer, the computer is caused to execute the steps of the service offline method described above.

[0134] It should be understood that the "at least one" mentioned herein refers to one or more, and the "multiple" refers to two or more. In the description of the embodiments of the present application, unless otherwise specified, " / " means "or". For example, A / B may represent A or B; the "and / or" herein is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in order to clearly describe the technical solutions of the embodiments of the present application, in the embodiments of the present application, terms such as "first" and "second" are used to distinguish the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the terms "first" and "second" do not limit the quantity and execution order, and the terms "first" and "second" do not necessarily mean different.

[0135] The above are the embodiments provided by the present application, which are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A service offline method, characterized in that, Applied to a service publishing node, the method includes: Sending a status update request to a service registration node, where the status update request is used to request the service registration node to update the status of a target business service to be taken offline to an offline status. The status update request carries the identifier and status of the target business service, and the status of the target business service carried in the status update request is the offline status; Waiting for a first duration to enable the gateway node to obtain from the service registration node that the status of the target business service is the offline status; When the waiting for the first duration ends, sending a service offline message to the service node where the target business service is deployed, where the service offline message is used to instruct the service node to close one or more running processes corresponding to the target business service to take the target business service offline; Sending a service deletion request to the service registration node, where the service deletion request is used to request the service registration node to delete the relevant data of the target business service.

2. The method according to claim 1, characterized in that The first duration is greater than or equal to the sum of a second duration and a third duration. The second duration is the time interval for the service registration node to refresh a first service list, and the third duration is the time interval for the gateway node to refresh a second service list. The first service list is used to record the status of the target business service, and the second service list is used to record the business services allowed to process business requests.

3. The method according to claim 2, wherein The service registration node includes a first-level cache and a second-level cache. The first-level cache is used to store the first service list, and the second-level cache is used to store the offline status of the target business service obtained by responding to the status update request. The second duration is less than the time interval for the first-level cache to default refresh the first service list.

4. The method according to claim 2 or 3, characterized in that The second service list includes a service status list and a load balancing list. The service status list is used to record the status of each business service obtained from the service registration node, and the load balancing list is used to record the business services in the online status in the service status list. The third duration is the sum of the refresh time interval of the service status list and the refresh time interval of the load balancing list.

5. The method according to claim 1, wherein The method further includes: After the service registration node deletes the relevant data of the target business service, sending a service publishing message to the service node, where the service publishing message is used to instruct the service node to redeploy the target business service.

6. The method according to claim 1, wherein The target business service is a microservice, and the service registration node is a node deployed with an Eureka service.

7. A service offline system, characterized in that The system includes: a service publishing node, a service registration node, a gateway node, and at least one service node; The service publishing node is used to send a status update request to the service registration node; The service registration node is used to receive the status update request, update the status of the target business service to be taken offline to an offline status. The status update request carries the identifier and status of the target business service, and the status of the target business service carried in the status update request is the offline status; The service publishing node is further used to wait for a first duration; During the process of waiting for the first duration at the service publishing node, the gateway node is configured to obtain the status of the target business service as offline from the service registration node; When the waiting for the first duration ends, the service publishing node is further configured to send a service offline message to the service node(s) among the at least one service node(s) where the target business service is deployed; The service node(s) where the target business service is deployed is / are configured to receive the service offline message and close one or more running processes corresponding to the target business service to achieve taking the target business service offline; The service publishing node is further configured to send a service deletion request to the service registration node; The service registration node is further configured to receive the service deletion request and delete the relevant data of the target business service.

8. The system according to claim 7, wherein The service publishing node is further configured to send a service deletion request to the service registration node; The service registration node is further configured to receive the service deletion request and delete the relevant data of the target business service; After the service registration node deletes the relevant data of the target business service, the service publishing node is further configured to send a service publishing message to the service node(s) where the target business service is deployed; The service node(s) where the target business service is deployed is / are further configured to receive the service publishing message and redeploy the target business service.

9. A computer device, characterized in that, The computer device includes a memory and a processor. The memory is used to store a computer program, and the processor is configured to execute the computer program stored on the memory to implement the steps of the method according to any one of claims 1-6 above.

10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, and when the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Load balancing method and device

    CN110995519A

  • Service unit offline method based on micro-service unit architecture and related device

    CN112948098A