Service publishing method and device, computer device and storage medium
By acquiring service release parameters and controlling the offline and online status of instances according to preset rules, the problem of old instances being offline but still being perceived by the terminal and new instances not being ready in the service release process is solved, thereby achieving the rationality of service release and improving user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA PING AN PROPERTY INSURANCE CO LTD
- Filing Date
- 2022-09-09
- Publication Date
- 2026-04-14
AI Technical Summary
In the existing service deployment process, old instances are taken offline but can still be detected by the end user, while new instances are not ready but are detected by the end user, leading to systemic errors and affecting user experience.
By obtaining service publication parameters, it is determined whether instances need to be taken offline or brought online. Preset rules are used to control the offline and online processes of instances, ensuring the rationality of service publication, including graceful offline and ready probe detection.
This reduces the likelihood of terminals noticing the service release process too early or too late, thus improving the user experience.
Smart Images

Figure CN116319960B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of service upgrade technology, and in particular to a service publishing method, apparatus, computer equipment, and storage medium. Background Technology
[0002] Currently, the service deployment process generally includes taking old instances offline, rolling deployment of new instances, and bringing new instances online. However, during this process, there may be situations where old instances have been taken offline, but the end-user can still perceive and request them; or new instances may not be ready yet, meaning they are still unavailable, but the end-user can already perceive and request them. These issues can lead to systemic errors and service deployment failures, ultimately impacting the user experience. Therefore, existing technologies suffer from an unreasonable service deployment process, affecting the user experience. Summary of the Invention
[0003] The main purpose of this application is to provide a service publishing method, apparatus, computer equipment, and storage medium, which aims to improve the rationality of the service publishing process, reduce the possibility that the service publishing process is perceived by the terminal too early or too late, and improve the user experience.
[0004] In a first aspect, this application provides a service publishing method, which includes the following steps:
[0005] Retrieve the service publication parameters;
[0006] Based on the published parameters, determine whether the first instance of the service needs to be taken offline, and / or determine whether the second instance needs to be brought online to the service;
[0007] If it is determined that the first instance of the service needs to be taken offline, the first instance is taken offline based on the preset instance offline rules;
[0008] If it is determined that a second instance needs to be deployed to the service, the deployment of the second instance is controlled based on the preset instance deployment rules.
[0009] If it is determined that the first instance of the service does not need to be taken offline, and it is determined that the second instance of the service does not need to be brought online, then the service is considered published.
[0010] Secondly, this application also provides a service publishing apparatus, the service publishing apparatus comprising:
[0011] The acquisition module is used to obtain the service publication parameters;
[0012] The judgment module is used to determine, based on the publication parameters, whether the first instance of the service needs to be taken offline, and / or whether the second instance needs to be brought online to the service;
[0013] The offline module is used to control the first instance to go offline if it is determined that the first instance of the service needs to be taken offline, based on a preset instance offline rule.
[0014] The online module is used to control the online deployment of the second instance based on preset instance online rules if it is determined that a second instance needs to be deployed to the service.
[0015] The publishing module is used to determine that the service publishing is complete if it is determined that a first instance of the service does not need to be taken offline, and a second instance of the service does not need to be brought online.
[0016] Thirdly, this application also provides a computer device, which includes a memory and a processor;
[0017] The memory is used to store computer programs;
[0018] The processor is configured to execute the computer program and, in executing the computer program, implement the service publishing method as described above.
[0019] Fourthly, this application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the service publishing method described above.
[0020] This application provides a service publishing method, apparatus, computer device, and storage medium. The method includes: obtaining service publishing parameters; determining, based on the publishing parameters, whether a first instance of the service needs to be taken offline, and / or determining whether a second instance needs to be added to the service; if it is determined that the first instance of the service needs to be taken offline, controlling the first instance to go offline based on preset instance offline rules; if it is determined that a second instance needs to be added to the service, controlling the second instance to go online based on preset instance online rules; if it is determined that the first instance of the service does not need to be taken offline, and it is determined that a second instance does not need to be added to the service, determining that the service publishing is complete, thereby improving the rationality of the service publishing process, reducing the possibility that the service publishing process is perceived by the terminal too early or too late, and improving the user experience. Attached Figure Description
[0021] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a flowchart illustrating a service publishing method provided in an embodiment of this application;
[0023] Figure 2 This is an application scenario diagram of a service publishing method according to an embodiment of this application;
[0024] Figure 3 This is a schematic diagram illustrating service publishing according to an embodiment of this application;
[0025] Figure 4 This is a flowchart illustrating the service publishing process according to an embodiment of this application;
[0026] Figure 5 This is a schematic block diagram of a service publishing device provided in an embodiment of this application;
[0027] Figure 6 This is a schematic block diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0028] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0029] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the order described. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change depending on the actual situation.
[0030] This application provides a service publishing method, apparatus, computer equipment, and storage medium. The service publishing method can be applied to terminal devices, such as mobile phones, tablets, laptops, and desktop computers. It can also be applied to servers, which can be standalone servers or cloud servers providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0031] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0032] Please see Figure 1 , Figure 1 This is a flowchart illustrating a service publishing method provided in an embodiment of this application. It should be noted that the service publishing method provided in this embodiment can be used on terminal devices, and of course, it can also be used on servers. It can also be... Figure 2 As shown, the server can obtain the service publishing parameters from the terminal device, obtain the published service according to the service publishing method, and then the terminal device can call the published service. Figure 2 This diagram illustrates only one application scenario of the service publishing method. It should be understood that the service publishing method is not limited to... Figure 2 The scene shown.
[0033] In practice, terminal devices include, but are not limited to, any of the following: mobile phones, tablets, laptops, and desktop computers; servers can be standalone servers, server clusters, or cloud servers that provide cloud computing services.
[0034] For example, this service publishing method is applied to an architecture that combines a service discovery framework (Eureka, the service publishing framework) with a user interface (Ribbon, the user interface), where Eureka includes Eureka Server and Eureka Client.
[0035] In some embodiments, when Eureka discovers a service, the Eureka Client registers the discovered service with the Eureka Server, allowing the Eureka Server to add the service to its service list. For example, the Eureka Client sends service metadata to the Eureka Server. This metadata includes at least one of the following: IP address (Internet Protocol Address), port, homepage, etc. Based on this metadata, the Eureka Server determines whether the service needs to be registered and adds it to its service list.
[0036] In some embodiments, the Eureka Client renews its service with the Eureka Server at regular intervals to demonstrate the service's activity. If the Eureka Client fails to renew the service with the Eureka Server for several consecutive time intervals, and the service is not in protection mode, the Eureka Server assumes the service has expired and removes it from the service list. For example, the Eureka Client renews the service with the Eureka Server every 30 seconds by default. If the Eureka Server does not receive a renewal notice for 90 consecutive seconds, and the service is not in protection mode, it removes the service from the service list.
[0037] In some embodiments, the Eureka Client retrieves the service list from the Eureka Server at default intervals, such as every 30 seconds. For example, when retrieving the service list from the Eureka Server, the Eureka Client already has a cached service list. The Eureka Client can compare the currently retrieved service list with the currently cached service list, and merge the two lists based on the comparison results. For instance, the Eureka Client can directly use its own cached service list when it needs to access the service list.
[0038] For example, the Eureka Client retrieves and caches the service list from the Eureka Server at intervals of approximately 30 seconds, and Ribbon also retrieves and caches the service list from the Eureka Client at approximately 30 seconds. In other words, Ribbon can directly use its own cached service list when it needs to access it.
[0039] like Figure 1 As shown, the service publishing method includes steps S101 to S105.
[0040] Step S101: Obtain the service publication parameters.
[0041] For example, service publishing could be used to upgrade a first instance of a service to a second instance.
[0042] In some embodiments, the deployment parameters include the number of first instances, the number of second instances, the number of unavailable instances, and the number of overrunning instances. For example, the number of first instances indicates the number of first instances currently awaiting decommissioning, the number of second instances indicates the number of second instances currently online, the number of unavailable instances indicates the number of unavailable instances among the instances excluding overrunning instances, and the number of overrunning instances indicates the number of overrunning instances.
[0043] Optionally, the service publishing process can be improved based on the service publishing parameters to enhance its efficiency.
[0044] Step S102: Based on the release parameters, determine whether the first instance of the service needs to be taken offline, and / or determine whether the second instance needs to be brought online to the service.
[0045] For example, when publishing a service, the service publishing parameters will change as the service publishing progresses. Therefore, it is necessary to determine whether the first instance of the service needs to be taken offline and / or whether the second instance needs to be brought online to the service based on the publishing parameters.
[0046] In some embodiments, when determining whether a first instance of the service needs to be taken offline, and / or whether a second instance needs to be brought online to the service, the release parameters are determined by combining a first quantity threshold, a second quantity threshold, an unavailable quantity threshold, a first exceeded quantity threshold, and a second exceeded quantity threshold.
[0047] For example, the first quantity threshold, the second quantity threshold, the unavailable quantity threshold, the first exceeded quantity threshold, and the second exceeded quantity threshold can be preset or set by the user, and there is no restriction here.
[0048] In some embodiments, a first quantity threshold is set to 0. For example, when a service is published, it is necessary to upgrade the first instance in the service to a second instance. When the service is published, the number of the first instance in the service is 0. Therefore, the first quantity threshold is set to 0.
[0049] In some embodiments, a second quantity threshold is determined based on the number of first instances included in the service publication parameters obtained in the first instance. For example, when a service is published, it is necessary to upgrade the first instance in the service to a second instance. When the service is published, the number of second instances in the service is equal to the number of first instances obtained in the first instance. Therefore, the second quantity threshold is set to the number of first instances obtained in the first instance.
[0050] In some embodiments, the unavailability threshold is set to 0. For example, during service deployment, the service can still renew its contract with the Eureka Server through the Eureka Client, and terminal devices can still detect the service, for example, through Ribbon. Exemplarily, when the unavailability threshold is not set to 0, even if some instances of the service are unavailable, terminal devices can still call the service. In this case, when a terminal device calls the service, traffic will flow into the unavailable instances, leading to systemic errors and service deployment failure. Therefore, setting the unavailability threshold to 0 can prevent terminal devices from calling unavailable instances, improve the rationality of the service deployment process, reduce the possibility of the service deployment process being detected by the terminal too early or too late, and improve the user experience.
[0051] For example, the system determines whether the first instance has been taken offline based on whether the number of the first instance is equal to the first quantity threshold; it determines whether the second instance has been brought online based on whether the number of the second instance is equal to the second quantity threshold; it determines whether the service release process meets the requirements based on whether the number of unavailable instances is less than or equal to the unavailable quantity threshold; and it determines whether the service release process meets the requirements based on whether the number of excess instances is greater than or equal to the first excess quantity threshold and / or less than or equal to the second excess quantity threshold.
[0052] Optionally, based on the deployment parameters, determine whether the first instance needs to be taken offline and / or whether the second instance needs to be brought online, including: when the number of first instances is greater than a first quantity threshold, the number of second instances is less than a second quantity threshold, the number of unavailable instances is less than or equal to an unavailable quantity threshold, and the number of instances exceeding the threshold is equal to a first exceeding quantity threshold, determine that the second instance needs to be brought online; when the number of first instances is greater than the first quantity threshold, the number of second instances is less than the second quantity threshold, the number of unavailable instances is less than or equal to an unavailable quantity threshold, and the number of instances exceeding the threshold is greater than the first exceeding quantity threshold and less than or equal to the second exceeding quantity threshold, determine that the first instance needs to be taken offline and that the second instance needs to be brought online; when the number of first instances is greater than the first quantity threshold, the number of second instances is equal to the second quantity threshold, the number of unavailable instances is less than or equal to an unavailable quantity threshold, and the number of instances exceeding the threshold is greater than the first exceeding quantity threshold and less than or equal to the second exceeding quantity threshold, determine that the first instance needs to be taken offline. Optionally, when the number of first instances equals the first quantity threshold, the number of second instances equals the second quantity threshold, the number of unavailable instances is less than or equal to the unavailable quantity threshold, and exceeds the number of instances equal to the first quantity threshold, it is determined that the first instance does not need to be taken offline, and the second instance does not need to be brought online.
[0053] For example, after determining that a first instance of the service needs to be taken offline, and / or determining that a second instance of the service needs to be brought online, the process includes: determining the number of the first instance that needs to be taken offline, and / or determining the number of the second instance that needs to be brought online, based on at least two of the following: publishing parameters, a first quantity threshold, a second quantity threshold, an unavailable quantity threshold, a first exceeded quantity threshold, and a second exceeded quantity threshold.
[0054] For example, such as Figure 3As shown, when a service is published, the first published service parameters obtained are: the number of first instances is 3, the number of second instances is 0, the number of unavailable instances is 0, and the number of instances exceeding the limit is 0. For example, when a service is published, the number of first instances needs to be 0, the number of second instances needs to be 3, the number of unavailable instances needs to be 0, and the number of overrun instances needs to be 0. For instance, if we set the first threshold to 0, the second threshold to 3, the unavailable threshold to 0, the first overrun threshold to 0, and the second overrun threshold to 1, then we can determine that the number of first instances is greater than the first threshold, the number of second instances is less than the second threshold, the number of unavailable instances equals the unavailable threshold, and the number of overrun instances equals the first overrun threshold. Since the number of unavailable instances needs to be consistently less than or equal to the unavailable threshold, we determine that a second instance needs to be added to the service. Specifically, since the number of overrun instances needs to be greater than or equal to the first overrun threshold and less than or equal to the second overrun threshold, we determine that the number of the second instance to be added is one. When the added second instance is detected to be available, the current service publication parameters are: the number of first instances is 3, the number of second instances is 1, the number of unavailable instances is 0, and the number of overrun instances is 1. Therefore, we can determine that the number of first instances is greater than the first threshold, and the number of second instances is less than the second threshold. If the number of instances is less than the second threshold, the number of unavailable instances equals the unavailable threshold, and the number of instances exceeding the threshold equals the second exceeding threshold, and since the number of unavailable instances needs to be continuously less than or equal to the unavailable threshold, and the number of instances exceeding the threshold needs to be greater than or equal to the first exceeding threshold and less than or equal to the second exceeding threshold, it is determined that the first instance needs to be taken offline from the service, and it is determined that the second instance needs to be brought online to the service. Due to the limitations of the unavailable threshold and the second exceeding threshold, it is determined that the number of the first instance to be taken offline is one, and the number of the second instance to be brought online is one. When the second instance is detected to be in an available state, the current service's publishing parameters are: the number of the first instance is 2, the number of the second instance is 2, the number of unavailable instances is 0, and the number of instances exceeding the threshold is 1. Therefore, it is determined that the number of the first instance is greater than the first threshold, the number of the second instance is less than the second threshold, the number of unavailable instances equals the unavailable threshold, and the number of instances exceeding the threshold equals the second exceeding threshold. Similarly, it is determined that one first instance needs to be taken offline from the service, and one second instance needs to be brought online to the service.When the second instance is detected to be available, and the current service deployment parameters are: 1 first instance, 3 second instances, 0 unavailable instances, and 1 excess instance, it can be determined that the number of first instances exceeds a first threshold, the number of second instances equals a second threshold, the number of unavailable instances equals an unavailable threshold, and the number of excess instances equals a second excess threshold. Due to the limitations of the first and first excess thresholds, it is determined that one first instance needs to be taken offline from the service. Therefore, the current number of first instances is 0, the number of second instances is 3, the number of unavailable instances is 0, and the number of excess instances is 0. It is determined that the first instance of the service does not need to be taken offline, and the second instance does not need to be deployed to the service, thus confirming that the service deployment is complete.
[0055] For example, when a service is published, the first published parameters obtained are: the number of first instances is 5, the number of second instances is 0, the number of unavailable instances is 0, and the number of over-limited instances is 0. For example, when a service is published, the number of first instances needs to be 0, the number of second instances needs to be 5, the number of unavailable instances needs to be 0, and the number of overrun instances needs to be 0. For instance, if we set the first threshold to 0, the second threshold to 5, the unavailable threshold to 0, the first overrun threshold to 0, and the second overrun threshold to 1, then we can determine that the number of first instances is greater than the first threshold, and the number of second instances is less than the second threshold. Since the number of unavailable instances needs to be consistently less than or equal to the unavailable threshold, we determine that a second instance needs to be added to the service. Here, since the number of overrun instances needs to be greater than or equal to the first overrun threshold and less than or equal to the second overrun threshold, we determine that the number of second instances to be added is one or two. Taking two second instances as an example, when the second instance is detected to be available, the current service publication parameters are: the number of first instances is 5, the number of second instances is 2, the number of unavailable instances is 0, and the number of overrun instances is 2. Therefore, we can determine that the number of first instances is greater than the first threshold, the number of second instances is less than the second threshold, the number of unavailable instances equals the unavailable threshold, and the number of overrun instances equals the second overrun threshold. If the number of instances needs to be consistently less than or equal to the unavailable number threshold, and the number of instances exceeding the threshold needs to be greater than or equal to the first exceeding number threshold and less than or equal to the second exceeding number threshold, then it is determined that the first instance needs to be taken offline from the service, and it is determined that the second instance needs to be brought online to the service. Due to the limitations of the unavailable number threshold and the second exceeding number threshold, the number of the first instance taken offline can be one or two, and the number of the second instance brought online can be one or two. For example, if the number of the first instance taken offline is two, and the number of the second instance brought online is two, when the second instance is detected to be in an available state, the current service's publishing parameters are: the number of the first instance is 3, the number of the second instance is 4, the number of unavailable instances is 0, and the number of exceeding instances is 2. Therefore, it can be determined that the number of the first instance is greater than the first number threshold, the number of the second instance is less than the second number threshold, the number of unavailable instances is equal to the unavailable number threshold, and the number of exceeding instances is equal to the second exceeding number threshold. Similarly, it can be determined that the first instance needs to be taken offline from the service, and it is determined that the second instance needs to be brought online to the service. Due to the limitations of the unavailable number threshold, the number of the first instance taken offline can be one or two, and due to the limitations of the second number threshold, the number of the second instance brought online is one.Taking two instances as an example, when the second instance is detected to be available, the current service deployment parameters are: 1 instance of the first service, 5 instances of the second service, 0 unavailable instances, and 1 instance exceeding the service limit. Therefore, the number of available instances is greater than a first threshold, the number of available instances is equal to a second threshold, the number of unavailable instances is equal to an unavailable threshold, and the number of exceeding the service limit is greater than a first exceeding threshold but less than a second exceeding threshold. Thus, the first instance that needs to be taken offline is determined. However, due to the limitation of the first threshold, the number of instances to be taken offline is 1. Therefore, the current number of instances is 0, the number of available instances is 5, the number of unavailable instances is 0, and the number of exceeding the service limit is 0. It is determined that the first instance does not need to be taken offline, and the second instance does not need to be deployed to the service, thus confirming that the service deployment is complete.
[0056] Step S103: If it is determined that the first instance needs to be taken offline, control the first instance to go offline based on the preset instance offline rules.
[0057] For example, when determining that the first instance of a service needs to be taken offline, if the offline type of the first instance is a first preset type, such as graceful offline, then in response to the offline of the first instance of the service, the Eureka Server updates the stored service list. Subsequently, the Eureka Client retrieves the updated service list from the Eureka Server, and the Ribbon retrieves the updated service list from the Eureka Client. For example, it takes 10 seconds for the Eureka Client to retrieve the updated service list from the Eureka Server, and 3 seconds for the Ribbon to retrieve the updated service list from the Eureka Client. For example, within 13 seconds after the first instance of the service goes offline, since the terminal device can still perceive the service, if the terminal device requests to call the service, traffic may still request the offline first instance, leading to a systemic error and even service publication failure. If the offline type of the first instance is a second preset type, such as non-graceful offline, then in response to the offline of the first instance of the service, if the Eureka Client, for example, does not renew the subscription for the first instance of the service with the Eureka Server for 90 consecutive seconds, then Eureka... The server updates the stored service list. Then, the Eureka Client retrieves the updated service list from the Eureka Server, and the Ribbon retrieves the updated service list from the Eureka Client. For example, the Eureka Server determines to update the service list based on not receiving a renewal request for the first instance of the service from the Eureka Client for 90 consecutive seconds. This update takes 3 seconds for the Eureka Server, 10 seconds for the Eureka Client to retrieve the updated service list, and 3 seconds for the Ribbon to retrieve the updated service list from the Eureka Client. For instance, within 106 seconds after the first instance of the service goes offline, because the terminal device can still perceive the service, if the terminal device requests to call the service, traffic may still be directed to the offline first instance, leading to systemic errors and service deployment failures. Therefore, if it is determined that the first instance of a service needs to be taken offline, it is necessary to control the first instance's offline status based on preset instance offline rules to improve the rationality of the service deployment process, reduce the possibility of the service deployment process being perceived by the terminal too late, and improve the user experience.
[0058] Optionally, based on preset instance offline rules, controlling the first instance offline includes: sending a first instance offline instruction to a preset service discovery framework; updating the stored service list in the service discovery framework according to the first instance offline instruction; determining whether the interval between the current time and the time of sending the first instance offline instruction to the service discovery framework meets a preset time interval threshold; and controlling the first instance offline if the interval meets the preset time interval threshold.
[0059] For example, such as Figure 4 As shown, when it is determined that the first instance needs to be taken offline, a first instance offline command is first sent to the preset service discovery framework. In the service discovery framework, such as Eureka Server, the stored service list is updated according to the first instance offline command, and a preset time interval threshold is waited to ensure that when the terminal device perceives the service, it will not perceive the first instance to be taken offline in the service. Then, the first instance to be taken offline is controlled to improve the rationality of the service release process, reduce the possibility that the service release process is perceived by the terminal too late, and improve the user experience.
[0060] In some embodiments, determining whether the interval between the current time and the time of sending the first instance offline instruction to the service discovery framework meets a preset time interval threshold includes: when the first instance offline instruction is used to indicate that the offline type of the first instance is a first preset type, determining whether the interval between the current time and the time of sending the first instance offline instruction to the service discovery framework meets a preset first time interval threshold; when the first instance offline instruction is used to indicate that the offline type of the first instance is a second preset type, determining whether the interval between the current time and the time of sending the first instance offline instruction to the service discovery framework meets a preset second time interval threshold.
[0061] For example, the first preset type is also known as graceful shutdown, and the second preset type is also known as non-graceful shutdown. The time required for service discovery frameworks such as Eureka Server to update the service list and for Eureka Client and Ribbon to obtain the updated service list is also different depending on the shutdown type of the first instance. Therefore, the preset time interval threshold needs to be set reasonably for different shutdown types of the first instance.
[0062] For example, the preset time interval threshold can be determined based on the maximum time interval required for Eureka Server, Eureka Client and Ribbon to obtain the updated service list and the maximum time interval required to transmit the first instance offline command. Transmitting the first instance offline command includes synchronizing the first instance offline command between at least two of Eureka Server, Eureka Client and Ribbon, and transmitting the first instance offline command to the first instance of the service.
[0063] For example, when the first instance offline command is used to indicate that the offline command for the first instance is of the first preset type, i.e., graceful offline, the maximum time interval required for Eureka Server, Eureka Client, and Ribbon to obtain the updated service list is, for example, 13 seconds; the maximum time interval required for at least two of Eureka Server, Eureka Client, and Ribbon to synchronize the first instance offline command is, for example, 0.5 seconds; and the maximum time interval required to transmit the first instance offline command to the first instance of the service is, for example, 1.5 seconds. Therefore, the preset first time interval threshold is determined to be, for example, 15 seconds. When the first instance offline command is used to indicate that the offline command for the first instance is of the second preset type, i.e., non-graceful offline, the maximum time interval required for Eureka Server, Eureka Client, and Ribbon to obtain the updated service list is, for example, 106 seconds. If the maximum time interval required for synchronizing the first instance offline command between at least two of the Client and Ribbon is, for example, 0.5 seconds, and the maximum time interval required for transmitting the first instance offline command to the first instance of the service is, for example, 1.5 seconds, then a preset second time interval threshold is determined to be, for example, 108 seconds. This ensures that the terminal device can still perceive the first instance of the service to be offline and can call the first instance to be offline normally. Only when the terminal device can no longer perceive the first instance of the service to be offline will the first instance of the service be taken offline. This improves the rationality of the service release process, reduces the possibility that the service release process is perceived by the terminal too late, and improves the user experience.
[0064] Step S104: If it is determined that a second instance needs to be brought online to the service, control the second instance to come online based on the preset instance online rules.
[0065] For example, during the process of deploying a second instance to a service, the Eureka Client can discover the second instance that is being deployed and register it with the Eureka Server. The Eureka Server can then update the service list based on this second instance. The Eureka Client and Ribbon can then obtain the updated service list, making the second instance of the service perceptible to end devices. However, the second instance being deployed might still be unavailable. If an end device requests to call the service, traffic might flow to the unavailable second instance, leading to systemic errors and service deployment failure. Therefore, if it is determined that a second instance needs to be deployed to a service, it is necessary to control the deployment of the second instance based on preset instance deployment rules to improve the rationality of the service deployment process, reduce the possibility of the service deployment process being perceived by the end device too early, and improve the user experience.
[0066] For example, based on preset instance online rules, controlling the online launch of a second instance includes: controlling the online launch of the second instance and detecting whether the second instance has been fully launched; if the second instance has been fully launched, sending a second instance online command to a preset service discovery framework; and updating the stored service list in the service discovery framework according to the second instance online command.
[0067] For example, such as Figure 4 As shown, the second instance is first deployed online, and its deployment status is checked. For example, the deployment status of the second instance is checked using a readiness probe. Once the deployment status of the second instance is confirmed, the service list stored in the service discovery framework is updated. The registration of the second instance of the service in the service discovery framework is modified to be executed when the second instance is in an available state. This ensures that the second instance of the service can only be perceived by the terminal device when it is in an available state, thereby improving the rationality of the service deployment process, reducing the possibility of the service deployment process being perceived by the terminal too early, and improving the user experience.
[0068] Step S105: If it is determined that the first instance of the service does not need to be taken offline, and the second instance of the service does not need to be brought online, the service publication is complete.
[0069] For example, published services can be stored in a blockchain. The blockchain referred to in this application is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.
[0070] Understandably, when a server needs to retrieve a published service, it can broadcast to the blockchain to determine the storage node or address of the published service, and then retrieve the published service from the storage node or address.
[0071] The service publishing method provided in the above embodiments obtains service publishing parameters; based on the publishing parameters, it determines whether a first instance of the service needs to be taken offline, and / or whether a second instance needs to be brought online to the service; if it is determined that the first instance of the service needs to be taken offline, it controls the first instance to be taken offline based on preset instance offline rules; if it is determined that a second instance needs to be brought online to the service, it controls the second instance to be brought online based on preset instance online rules; if it is determined that the first instance of the service does not need to be taken offline, and it is determined that a second instance does not need to be brought online to the service, it determines that the service publishing is complete, thereby improving the rationality of the service publishing process, reducing the possibility that the service publishing process is perceived by the terminal too early or too late, and improving the user experience.
[0072] Please see Figure 5 , Figure 5 This is a schematic block diagram of a service publishing device provided in an embodiment of this application. The service publishing device can be configured in a server or terminal device to execute the aforementioned service publishing method.
[0073] like Figure 5 As shown, the service publishing device includes: an acquisition module 110, a judgment module 120, an offline module 130, an online module 140, and a publishing module 150.
[0074] Module 110 is used to obtain the service publication parameters.
[0075] The judgment module 120 is used to determine, based on the publication parameters, whether the first instance of the service needs to be taken offline, and / or whether the second instance needs to be brought online to the service.
[0076] The offline module 130 is used to control the first instance to go offline based on a preset instance offline rule if it is determined that the first instance of the service needs to be taken offline.
[0077] The online module 140 is used to control the online launch of the second instance based on preset instance online rules if it is determined that the second instance needs to be launched to the service.
[0078] The publishing module 150 is used to determine that the service publishing is complete if it is determined that a first instance of the service does not need to be taken offline and a second instance of the service does not need to be brought online.
[0079] For example, the offline module 130 includes an offline instruction submodule, a first update submodule, a judgment submodule, and a control submodule.
[0080] The offline instruction submodule is used to send the first instance offline instruction to the preset service discovery framework.
[0081] The first update submodule is used to update the stored service list in the service discovery framework according to the offline instruction of the first instance.
[0082] The judgment submodule is used to determine whether the interval between the current time and the time when the first instance offline instruction is sent to the service discovery framework meets the preset time interval threshold.
[0083] The control submodule is used to control the first instance to go offline if the interval meets a preset time interval threshold.
[0084] For example, the judgment submodule includes a first judgment submodule and a second judgment submodule.
[0085] The first judgment submodule is used to determine whether the interval between the current time and the time of sending the first instance offline instruction to the service discovery framework meets a preset first time interval threshold when the first instance offline instruction is used to indicate that the offline type of the first instance is a first preset type.
[0086] The second judgment submodule is used to determine whether the interval between the current time and the time of sending the first instance offline instruction to the service discovery framework meets the preset second time interval threshold when the first instance offline instruction is used to indicate that the offline type of the first instance is a second preset type.
[0087] For example, the online module 140 includes a detection submodule, an online instruction submodule, and a second update submodule.
[0088] The detection submodule is used to control the second instance to go online and to detect whether the second instance has finished going online.
[0089] The online instruction submodule is used to send an online instruction for the second instance to the preset service discovery framework once the second instance has been brought online.
[0090] The second update submodule is used to update the stored service list in the service discovery framework according to the second instance online instruction.
[0091] For example, the determination module 120 includes a first determination submodule, a second determination submodule, and a third determination submodule.
[0092] The first determining submodule is used to determine that a second instance needs to be launched to the service when the number of the first instance is greater than a first quantity threshold, the number of the second instance is less than a second quantity threshold, the number of unavailable instances is less than or equal to an unavailable quantity threshold, and the number of instances exceeding the threshold is equal to a first exceeding quantity threshold.
[0093] The second determining submodule is used to determine the first instance that needs to be taken offline and the second instance that needs to be brought online to the service when the number of the first instance is greater than the first quantity threshold, the number of the second instance is less than the second quantity threshold, the number of unavailable instances is less than or equal to the unavailable quantity threshold, and the number of instances exceeding the threshold is greater than the first exceeding quantity threshold and less than or equal to the second exceeding quantity threshold.
[0094] The third determining submodule is used to determine the first instance that needs to be taken offline and the second instance that needs to be brought online to the service when the number of the first instance is greater than the first quantity threshold, the number of the second instance is equal to the second quantity threshold, the number of unavailable instances is less than or equal to the unavailable quantity threshold, and the number of instances exceeding the first exceeding quantity threshold and less than or equal to the second exceeding quantity threshold.
[0095] For example, the service publishing module also includes a quantity submodule.
[0096] The quantity submodule is used to determine the number of first instances that need to be taken offline and / or the number of second instances that need to be brought online, based on at least two of the release parameters, the first quantity threshold, the second quantity threshold, the unavailable quantity threshold, the first exceeded quantity threshold, and the second exceeded quantity threshold.
[0097] For example, the determination module 120 also includes a fourth determination submodule.
[0098] The fourth determining submodule is used to determine, when the number of the first instance is equal to a first quantity threshold, the number of the second instance is equal to a second quantity threshold, the number of unavailable instances is less than or equal to an unavailable quantity threshold, and the number of instances exceeding the threshold is equal to a first exceeding quantity threshold, determine that the first instance of the service does not need to be taken offline, and determine that the second instance does not need to be brought online to the service.
[0099] It should be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the above-described apparatus and its modules and units can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0100] The method of this application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics devices, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0101] For example, the above-described methods and apparatus can be implemented as a computer program that can run on a computer device.
[0102] Please see Figure 6 , Figure 6 This is a schematic block diagram illustrating the structure of a computer device according to an embodiment of this application. The computer device can be a server or a terminal device.
[0103] like Figure 6 As shown, the computer device includes a processor, a memory, and a network interface connected via a system bus, wherein the memory may include storage media and internal memory.
[0104] The storage medium may store the operating system and computer programs. These computer programs include program instructions that, when executed, cause the processor to perform any service delivery method.
[0105] The processor provides computing and control capabilities, supporting the operation of the entire computer device.
[0106] Internal memory provides an environment for the execution of computer programs stored in storage media. When these computer programs are executed by the processor, the processor can perform any service publishing method.
[0107] This network interface is used for network communication, such as sending assigned tasks. Those skilled in the art will understand that... Figure 6The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0108] It should be understood that a processor can be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other convertible logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among these, a general-purpose processor can be a microprocessor or any conventional processor.
[0109] In one embodiment, the processor is configured to run a computer program stored in memory to perform the following steps:
[0110] Retrieve the service publication parameters;
[0111] Based on the published parameters, determine whether the first instance of the service needs to be taken offline, and / or determine whether the second instance needs to be brought online to the service;
[0112] If it is determined that the first instance of the service needs to be taken offline, the first instance is taken offline based on the preset instance offline rules;
[0113] If it is determined that a second instance needs to be deployed to the service, the deployment of the second instance is controlled based on the preset instance deployment rules.
[0114] If it is determined that the first instance of the service does not need to be taken offline, and it is determined that the second instance of the service does not need to be brought online, then the service is considered published.
[0115] In one embodiment, when the processor implements the preset instance offline rule to control the first instance offline, it is used to:
[0116] Send the first instance offline command to the pre-defined service discovery framework;
[0117] In the service discovery framework, the stored service list is updated according to the first instance offline instruction;
[0118] Determine whether the interval between the current time and the time when the first instance offline instruction is sent to the service discovery framework meets a preset time interval threshold;
[0119] If the interval meets the preset time interval threshold, the first instance is taken offline.
[0120] In one embodiment, when the processor performs the step of determining whether the interval between the current time and the time of sending the first instance offline instruction to the service discovery framework meets a preset time interval threshold, it is configured to:
[0121] When the first instance offline instruction is used to indicate that the offline type of the first instance is a first preset type, it is determined whether the interval between the current time and the time when the first instance offline instruction is sent to the service discovery framework meets the preset first time interval threshold.
[0122] When the first instance offline instruction is used to indicate that the offline type of the first instance is a second preset type, it is determined whether the interval between the current time and the time when the first instance offline instruction is sent to the service discovery framework meets the preset second time interval threshold.
[0123] In one embodiment, when the processor controls the second instance to go online based on the preset instance online rule, it is used to:
[0124] Control the second instance to come online, and detect whether the second instance has finished coming online;
[0125] If the second instance is successfully launched, a second instance launch command is sent to the preset service discovery framework.
[0126] In the service discovery framework, the stored service list is updated according to the second instance's online instruction. In one embodiment, when the processor determines whether the first instance of the service needs to be taken offline based on the publication parameters, and / or determines whether the second instance needs to be brought online to the service, it is configured to:
[0127] When the number of the first instance is greater than the first quantity threshold, the number of the second instance is less than the second quantity threshold, the number of unavailable instances is less than or equal to the unavailable quantity threshold, and the number of instances exceeding the threshold is equal to the first exceeding quantity threshold, it is determined that the second instance needs to be brought online to the service.
[0128] When the number of the first instance is greater than the first quantity threshold, the number of the second instance is less than the second quantity threshold, the number of unavailable instances is less than or equal to the unavailable quantity threshold, and the number of instances exceeding the first exceeding quantity threshold is less than or equal to the second exceeding quantity threshold, it is determined that the first instance of the service needs to be taken offline, and the second instance needs to be brought online to the service.
[0129] When the number of the first instance is greater than the first quantity threshold, the number of the second instance is equal to the second quantity threshold, the number of unavailable instances is less than or equal to the unavailable quantity threshold, and the number of instances exceeding the threshold is greater than the first exceeding quantity threshold, it is determined that the first instance of the service needs to be taken offline.
[0130] In one embodiment, after determining that a first instance of the service needs to be taken offline, and / or determining that a second instance needs to be brought online to the service, the processor is configured to:
[0131] Based on at least two of the release parameters, the first quantity threshold, the second quantity threshold, the unavailable quantity threshold, the first exceeded quantity threshold, and the second exceeded quantity threshold, determine the number of first instances that need to be taken offline, and / or determine the number of second instances that need to be brought online.
[0132] In one embodiment, when the processor determines whether a first instance of the service needs to be taken offline based on the publication parameters, and / or determines whether a second instance needs to be brought online to the service, it is configured to:
[0133] When the number of the first instance is equal to the first quantity threshold, the number of the second instance is equal to the second quantity threshold, the number of unavailable instances is less than or equal to the unavailable quantity threshold, and the number of instances exceeding the threshold is equal to the first exceeding quantity threshold, it is determined that the first instance of the service does not need to be taken offline, and it is determined that the second instance does not need to be brought online to the service.
[0134] It should be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific process of service publishing described above can be referred to the corresponding process in the aforementioned service publishing method embodiments, and will not be repeated here.
[0135] This application also provides a computer-readable storage medium storing a computer program, which includes program instructions. When the program instructions are executed, the method implemented can be referred to in various embodiments of the service publishing method of this application.
[0136] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiments, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, SmartMedia Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the computer device.
[0137] It should be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0138] It should also be understood that the term "and / or" as used in this specification and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations. It should be noted that, herein, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0139] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. The above descriptions are merely specific implementations of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A service publishing method, characterized in that, The method includes: Retrieve the service publication parameters; Based on the published parameters, determine whether the first instance of the service needs to be taken offline, and / or determine whether the second instance needs to be brought online to the service; If it is determined that the first instance of the service needs to be taken offline, the first instance is taken offline based on the preset instance offline rules; If it is determined that a second instance needs to be deployed to the service, the deployment of the second instance is controlled based on the preset instance deployment rules. If it is determined that the first instance of the service does not need to be taken offline, and it is determined that the second instance of the service does not need to be brought online, the service is considered published. The control of taking the first instance offline based on preset instance offline rules includes: Send a first instance offline command to a preset service discovery framework; the service discovery framework includes EurekaServer and EurekaClient. In the service discovery framework, the stored service list is updated according to the first instance offline instruction; Determine whether the interval between the current time and the time of sending the first instance offline instruction to the service discovery framework meets a preset time interval threshold; the preset time interval is determined based on the maximum time interval required for the Eureka Server, Eureka Client, and user interface to obtain an updated service list and the maximum time interval required to transmit the first instance offline instruction, wherein transmitting the first instance offline instruction includes synchronizing the first instance offline instruction between at least two of the Eureka Server, Eureka Client, and user interface, and transmitting the first instance offline instruction to the first instance of the service; If the interval meets the preset time interval threshold, the first instance is taken offline; The control of the second instance's online status based on preset instance online rules includes: Control the second instance to come online, and detect whether the second instance has finished coming online; If the second instance is successfully launched, a second instance launch command is sent to the preset service discovery framework. In the service discovery framework, the stored service list is updated according to the second instance online instruction.
2. The service publishing method according to claim 1, characterized in that, The step of determining whether the interval between the current time and the time of sending the first instance offline instruction to the service discovery framework meets a preset time interval threshold includes: When the first instance offline instruction is used to indicate that the offline type of the first instance is a first preset type, it is determined whether the interval between the current time and the time when the first instance offline instruction is sent to the service discovery framework meets the preset first time interval threshold. When the first instance offline instruction is used to indicate that the offline type of the first instance is a second preset type, it is determined whether the interval between the current time and the time when the first instance offline instruction is sent to the service discovery framework meets the preset second time interval threshold.
3. The service publishing method according to claim 1, characterized in that, The publishing parameters include the number of first instances, the number of second instances, the number of unavailable instances, and the number of instances exceeding the limit. The step of determining whether a first instance of the service needs to be taken offline, and / or determining whether a second instance needs to be added to the service, based on the publication parameters, includes: When the number of the first instance is greater than the first quantity threshold, the number of the second instance is less than the second quantity threshold, the number of unavailable instances is less than or equal to the unavailable quantity threshold, and the number of instances exceeding the threshold is equal to the first exceeding quantity threshold, it is determined that the second instance needs to be brought online to the service. When the number of the first instance is greater than the first quantity threshold, the number of the second instance is less than the second quantity threshold, the number of unavailable instances is less than or equal to the unavailable quantity threshold, and the number of instances exceeding the first exceeding quantity threshold is less than or equal to the second exceeding quantity threshold, it is determined that the first instance of the service needs to be taken offline, and the second instance needs to be brought online to the service. When the number of the first instance is greater than the first quantity threshold, the number of the second instance is equal to the second quantity threshold, the number of unavailable instances is less than or equal to the unavailable quantity threshold, and the number of instances exceeding the threshold is greater than the first exceeding quantity threshold and less than or equal to the second exceeding quantity threshold, it is determined that the first instance of the service needs to be taken offline.
4. The service publishing method according to claim 3, characterized in that, After determining that a first instance of the service needs to be taken offline, and / or determining that a second instance needs to be brought online to the service, the process includes: Based on at least two of the release parameters, the first quantity threshold, the second quantity threshold, the unavailable quantity threshold, the first exceeded quantity threshold, and the second exceeded quantity threshold, determine the number of first instances that need to be taken offline, and / or determine the number of second instances that need to be brought online.
5. The service publishing method according to claim 1, characterized in that, The step of determining whether a first instance of the service needs to be taken offline, and / or determining whether a second instance needs to be added to the service, based on the publication parameters, includes: When the number of the first instance is equal to the first quantity threshold, the number of the second instance is equal to the second quantity threshold, the number of unavailable instances is less than or equal to the unavailable quantity threshold, and exceeds the number of instances equal to the first quantity threshold, it is determined that the first instance of the service does not need to be taken offline, and it is determined that the second instance does not need to be brought online to the service.
6. A service publishing device, characterized in that, The service publishing device includes: The acquisition module is used to obtain the service publication parameters; The judgment module is used to determine, based on the publication parameters, whether the first instance of the service needs to be taken offline, and / or whether the second instance needs to be brought online to the service; The offline module is used to control the first instance to go offline if it is determined that the first instance of the service needs to be taken offline, based on a preset instance offline rule. The online module is used to control the online deployment of the second instance based on preset instance online rules if it is determined that a second instance needs to be deployed to the service. The publishing module is used to determine that the service publishing is complete if it is determined that a first instance of the service does not need to be taken offline, and a second instance of the service does not need to be brought online. The control of taking the first instance offline based on preset instance offline rules includes: Send a first instance offline command to a preset service discovery framework; the service discovery framework includes EurekaServer and EurekaClient. In the service discovery framework, the stored service list is updated according to the first instance offline instruction; Determine whether the interval between the current time and the time of sending the first instance offline instruction to the service discovery framework meets a preset time interval threshold; the preset time interval is determined based on the maximum time interval required for the Eureka Server, Eureka Client, and user interface to obtain an updated service list and the maximum time interval required to transmit the first instance offline instruction, wherein transmitting the first instance offline instruction includes synchronizing the first instance offline instruction between at least two of the Eureka Server, Eureka Client, and user interface, and transmitting the first instance offline instruction to the first instance of the service; If the interval meets the preset time interval threshold, the first instance is taken offline; The control of the second instance's online status based on preset instance online rules includes: Control the second instance to come online, and detect whether the second instance has finished coming online; If the second instance is successfully launched, a second instance launch command is sent to the preset service discovery framework. In the service discovery framework, the stored service list is updated according to the second instance online instruction.
7. A computer device, characterized in that, The computer device includes a memory and a processor; The memory is used to store computer programs; The processor is configured to execute the computer program and, in executing the computer program, implement the service publishing method as described in any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the service publishing method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Service instance updating method and device and storage medium
CN109725920A