Micro-service processing method and device based on multiple clusters, equipment, storage medium and product
By responding to service failure instructions in a multi-cluster environment and selecting target disaster recovery clusters and services, the problem of uneven load and fault processing delay is solved, high availability and load balancing of microservices are achieved, and user experience is improved.
Patent Information
- Application Number
- CN202410769960.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-09-24
AI Technical Summary
In a multi-cluster environment, it is difficult for existing technologies to achieve load balancing and handle microservice failures in a timely manner, resulting in some clusters being overloaded or service interruptions taking too long, affecting user experience.
By responding to service failure instructions, the set of candidate disaster recovery clusters is determined, and the target disaster recovery cluster is selected based on the fault service type and cluster identification/physical location of the computer room, and the target disaster recovery service is used to process microservice requests to ensure load balancing and high availability.
It achieves timely load balancing and high availability in the event of microservice failure, avoids service interruption, improves user experience, and meets the needs of cloud computing environments.
Smart Images

Figure CN118689647A
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the technical field of server cluster application, and in particular to a multi-cluster based microservice processing method, device, equipment, storage medium and product. Background Art
[0002] With the development of cloud computing technology, microservice architecture has been widely adopted. In a multi-cluster environment, the deployment and management of microservices are of great significance to improving the availability and stability of applications. However, existing technical solutions often have some problems when dealing with the high availability of microservices in a multi-cluster environment, such as uneven load and untimely failover.
[0003] Traditional load balancing algorithms often fail to achieve even load distribution among multiple clusters, causing some clusters to be overloaded while other clusters are idle. At the same time, when a service instance fails, existing solutions often need to wait for the failed instance to recover before re-adding it to the service list, which may cause the service to be interrupted for a long time and affect the user experience. Therefore, how to process microservice requests in a timely manner when a service failure occurs has become an urgent problem to be solved. Summary of the invention
[0004] Embodiments of the present invention provide a multi-cluster based microservice processing method, apparatus, device, storage medium and product to solve the problem that microservice requests cannot be processed in time when there are faulty service instances.
[0005] In a first aspect, an embodiment of the present invention provides a microservice processing method based on multiple clusters, wherein the method includes:
[0006] In response to the received service failure instruction, determining a candidate disaster recovery cluster set according to the type of the failed service;
[0007] If the candidate disaster recovery cluster set includes the current cluster of the faulty service, the current cluster of the faulty service is directly used as the corresponding target disaster recovery cluster;
[0008] If the candidate disaster recovery cluster set does not include the current cluster where the faulty service is located, determine the corresponding target disaster recovery cluster based on the cluster identifier / computer room physical location of each candidate disaster recovery cluster in the candidate disaster recovery cluster set;
[0009] Determine the corresponding target disaster recovery service based on the heartbeat-related parameters of all microservices matching the faulty service type in the target disaster recovery cluster;
[0010] On the microservice call link corresponding to the faulty service, the target disaster recovery service is used to process the microservice request of the faulty service.
[0011] In a second aspect, an embodiment of the present invention further provides a multi-cluster based microservice processing device, wherein the device includes:
[0012] A set determination module, configured to determine a candidate disaster recovery cluster set according to a fault service type in response to a received service fault instruction;
[0013] A first cluster determination module is used to directly use the current cluster of the failed service as the corresponding target disaster recovery cluster if the candidate disaster recovery cluster set includes the current cluster of the failed service;
[0014] A second cluster determination module is used to determine a corresponding target disaster recovery cluster based on the cluster identifier / computer room physical location of each candidate disaster recovery cluster in the candidate disaster recovery cluster set if the candidate disaster recovery cluster set does not include the current cluster where the faulty service is located;
[0015] A service determination module, used to determine a corresponding target disaster recovery service based on heartbeat-related parameters of all microservices matching the fault service type in the target disaster recovery cluster;
[0016] The service processing module is used to process the microservice request of the faulty service by using the target disaster recovery service on the microservice call link corresponding to the faulty service.
[0017] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a multi-cluster based microservice processing method as described in any one of the embodiments of the present invention is implemented.
[0018] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a multi-cluster-based microservice processing method as described in any one of the embodiments of the present invention.
[0019] In a fifth aspect, an embodiment of the present invention further provides a computer program product, including a computer program, which, when executed by a processor, implements a multi-cluster-based microservice processing method as described in any one of the embodiments of the present invention.
[0020] In an embodiment of the present invention, by responding to a received service fault instruction, a set of candidate disaster recovery clusters is determined according to the type of the fault service, and then a multi-level degradation strategy is adopted to select a target disaster recovery cluster, and the current cluster of the fault service is preferentially used as the target disaster recovery cluster. When there is no disaster recovery service of the same type as the fault service in the current cluster, a more suitable disaster recovery cluster is determined based on the cluster identifier or the physical location of the computer room, and the optimal target disaster recovery cluster is determined, while affinity is guaranteed; the corresponding target disaster recovery service is determined based on the heartbeat-related parameters of all microservices matching the fault service type in the target disaster recovery cluster, so as to ensure the highest availability of the service; and on the call link corresponding to the service, the target disaster recovery service is used to process the microservice request of the fault service, and the fault service is replaced by the target disaster recovery service, that is, multiple microservices are used to process one data, so as to ensure high availability, realize timely load balancing of microservices, avoid service interruption affecting user experience, and better meet the needs of cloud computing environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0022] Figure 1 A flowchart of a multi-cluster based microservice processing method provided by an embodiment of the present invention;
[0023] Figure 2 A flowchart of another multi-cluster based microservice processing method provided by an embodiment of the present invention;
[0024] Figure 3 An example diagram of a multi-cluster based microservice load balancing provided in an embodiment of the present invention;
[0025] Figure 4 A schematic diagram of the structure of a multi-cluster based microservice processing device provided by an embodiment of the present invention;
[0026] Figure 5 It is a structural block diagram of an electronic device of a multi-cluster based microservice processing method provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0029] The acquisition, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.
[0030] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0031] In one embodiment, Figure 1 The present invention provides a flowchart of a multi-cluster based microservice processing method. This embodiment is applicable to service processing situations. The method can be executed by a multi-cluster based microservice processing device. The multi-cluster based microservice processing device can be implemented in the form of hardware and / or software. The multi-cluster based microservice processing device can be configured in an electronic device. Figure 1 As shown, the method includes:
[0032] S110 . In response to the received service failure instruction, determine a set of candidate disaster recovery clusters according to the type of the failed service.
[0033] Among them, the service fault instruction refers to the indication information indicating that the service has a fault during the service operation of the cluster. Generally speaking, before the service is run, a microservice call link can be created in advance. When calling any microservice fails, a service fault instruction can be generated. When a service fault instruction is received, it can be considered that there is an abnormal microservice in the current microservice call link, and load balancing is required to find a microservice instance matching the disaster recovery service for replacement to ensure the stable operation of the service. The fault service type refers to the type of microservice that has a fault. Exemplarily, the fault service type can include at least user management service, message notification service, configuration management service, and search service. The candidate disaster recovery cluster set can be understood as a set of candidate disaster recovery clusters. When it is determined that there is a microservice of the fault service type in the cluster, the disaster recovery cluster can be determined as a candidate disaster recovery cluster. In one embodiment, the number of clusters in the candidate disaster recovery cluster set can be at least one.
[0034] In an embodiment, when a service fault instruction is received, the fault service type can be determined. A microservice matching the fault service type is searched in each cluster. When it is determined that a microservice matching the fault service type exists in the cluster, the cluster is determined to be a candidate disaster recovery cluster, and the candidate disaster recovery clusters constitute a candidate disaster recovery cluster set; or, a microservice instance with the same fault service type can be searched in each cluster. When it is determined that a microservice instance with the same fault service type exists in the cluster, the cluster is determined to be a candidate disaster recovery cluster, and the candidate disaster recovery clusters constitute a candidate disaster recovery cluster set. In the actual operation process, since the microservice instances are pre-registered in the microservice registration center, the microservice instances contained in each cluster can be determined through the microservice registration center, and then the corresponding microservice instances are matched by the fault service type, and the clusters with at least one microservice instance constitute a candidate disaster recovery cluster set.
[0035] S120: If the candidate disaster recovery cluster set includes the current cluster of the failed service, directly use the current cluster of the failed service as the corresponding target disaster recovery cluster.
[0036] In an embodiment, when it is determined that the candidate disaster recovery cluster set includes the current cluster of the faulty service, the current cluster of the faulty service can be directly used as the corresponding target disaster recovery cluster, that is, the priority of the current cluster including the faulty service is higher than other clusters in the candidate disaster recovery cluster set.
[0037] S130: If the candidate disaster recovery cluster set does not include the current cluster where the faulty service is located, determine the corresponding target disaster recovery cluster based on the cluster identifier / computer room physical location of each candidate disaster recovery cluster in the candidate disaster recovery cluster set.
[0038] The cluster identifier can be understood as the identification information for identifying the cluster, which is the authentication data used to uniquely identify a microservice cluster. In one embodiment, the cluster identifier can be represented by a string or a number. The physical location of the computer room can be understood as the actual location of the computer room. In one embodiment, the physical location of the computer room can include the longitude and latitude coordinates, or the city location, etc.
[0039] In an embodiment, the target disaster recovery cluster can be determined according to the cluster identifier of each candidate disaster recovery cluster in the candidate disaster recovery cluster set or the physical location of the computer room. Specifically, when the target disaster recovery cluster is determined by the cluster identifier, the cluster identifier of the current cluster of the faulty service and each candidate disaster recovery cluster in the candidate disaster recovery cluster set can be determined, and the candidate disaster recovery cluster corresponding to the minimum value of the cluster identifier is determined as the target disaster recovery cluster; or, the candidate disaster recovery cluster with the cluster identifier adjacent to the cluster identifier of the current cluster of the faulty service is determined as the corresponding target disaster recovery cluster. Exemplarily, if there are 4 candidate disaster recovery clusters in the candidate disaster recovery cluster set, the cluster identifier of the current cluster is 3, and the cluster identifiers of the candidate disaster recovery clusters are 1, 2, 4, and 5 respectively, the candidate disaster recovery cluster with a cluster identifier of 1 can be determined as the corresponding target disaster recovery cluster; or, the candidate disaster recovery cluster with a cluster identifier of 2 or a cluster identifier of 4 can be used as the corresponding target disaster recovery cluster. If there are 4 candidate disaster recovery clusters in the candidate disaster recovery cluster set, the cluster ID of the current cluster is 3, and the cluster IDs of the candidate disaster recovery clusters are 1, 2, 5, and 6 respectively, the candidate disaster recovery cluster with cluster ID 1 can be determined as the corresponding target disaster recovery cluster; or the candidate disaster recovery cluster with cluster ID 2 or cluster ID 4 can be determined as the corresponding target disaster recovery cluster. In this case, there are two candidate disaster recovery clusters with adjacent cluster IDs. The target disaster recovery cluster can be determined based on the physical location of the computer room and the number of available microservices in the candidate disaster recovery cluster. The candidate disaster recovery cluster with a closer physical location to the computer room is used as the target disaster recovery cluster, or the candidate disaster recovery cluster with the largest number of available microservices is used as the target disaster recovery cluster.
[0040] Alternatively, you can directly determine the physical location of the computer room corresponding to each candidate disaster recovery cluster, determine the distance between each candidate disaster recovery cluster and the current cluster where the faulty service is located, and use the candidate disaster recovery cluster group with a closer distance as the target disaster recovery cluster. If there are two candidate disaster recovery clusters with the same distance, you can determine the target disaster recovery cluster based on the number of available microservices in the candidate disaster recovery cluster, and use the candidate disaster recovery cluster with the largest number of available microservices as the target disaster recovery cluster.
[0041] S140: Determine a corresponding target disaster recovery service based on the heartbeat-related parameters of all microservices matching the faulty service type in the target disaster recovery cluster.
[0042] The target disaster recovery service refers to a service used in the target disaster recovery cluster to replace the faulty service. The target disaster recovery service may be the disaster recovery service with the highest matching degree with the faulty service. The heartbeat-related parameters may be used to indicate the activity level of the candidate disaster recovery service.
[0043] In one embodiment, the heartbeat-related parameters include at least one of the following indicators: the maximum number of active threads; and the current available CPU resource usage rate.
[0044] The maximum number of active threads can be considered as the upper limit of the number of threads that can be in an active state (executing tasks or waiting for tasks) at the same time for the microservice instance corresponding to the microservice, that is, the upper limit of the number of threads that can run simultaneously for the microservice instance. The maximum number of active threads can be pre-configured when registering each microservice instance. The current available CPU resource usage is used to indicate the current time. The central processing unit (CPU) resources are available.
[0045] In an embodiment, the heartbeat-related parameters of all microservices matching the fault service type in the target disaster recovery cluster can be determined, the priority of each microservice can be determined according to the heartbeat-related parameters, and the microservice with the highest priority can be used as the target disaster recovery service. In the actual operation process, when the heartbeat-related parameter is the maximum number of active threads, the microservice with the largest number of maximum active threads can be determined as the target disaster recovery service; when the heartbeat-related parameter is the current available CPU resource utilization rate, the microservice with the highest current available CPU resource utilization rate can be determined as the target disaster recovery service; if the heartbeat-related parameters include multiple parameters such as the maximum number of active threads and the current available CPU resource utilization rate, the corresponding weight value of each heartbeat-related parameter can be determined, and the actual activity value of each microservice is obtained by weighted summing each heartbeat-related parameter and the corresponding weight value, and the microservice with the best actual activity value is used as the target disaster recovery service.
[0046] S150: On the microservice call link corresponding to the faulty service, the target disaster recovery service is used to process the microservice request of the faulty service.
[0047] Among them, the microservice call link refers to the path formed by the mutual calls between various microservices during the operation of the service. For example, when the service is to purchase goods, it may include user verification service, order service and payment service. Correspondingly, the microservice call link can verify user information for user verification service, user verification service calls the order created by order service, and order service calls payment service to complete the purchase of goods, forming a microservice call link of user verification service, order service and payment service.
[0048] In an embodiment, on the microservice call link corresponding to the faulty service, the microservice instance in the faulty service can be determined, the microservice instance in the target disaster recovery service can be determined, the microservice instance of the target disaster recovery service can be replaced with the microservice instance of the faulty service, and the microservice request of the faulty service can be processed. In one embodiment, all microservice instances in the faulty service can be replaced; or, the faulty microservice instance can be determined, and only the faulty microservice instance can be replaced.
[0049] The embodiment of the present invention responds to the received service fault instruction, determines a set of candidate disaster recovery clusters according to the fault service type, and then adopts a multi-level degradation strategy to select a target disaster recovery cluster, preferentially uses the current cluster of the fault service as the target disaster recovery cluster, and when there is no disaster recovery service of the same type as the fault service in the current cluster, determines a more suitable disaster recovery cluster based on the cluster identifier or the physical location of the computer room, thereby ensuring affinity; determines the corresponding target disaster recovery service based on the heartbeat-related parameters of all microservices matching the fault service type in the target disaster recovery cluster, thereby ensuring the highest availability of the service; and replaces the fault service with the target disaster recovery service on the call link corresponding to the service, that is, multiple microservices are used to process one data, thereby ensuring high availability, realizing timely load balancing of microservices, avoiding service interruptions from affecting user experience, and being able to better meet the needs of cloud computing environments.
[0050] In one embodiment, a multi-cluster based microservice processing method further includes:
[0051] Configure the microservice registration center of the corresponding cluster according to the microservice framework used in each microservice cluster;
[0052] Register the instance information of each microservice instance in each microservice cluster to the corresponding microservice registration center;
[0053] The access addresses of the microservice registration centers of other microservice clusters are configured in the microservice registration center of each microservice cluster, so that the microservice registration center shares the instance information with the microservice registration centers of other microservice clusters.
[0054] Among them, a microservice cluster refers to a cluster composed of multiple microservice instances. The microservice framework can be considered as a set of tools, components, and technologies for building, deploying, and managing a microservice architecture. The microservice registry can be used to register instance information for each microservice instance. The number and type of microservice registry centers in each cluster can be different and can be configured by the adopted microservice framework. Exemplary types of microservice registry centers can include Eureka, Nacos, Consul, ETCD, Zookeeper, etc. In general, the number of centralized microservice registry centers can be determined by the number of microservices required by the cluster; or, for different microservice frameworks, the number of microservice registry centers may be limited.
[0055] Instance information can be considered as specific information of a microservice instance. Exemplarily, the instance information can include at least the microservice instance name, microservice instance identification information, resource usage of the microservice instance, and deployment information of the microservice instance.
[0056] In an embodiment, the microservice framework used in each microservice cluster can be determined, and the microservice registration center of the corresponding cluster can be configured through the microservice frame. The number of microservice registration centers of each microservice cluster can be at least one. After the microservice registration center is configured, the instance information of each microservice instance can be determined, and the instance information of each microservice instance can be registered to the corresponding microservice registration center. At the same time, in the microservice registration center of each microservice cluster, the access address of the microservice registration center of other microservice clusters can be configured so that the microservice registration center shares the instance information with the microservice registration center of other microservice clusters. In other words, the microservice registration center can obtain the instance information of the microservice registration center of other microservice clusters through the access address of the microservice registration center of other microservice clusters, so that the microservice registration center can share instance information across clusters.
[0057] In one embodiment, a multi-cluster based microservice processing method further includes:
[0058] In response to the received microservice request, determine a corresponding microservice call link and multiple microservice instances based on the request type of the microservice request;
[0059] A connection is established between multiple microservice instances based on the microservice call link, so that each microservice instance processes the microservice request.
[0060] Among them, the microservice request can be considered as the request information for calling the microservice; the request type can refer to the type of microservice that needs to be requested. Generally speaking, the request type can include but is not limited to data query requests, data update requests, notification requests, user requests, and data synchronization requests. For each microservice request, at least one corresponding microservice can be called to determine the microservice call link corresponding to the request type and the microservice instance corresponding to the execution microservice request.
[0061] A microservice instance can be understood as a specific running instance of a microservice. For each microservice, there can be at least one microservice instance, and each microservice instance can run independently. In actual operation, microservice instances can run in different servers or containers.
[0062] In an embodiment, after receiving a microservice request, the request type of the microservice request can be determined, the corresponding microservice is called according to the request type, and the corresponding microservice call link is generated according to the microservice request to determine the microservice instance in the microservice. A connection between microservice instances is established according to the microservice call link so that each microservice instance processes the microservice request. The establishment of the microservice call link is realized, and it is determined that the processing of the microservice request can be executed according to the microservice call link.
[0063] In one embodiment, the fault tolerance mechanism of the microservice is integrated into an independent process or container.
[0064] Among them, the fault tolerance mechanism can be understood as a mechanism that attempts to connect to other available microservices when a service instance of a microservice fails. In actual operation, the fault tolerance mechanism of a microservice can be integrated into an independent process or container, such as a sidecar. The service does not need to pay attention to the traffic corresponding to the fault tolerance mechanism, and it is not invasive to the service, which can ensure the decoupling between development and fault tolerance; at the same time, it has high portability and can be ported to any service.
[0065] In one embodiment, Figure 2 This is a flowchart of another multi-cluster based microservice processing method provided by an embodiment of the present invention. This embodiment further illustrates the process of determining the candidate disaster recovery cluster set, the target disaster recovery cluster and the target disaster recovery service based on the above embodiment. Figure 2 As shown, the method includes:
[0066] S201. In response to a received service fault instruction, search in each cluster for an available microservice that matches the faulty service type.
[0067] Among them, the available microservices can be microservices that immediately match the faulty service type, and are microservices that are in a normal operating state and can provide services externally.
[0068] In an embodiment, after receiving a service fault instruction, the corresponding available microservice can be searched in each search according to the fault service type. In the actual operation process, the microservice instance that has been registered in the microservice registration center of each cluster can be identified as a matching microservice instance with the same type as the fault service, and the microservice corresponding to the matching microservice instance can be used as an available microservice.
[0069] S202: All clusters with at least one available microservice constitute a candidate disaster recovery cluster set.
[0070] In an embodiment, all clusters with available microservices may constitute a candidate disaster recovery cluster set.
[0071] S203: If the candidate disaster recovery cluster set includes the current cluster where the faulty service is located, directly use the current cluster where the faulty service is located as the corresponding target disaster recovery cluster.
[0072] S204: If the candidate disaster recovery cluster set does not include the current cluster where the faulty service is located, obtain a cluster identifier of each candidate disaster recovery cluster in the candidate disaster recovery cluster set.
[0073] In an embodiment, when the set of candidate disaster recovery clusters does not include the cluster where the faulty service is currently located, the cluster identifier of each candidate disaster recovery cluster can be identified in the microservice registration center or the configuration file of the candidate disaster recovery cluster.
[0074] S205: Take the candidate disaster recovery cluster with the smallest cluster ID or the cluster ID adjacent to the cluster where the faulty service currently resides as the corresponding target disaster recovery cluster.
[0075] In an embodiment, the cluster identifier may contain numbers, and the digital information in each cluster identifier may be determined, and the candidate disaster recovery cluster with the smallest cluster identifier may be determined as the corresponding target disaster recovery cluster; or, the cluster identifier of the current cluster may be extracted, and the candidate disaster recovery cluster adjacent to the cluster identifier of the current cluster may be determined as the corresponding target disaster recovery cluster. Exemplarily, if there are 4 candidate disaster recovery clusters in the candidate disaster recovery cluster set, the cluster identifier of the current cluster is 3, and the cluster identifiers of the candidate disaster recovery clusters are 1, 2, 5, and 6, respectively, the candidate disaster recovery cluster with the cluster identifier of 1 may be determined as the corresponding target disaster recovery cluster; or, the candidate disaster recovery cluster with the cluster identifier of 2 may be determined as the corresponding target disaster recovery cluster. In one embodiment, when there are two candidate disaster recovery clusters determined, the physical location of the computer room corresponding to the candidate disaster recovery cluster may be determined, and the candidate disaster recovery cluster with the smallest relative physical distance may be used as the corresponding target disaster recovery cluster; or, the number of available microservices in the candidate disaster recovery cluster may be determined, and the candidate disaster recovery cluster with a larger number of available microservices may be used as the corresponding target disaster recovery cluster.
[0076] S206. If the candidate disaster recovery cluster set does not include the current cluster where the faulty service is located, obtain the computer room physical location corresponding to each candidate disaster recovery cluster in the candidate disaster recovery cluster set and the computer room physical location corresponding to the current cluster where the faulty service is located as the first physical location and the second physical location.
[0077] Among them, the first physical location refers to the physical location of the computer room corresponding to each candidate disaster recovery cluster in the candidate disaster recovery cluster set; the second physical location refers to the physical location of the computer room corresponding to the cluster where the faulty service is currently located. In an embodiment, if the candidate disaster recovery cluster set does not include the cluster where the faulty service is currently located, the physical location of the computer room corresponding to each candidate disaster recovery cluster in the candidate disaster recovery cluster set and the physical location of the computer room corresponding to the cluster where the faulty service is currently located can be decomposed and determined. In the actual operation process, the Internet Protocol Address (IP) address of the server in the cluster can be analyzed, and the physical location of the computer room of the corresponding cluster can be determined by the IP address. Alternatively, the network topology information corresponding to the cluster can be obtained to find the physical location of the computer room of each cluster.
[0078] S207: Determine a relative physical distance between the first physical location and the second physical location.
[0079] In an embodiment, a straight-line distance between the first physical location and the second physical location may be determined as the relative physical distance.
[0080] S208: Use the candidate disaster recovery cluster with the shortest relative physical distance in the candidate disaster recovery cluster set as the corresponding target disaster recovery cluster.
[0081] In an embodiment, a candidate disaster recovery cluster with the smallest relative physical distance in the candidate disaster recovery cluster set may be determined and used as the corresponding target disaster recovery cluster. It is understandable that the smaller the relative physical distance, the faster the load speed, which improves the affinity of cluster load.
[0082] In one embodiment, the target disaster recovery cluster is determined in S203, S204-S205, and S206-S208 in a parallel manner without interfering with each other.
[0083] S209: Acquire all available microservices in the target disaster recovery cluster that match the service type of the failed service to form a candidate disaster recovery service set.
[0084] In an embodiment, each service type in the target disaster recovery cluster can be determined, and available microservices with the same service type as the faulty service can be determined, and all available microservices constitute a candidate disaster recovery service set. In the actual operation process, the service type of each microservice in the target disaster recovery cluster can be determined in the microservice registration center. Exemplarily, when it is determined that the service type of the faulty service is service A, the microservices with the service type of service A in the target disaster recovery cluster can be determined as available microservices to constitute a candidate disaster recovery service set.
[0085] S210 , sorting the candidate disaster recovery services by priority based on the heartbeat-related parameters of each candidate disaster recovery service in the candidate disaster recovery service set to obtain a sorted candidate disaster recovery service set.
[0086] In an embodiment, the heartbeat-related parameters of each candidate disaster recovery service in the candidate disaster recovery service set can be determined, and the candidate disaster recovery services can be prioritized in the order of the heartbeat-related parameters from best to worst, or from worst to best, to obtain a sorted candidate disaster recovery service set. Exemplarily, when the heartbeat-related parameter is the maximum number of active threads, the candidate disaster recovery services can be arranged in the order of the maximum number of active threads from high to low or from low to high to obtain a sorted candidate disaster recovery service set; when the heartbeat-related parameter is the current available CPU resource usage rate, the candidate disaster recovery services can be arranged in the order of the current available CPU resource usage rate from large to small or from small to large to obtain a sorted candidate disaster recovery service set.
[0087] In one embodiment, when the heartbeat-related parameters include at least two indicators, the candidate disaster recovery services are prioritized based on the heartbeat-related parameters of each candidate disaster recovery service in the candidate disaster recovery service set to obtain a prioritized candidate disaster recovery service set, including:
[0088] Obtain the actual detection value of each indicator in the heartbeat-related parameters of each candidate disaster recovery service in the candidate disaster recovery service set;
[0089] Determine the actual activity value of the corresponding candidate disaster recovery service based on the actual detection value of each indicator and the pre-configured weight value;
[0090] Prioritize each candidate disaster recovery service in the candidate disaster recovery service set according to the actual activity level value to obtain a sorted candidate disaster recovery service set.
[0091] In an embodiment, if the heartbeat-related parameters include at least two indicators, the actual detection value of each indicator in the heartbeat-related parameters of each candidate disaster recovery service in the candidate disaster recovery service set can be determined first, and the pre-configured weight value of each indicator can be determined. The sum of the products of each actual detection value and the corresponding weight value is used as the actual activity value of the candidate disaster recovery service, and each candidate disaster recovery service in the candidate disaster recovery service set is prioritized by the actual activity value to obtain a sorted candidate disaster recovery service set. Exemplarily, the order of the actual activity value can be sorted from high to low, or the order of the actual activity value can be sorted from low to high to obtain a sorted candidate disaster recovery service set.
[0092] S211 . Select the candidate disaster recovery service with the highest priority from the sorted candidate disaster recovery service set as the corresponding target disaster recovery service.
[0093] In an embodiment, the candidate disaster recovery service with the highest priority in the sorted candidate disaster recovery service set can be determined, and the candidate disaster recovery service can be used as the corresponding target disaster recovery service. Exemplarily, the candidate disaster recovery service with the largest actual activity value can be used as the corresponding target disaster recovery service; or the candidate disaster recovery service with the best heartbeat-related parameters can be used as the corresponding target disaster recovery service.
[0094] S212. Search for a microservice instance of the faulty service on the microservice call link corresponding to the faulty service.
[0095] In an embodiment, the microservice call link corresponding to the faulty service may be extracted to determine the microservice instance of the faulty service. In an actual operation, the microservice call link may be generated in advance after receiving a microservice request, and the pre-generated microservice call link may be extracted to determine the microservice instance of the faulty service. In an embodiment, the number of microservice instances may be at least one.
[0096] S213: Replace the microservice instance of the faulty service with the microservice instance of the target disaster recovery service to process the microservice request.
[0097] In an embodiment, the microservice instance of the target disaster recovery service may replace the microservice instance of the faulty service to process the microservice request.
[0098] The embodiment of the present invention determines whether the candidate disaster recovery cluster set includes the current cluster of the faulty service, adopts a degradation strategy, preferentially uses the current cluster of the faulty service as the target disaster recovery cluster, does not include the current cluster of the faulty service in the selected disaster recovery cluster, uses the cluster identifier and the physical location of the computer room to determine the target disaster recovery cluster, and ensures that the cluster has the highest availability; determines the target disaster recovery service through the heartbeat-related parameters of each candidate disaster recovery service, replaces the microservice instance of the faulty service with the microservice instance of the target disaster recovery service to process the microservice request, realizes the balanced distribution of the load between the microservices, avoids the problem of microservice overload while other microservices are idle, and ensures the timely processing of microservice requests.
[0099] In one embodiment, Figure 3 This is an example diagram of a multi-cluster based microservice load balancing provided by an embodiment of the present invention. This embodiment takes the registration center as the microservice registration center, and service A and service B as microservices in the microservice call link as examples to further illustrate a multi-cluster based microservice processing method. Figure 3 The figure shows two clusters: AZ1 and AZ2. The cluster can be a physical machine, a virtual machine, or a K8S cluster. Each cluster includes a registration center module, a gateway module, and a service module. Each cluster includes multiple registration centers. Figure 3 The dashed arrow in the middle represents service registration discovery, the implementation arrow represents the request traffic, and the black dots represent the registration centers in the entire cluster (that is, multiple registration centers).
[0100] Among them, for the registration center module, each cluster has a set of microservice registration centers, and the industry's mainstream Eureka, Nacos, Consul, ETCD, Zookeeper, etc. can be selected according to the selected microservice framework. And the registration center forms a high-availability mode in the cluster to achieve mutual registration and discovery.
[0101] For the gateway module, it can be a microservice gateway, which is the traffic entrance of each cluster and will forward the traffic to the corresponding service; there are many types of gateways, such as Spring Cloud Gateway, OpenResty, Zuul, Kong, etc., and there is no limitation on this.
[0102] For the service module, it contains multiple microservices, and each cluster can contain multiple identical microservices. For example, Figure 3 As shown, each cluster contains two services A and multiple services B as an example.
[0103] The registration centers of two clusters can be registered and discovered across clusters, so that each registration center can have the full service information of two clusters, and realize cross-cluster sharing of registration centers. At the same time, the service instance registry extension field of the registration center can be used (such as the metadata field in Eureka and Nacos). Each service will register the cluster information to the registration center when registering (for example, service A of AZ1 will register "AZ1" in the metadata field), and then register the external service address in the metadata (the address of the service that can be accessed from outside the cluster is generally transferred through a lightweight gateway).
[0104] Because microservice frameworks provide load balancing components, such as Ribbon and LoadBalancer in Spring Cloud, these components support expansion strategies. If service A in AZ1 needs to request service B, under normal circumstances, service A obtains the registry of service B from the registration center. Service A will default to request service B in the cluster (AZ1) first (based on the metadata of service B). If service B in AZ1 goes down collectively, service A will request service B in AZ2 (find service B in AZ2 in the registry).
[0105] For the load balancing strategy, it can be determined whether the candidate disaster recovery cluster set includes the current cluster of the faulty service. The degradation strategy is adopted to give priority to the current cluster of the faulty service as the target disaster recovery cluster. The current cluster of the faulty service is not included in the selected disaster recovery cluster. The target disaster recovery cluster is determined by the cluster identifier and the physical location of the computer room to ensure the highest cluster availability. The target disaster recovery service is determined by the heartbeat-related parameters of each candidate disaster recovery service, and the microservice instance of the target disaster recovery service is replaced with the microservice instance of the faulty service to process the microservice request in a timely manner. The service does not need to pay attention to the traffic corresponding to the fault tolerance mechanism, and is not invasive to the service, which can ensure the decoupling between development and fault tolerance; at the same time, it has high portability and can be ported to any service.
[0106] In one embodiment, Figure 4 The following is a schematic diagram of a multi-cluster based microservice processing device provided by an embodiment of the present invention. Figure 4 As shown, the device includes: a set determination module 41, a first cluster determination module 42, a second cluster determination module 43, a service determination module 44 and a service processing module 45.
[0107] The set determination module 41 is used to determine a candidate disaster recovery cluster set according to the fault service type in response to the received service fault instruction;
[0108] A first cluster determination module 42 is configured to directly use the current cluster of the failed service as the corresponding target disaster recovery cluster if the candidate disaster recovery cluster set includes the current cluster of the failed service;
[0109] The second cluster determination module 43 is used to determine the corresponding target disaster recovery cluster based on the cluster identifier / computer room physical location of each candidate disaster recovery cluster in the candidate disaster recovery cluster set if the candidate disaster recovery cluster set does not include the current cluster where the faulty service is located;
[0110] A service determination module 44 is used to determine a corresponding target disaster recovery service based on the heartbeat related parameters of all microservices matching the fault service type in the target disaster recovery cluster;
[0111] The service processing module 45 is used to process the microservice request of the faulty service by using the target disaster recovery service on the microservice call link corresponding to the faulty service.
[0112] In the embodiment of the present invention, the set determination module responds to the received service fault instruction and determines the candidate disaster recovery cluster set according to the fault service type. If the candidate disaster recovery cluster set includes the current cluster of the fault service, the first cluster determination module directly uses the current cluster of the fault service as the corresponding target disaster recovery cluster; if the candidate disaster recovery cluster set does not include the current cluster of the fault service, the second cluster determination module 43 determines the corresponding target disaster recovery cluster based on the cluster identifier / computer room physical location of each candidate disaster recovery cluster in the candidate disaster recovery cluster set, thereby determining the optimal candidate disaster recovery cluster; the service determination module determines the corresponding target disaster recovery service based on the heartbeat-related parameters of all microservices matching the fault service type in the target disaster recovery cluster, thereby ensuring the highest availability of the service; the service processing module uses the target disaster recovery service to process the microservice request of the fault service on the call link corresponding to the service, and replaces the fault service with the target disaster recovery service, that is, multiple microservices are used to process one data, thereby ensuring high availability. Timely load balancing of microservices is achieved, and service interruption is prevented from affecting user experience, thereby better meeting the needs of the cloud computing environment.
[0113] In one embodiment, the multi-cluster based microservice processing device further includes:
[0114] The registration center configuration module is used to configure the microservice registration center of the corresponding cluster according to the microservice framework adopted in each microservice cluster;
[0115] An information registration module is used to register the instance information of each microservice instance in each microservice cluster to the corresponding microservice registration center;
[0116] The information sharing module is used to configure the access address of the microservice registration center of other microservice clusters in the microservice registration center of each microservice cluster, so that the microservice registration center shares the instance information with the microservice registration centers of other microservice clusters.
[0117] In one embodiment, the set determination module 41 includes:
[0118] A microservice determination unit, which is used to find an available microservice matching the faulty service type in each cluster;
[0119] The set determination unit is used to form a candidate disaster recovery cluster set from all clusters with at least one available microservice.
[0120] In one embodiment, the first cluster determination module 43 includes:
[0121] An identification acquisition unit, used to acquire a cluster identification of each candidate disaster recovery cluster in the candidate disaster recovery cluster set;
[0122] The second cluster determination unit is configured to select a candidate disaster recovery cluster with a smallest cluster identifier or a cluster identifier adjacent to the cluster where the faulty service currently resides as a corresponding target disaster recovery cluster.
[0123] In one embodiment, the cluster determination module 43 includes:
[0124] A location determination unit, used to obtain the physical location of the computer room corresponding to each candidate disaster recovery cluster in the candidate disaster recovery cluster set and the physical location of the computer room corresponding to the cluster where the faulty service is currently located, as the first physical location and the second physical location;
[0125] a distance determination unit, configured to determine a relative physical distance between a first physical location and a second physical location;
[0126] The second cluster determination unit is configured to select a candidate disaster recovery cluster with the shortest relative physical distance in the candidate disaster recovery cluster set as a corresponding target disaster recovery cluster.
[0127] In one embodiment, the service determination module 44 includes:
[0128] A disaster recovery set determination unit is used to obtain all available microservices in the target disaster recovery cluster that match the service type of the faulty service to form a candidate disaster recovery service set;
[0129] A set sorting unit, used to sort the candidate disaster recovery services by priority based on the heartbeat related parameters of each candidate disaster recovery service in the candidate disaster recovery service set, to obtain a sorted candidate disaster recovery service set;
[0130] The target service determination unit is used to select the candidate disaster recovery service with the highest priority from the sorted candidate disaster recovery service set as the corresponding target disaster recovery service.
[0131] In one embodiment, when the heartbeat-related parameters include at least two indicators, the set sorting unit is specifically used to:
[0132] Obtain the actual detection value of each indicator in the heartbeat-related parameters of each candidate disaster recovery service in the candidate disaster recovery service set;
[0133] Determine the actual activity value of the corresponding candidate disaster recovery service based on the actual detection value of each indicator and the pre-configured weight value;
[0134] Prioritize each candidate disaster recovery service in the candidate disaster recovery service set according to the actual activity level value to obtain a sorted candidate disaster recovery service set.
[0135] In one embodiment, the heartbeat-related parameters of the service determination module 44 include at least one of the following indicators: the maximum number of active threads; and the current available CPU resource usage rate.
[0136] In one embodiment, the multi-cluster based microservice processing device further includes:
[0137] An instance determination module, configured to determine, in response to a received microservice request, a corresponding microservice call link and multiple microservice instances based on a request type of the microservice request;
[0138] The link determination module is used to establish connections between multiple microservice instances based on the microservice call link, so that each microservice instance processes the microservice request.
[0139] In one embodiment, the service processing module 45 includes:
[0140] An instance search unit, used to search for a microservice instance of a faulty service on a microservice call link corresponding to the faulty service;
[0141] The service processing unit is used to replace the microservice instance of the faulty service with the microservice instance of the target disaster recovery service to process the microservice request.
[0142] In one embodiment, a multi-cluster based microservice processing device integrates the fault tolerance mechanism of microservices into an independent process or container.
[0143] The multi-cluster based microservice processing device provided in the embodiment of the present invention can execute the multi-cluster based microservice processing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0144] In one embodiment, Figure 5 is a structural block diagram of an electronic device of a multi-cluster microservice processing method provided by an embodiment of the present invention, such as Figure 5 As shown, a schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0145] like Figure 5 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0146] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0147] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 executes the various methods and processes described above, such as a multi-cluster based microservice processing method.
[0148] In some embodiments, the multi-cluster based microservice processing method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the multi-cluster based microservice processing method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the multi-cluster based microservice processing method by any other appropriate means (e.g., by means of firmware).
[0149] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0150] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0151] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0152] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0153] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0154] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0155] An embodiment of the present invention further provides a computer program product, including a computer program, which, when executed by a processor, implements a multi-cluster based microservice processing method as provided in any embodiment of the present application.
[0156] In the process of implementation, the computer program product can be written in one or more programming languages or a combination thereof to perform the computer program code of the present invention, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0157] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A multi-cluster based microservice processing method, characterized in that: include: In response to the received service failure instruction, determining a candidate disaster recovery cluster set according to the type of the failed service; If the candidate disaster recovery cluster set includes the current cluster of the faulty service, the current cluster of the faulty service is directly used as the corresponding target disaster recovery cluster; If the candidate disaster recovery cluster set does not include the current cluster where the faulty service is located, determine the corresponding target disaster recovery cluster based on the cluster identifier / computer room physical location of each candidate disaster recovery cluster in the candidate disaster recovery cluster set; Determine the corresponding target disaster recovery service based on the heartbeat-related parameters of all microservices matching the faulty service type in the target disaster recovery cluster; On the microservice call link corresponding to the faulty service, the target disaster recovery service is used to process the microservice request of the faulty service.
2. The method according to claim 1, characterized in that The method further comprises: Configure the microservice registration center of the corresponding cluster according to the microservice framework used in each microservice cluster; Register the instance information of each microservice instance in each microservice cluster to the corresponding microservice registration center; The access address of the microservice registration center of other microservice clusters is configured in the microservice registration center of each microservice cluster, so that the microservice registration center shares the instance information with the microservice registration centers of other microservice clusters.
3. The method according to claim 1, characterized in that The step of determining a candidate disaster recovery cluster set according to the fault service type includes: Find an available microservice in each cluster that matches the faulty service type; All clusters with at least one available microservice constitute a candidate disaster recovery cluster set.
4. The method according to claim 1, characterized in that If the candidate disaster recovery cluster set does not include the current cluster of the failed service, determining the corresponding target disaster recovery cluster based on the cluster identifier of each candidate disaster recovery cluster in the candidate disaster recovery cluster set includes: Obtaining a cluster identifier of each candidate disaster recovery cluster in the candidate disaster recovery cluster set; The candidate disaster recovery cluster with the smallest cluster identifier or a cluster identifier adjacent to the cluster where the faulty service currently resides is used as the corresponding target disaster recovery cluster.
5. The method according to claim 1, characterized in that If the candidate disaster recovery cluster set does not include the current cluster where the faulty service is located, determining the corresponding target disaster recovery cluster based on the physical location of the computer room of each candidate disaster recovery cluster in the candidate disaster recovery cluster set includes: Obtaining the physical location of the computer room corresponding to each candidate disaster recovery cluster in the candidate disaster recovery cluster set and the physical location of the computer room corresponding to the cluster where the faulty service is currently located as the first physical location and the second physical location; determining a relative physical distance between the first physical location and the second physical location; The candidate disaster recovery cluster with the shortest relative physical distance in the candidate disaster recovery cluster set is used as the corresponding target disaster recovery cluster.
6. The method according to claim 1, characterized in that The determining the corresponding target disaster recovery service based on the heartbeat related parameters of all microservices matching the fault service type in the target disaster recovery cluster includes: Acquire all available microservices in the target disaster recovery cluster that match the service type of the faulty service to form a candidate disaster recovery service set; Prioritize the candidate disaster recovery services based on the heartbeat-related parameters of each candidate disaster recovery service in the candidate disaster recovery service set to obtain a prioritized candidate disaster recovery service set; A candidate disaster recovery service with the highest priority is selected from the sorted candidate disaster recovery service set as the corresponding target disaster recovery service.
7. The method according to claim 6, characterized in that When the heartbeat-related parameter includes at least two indicators, the candidate disaster recovery services are prioritized based on the heartbeat-related parameter of each candidate disaster recovery service in the candidate disaster recovery service set to obtain a prioritized candidate disaster recovery service set, including: Obtaining an actual detection value of each indicator in the heartbeat-related parameters of each candidate disaster recovery service in the candidate disaster recovery service set; Determine the actual activity value of the corresponding candidate disaster recovery service based on the actual detection value of each indicator and the pre-configured weight value; Priority ranking is performed on each candidate disaster recovery service in the candidate disaster recovery service set according to the actual activity level value to obtain a ranked candidate disaster recovery service set.
8. The method according to claim 1, 6 or 7, characterized in that: The heartbeat related parameters include at least one of the following indicators: the maximum number of active threads; the current available CPU resource usage.
9. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: In response to the received microservice request, determine a corresponding microservice call link and multiple microservice instances based on the request type of the microservice request; A connection is established between the multiple microservice instances based on the microservice call link, so that each of the microservice instances processes the microservice request.
10. The method according to claim 9, characterized in that The process of using the target disaster recovery service to process the microservice request of the faulty service on the microservice call link corresponding to the faulty service includes: On the microservice call link corresponding to the faulty service, search for the microservice instance of the faulty service; The microservice instance of the target disaster recovery service replaces the microservice instance of the faulty service to process the microservice request.
11. The method according to any one of claims 1 to 7, characterized in that: Integrate the fault tolerance mechanism of the microservice into an independent process or container.
12. A multi-cluster based microservice processing device, characterized in that: include: A set determination module, configured to determine a candidate disaster recovery cluster set according to a fault service type in response to a received service fault instruction; A first cluster determination module is used to directly use the current cluster of the failed service as the corresponding target disaster recovery cluster if the candidate disaster recovery cluster set includes the current cluster of the failed service; A second cluster determination module is used to determine a corresponding target disaster recovery cluster based on the cluster identifier / computer room physical location of each candidate disaster recovery cluster in the candidate disaster recovery cluster set if the candidate disaster recovery cluster set does not include the current cluster where the faulty service is located; A service determination module, used to determine a corresponding target disaster recovery service based on heartbeat-related parameters of all microservices matching the fault service type in the target disaster recovery cluster; The service processing module is used to process the microservice request of the faulty service by using the target disaster recovery service on the microservice call link corresponding to the faulty service.
13. An electronic device, characterized in that: It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the multi-cluster based microservice processing method as described in any one of claims 1 to 11 is implemented.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, a multi-cluster based microservice processing method as described in any one of claims 1 to 11 is implemented.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the multi-cluster based microservice processing method as described in any one of claims 1 to 11.
Citation Information
Cited By
Middleware management method and device
CN120909667A
