System switching method and apparatus, computer device, storage medium, and computer program product

By using a comprehensive registry center to monitor the status of microservices in real time and switch to a non-faulty system, the problem of the registry center being unable to quickly restore system services is solved, thus achieving rapid system recovery and high availability.

CN116633764BActive Publication Date: 2025-12-23TAIPING FINANCIAL SERVICE CENT (SHANGHAI) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310604973.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-26
Publication Date
2025-12-23
Estimated Expiration
2043-05-26

AI Technical Summary

Technical Problem

The existing registry center cannot quickly restore system services, which means that when all instances of a microservice in a running system encounter problems, the system cannot quickly return to normal operation.

Method used

By obtaining the configuration information of each target registry center through the comprehensive registry center, the status information of microservices is monitored in real time, and when it is determined that all instances of at least one microservice are all faulty, the system corresponding to the faulty microservice is switched to the non-faulty system, thus realizing intelligent system switching.

Benefits of technology

This enabled rapid system recovery, prevented system failures, ensured normal service delivery, and improved system availability and processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116633764B_ABST
    Figure CN116633764B_ABST
Patent Text Reader

Abstract

The application relates to a system switching method and device, computer equipment, a storage medium and a computer program product. The method comprises the following steps: obtaining configuration information of each target registration center; obtaining state information of each microservice in a system corresponding to each target registration center according to the configuration information; and when it is determined that all instances of at least one microservice are all faulty according to the state information of each microservice in the system, switching the system corresponding to the faulty microservice to a non-faulty system. The method can make the system quickly recover the external service, the registration mechanism of the system registration center in the unit of the whole system avoids the system failure caused by the complete failure of the microservice in the system, the system corresponding to the faulty microservice is switched to the non-faulty system when it is determined that all instances of at least one microservice are all faulty according to the state information of each microservice in the system, the intelligent switching of the system is realized, and the normal external service is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a system switching method and device, computer equipment, storage medium and computer program product. BACKGROUND

[0002] With the development of computer technology, micro-service technology appears, and the traditional micro-service technology is generally registered in a registration center. Specifically, generally, multiple instances of the same service are started and registered in the registration center, and when one of the service instances is abnormal, another service instance can ensure normal operation of the system to achieve high availability.

[0003] However, the current registration center can only register and discover each micro-service of an application system, and if all instances of a micro-service in a running system are problematic, the system cannot be quickly recovered. SUMMARY

[0004] Therefore, it is necessary to provide a system switching method, device, computer equipment, computer readable storage medium and computer program product capable of quickly recovering the system to provide external services in view of the above technical problems.

[0005] In a first aspect, the present application provides a system switching method, which comprises:

[0006] obtaining configuration information of each target registration center;

[0007] obtaining state information of each micro-service in a system corresponding to each target registration center according to the configuration information;

[0008] when it is determined that all instances of at least one micro-service are faulty according to the state information of each micro-service in the system, switching the system corresponding to the faulty micro-service to a non-faulty system.

[0009] In one embodiment, the configuration information comprises a registration center address, and the obtaining of the state information of each micro-service in the system corresponding to each target registration center according to the configuration information comprises:

[0010] accessing the corresponding target registration center according to the registration center address to obtain the total number of instances and the number of healthy instances of each micro-service;

[0011] After the obtaining of the state information of each micro-service in the system corresponding to each target registration center according to the configuration information, the method further comprises:

[0012] when the total number of instances of the micro-service is greater than a preset value and the number of healthy instances is less than the preset value, determining that the micro-service is faulty;

[0013] When the total instance number of the microservice is greater than a preset value, and the healthy instance number is greater than or equal to the preset value, it is determined that the microservice is normal.

[0014] In one of the embodiments, the configuration information further comprises a system corresponding to the target registry center and a system access address corresponding to the system; and when it is determined that all instances of at least one microservice are all faulty according to the state information of each microservice of the system, the system corresponding to the faulty microservice is switched to a corresponding non-faulty system, which comprises:

[0015] When at least one microservice in the system corresponding to the target registry center is faulty, the system access address of the system corresponding to the faulty microservice is replaced by the system access address of a non-faulty system.

[0016] In one of the embodiments, the configuration information comprises connection key information; and the state information of each microservice in the system corresponding to each target registry center is acquired according to the configuration information, which comprises:

[0017] One-way or two-way identity verification is performed between the connection key information and the target registry center;

[0018] When the identity verification is passed, the state information of each microservice in the system corresponding to each target registry center is acquired according to the configuration information.

[0019] In one of the embodiments, the system corresponding to the faulty microservice is switched to a non-faulty system, which comprises:

[0020] The balancing strategy of the load balancing server is modified to not access the system corresponding to the faulty microservice, and to access a non-faulty system.

[0021] In one of the embodiments, before the configuration information of each target registry center is acquired, it comprises:

[0022] The configuration information in the unit of system is received, and the microservices corresponding to the system are registered to the target registry center corresponding to each system in the unit of microservice.

[0023] In a second aspect, the application further provides a system switching device, which comprises:

[0024] A configuration information acquisition module is configured to acquire the configuration information of each target registry center;

[0025] A state information acquisition module is configured to acquire the state information of each microservice in the system corresponding to each target registry center according to the configuration information;

[0026] The switching module is configured to switch the system corresponding to the failed microservice to a non-failed system when it is determined that all instances of at least one microservice are all failed according to the state information of the microservices of the system.

[0027] In a third aspect, the present application also provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method in any one of the above embodiments when executing the computer program.

[0028] In a fourth aspect, the present application also provides a computer readable storage medium, which stores a computer program, and the computer program implements the steps of the method in any one of the above embodiments when executed by a processor.

[0029] In a fifth aspect, the present application also provides a computer program product, comprising a computer program, and the computer program implements the steps of the method in any one of the above embodiments when executed by a processor.

[0030] The system switching method, device, computer device, storage medium and computer program product avoid system failure caused by complete failure of microservices in a system, and realize intelligent switching of the system and ensure normal service provision to the outside by switching the system corresponding to the failed microservice to a non-failed system when it is determined that all instances of at least one microservice are all failed according to the state information of the microservices of the system. BRIEF DESCRIPTION OF DRAWINGS

[0031] Figure 1 An application environment diagram of the system switching method in one embodiment;

[0032] Figure 2 A flowchart of the system switching method in one embodiment;

[0033] Figure 3 A structural diagram of the primary and backup systems and the registration center in one embodiment;

[0034] Figure 4 A diagram of the configuration information of the target registration center in one embodiment;

[0035] Figure 5 A structural block diagram of the system switching device in one embodiment;

[0036] Figure 6 An internal structure diagram of the computer device in one embodiment. DETAILED DESCRIPTION

[0037] In order to make the purposes, technical solutions and advantages of the present application clearer, further detailed description will be made to the present application in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.

[0038] The system switching method provided by the embodiments of the present application can be applied to the application environment as shown in the figure. Figure 1 The comprehensive registration center 102 communicates with each target registration center 104 through a network, and each target registration center 104 communicates with one system 106 respectively.

[0039] Each microservice in each system 106 is registered to the corresponding target registration center 104, and each target registration center 104 is registered to the comprehensive registration center 102 respectively.

[0040] Each target registration center 104 can obtain the state of each microservice in the corresponding system 106. Specifically, when the microservice starts, it establishes communication with the server and port where the corresponding target registration center 104 is located, and sends the current starting service instance IP and instance port information to the target registration center 104 in the form of an http request. The target registration center saves the received starting service instance IP and port information in the form of json data to the data file of the target registration center 104, so that there is a usable service instance in the target registration center 104 at this time. Therefore, the target registration center 104 can monitor the state of each microservice in the system 106 in real time.

[0041] The comprehensive registration center 102 can obtain the configuration information of each target registration center 104; according to the configuration information, obtain the state information of each microservice in the system corresponding to each target registration center; when it is determined according to the state information of each microservice of the system that all instances of at least one microservice have failed and have not recovered within a preset time, switch the system corresponding to the failed microservice to a non-failed system. In this way, the registration mechanism of the system registration center as a whole system avoids the system failure caused by the complete failure of the microservices in a system. When it is determined according to the state information of each microservice of the system that all instances of at least one microservice have failed, the system corresponding to the failed microservice is switched to a non-failed system, so that intelligent switching of the system is realized, and normal service to the outside is ensured.

[0042] The comprehensive registration center 102 and the target registration center 104 can be implemented by an independent server or a server cluster composed of multiple servers. The system 106 can be a system of an application program, wherein the application program includes multiple microservices, and each microservice is registered in the corresponding target registration center 104.

[0043] In one embodiment, as shown in Figure 2 A system switching method is provided, which is applied to the integrated registry center in Figure 1 for example, including the following steps:

[0044] S202: Obtain the configuration information of each target registry center.

[0045] Specifically, the target registry center corresponds to the system, and one system registers its microservices to one target registry center. For example, in one application scenario, there are two systems, one is the main system and the other is the standby system, and two target registry centers are configured, one is the target registry center corresponding to the main system, and the other is the target registry center corresponding to the standby system. In other embodiments, other numbers of systems and target registry centers corresponding to the systems can also be configured.

[0046] For convenience, in combination with Figure 3 shown, wherein the registry center M is the integrated registry center, the registry center A is the target registry center corresponding to the main system, and the registry center B is the target registry center corresponding to the standby system. In this embodiment, the registration mechanism in the whole system unit can dynamically monitor the availability of the applications in the main system, and when all services are abnormal, it is dynamically switched to the standby system to realize seamless connection of the main and standby systems.

[0047] One system includes multiple microservices, and each microservice includes multiple service instances. In this way, each system registers each service instance of each microservice corresponding thereto to the corresponding registry center. For example, the main system registers each service instance of each microservice corresponding thereto to the registry center A, and the standby system registers each service instance of each microservice corresponding thereto to the registry center B. In other embodiments, for example, in the large scenario of domestic software replacement, one system can use domestic software and the other system can use non-domestic software. In this way, during subsequent modification, one-time replacement can be performed.

[0048] Wherein, at system startup, the related configuration of the target registry center is configured in the project startup configuration file of each system, for example, starting service discovery, service name, instance IP, port, health detection address, heartbeat opening, and target registry center server and port, etc., so that when the service starts, the target registry center 104 is established through the server and port corresponding to the target registry center 104, and the current starting service instance IP and instance port information is sent to the target registry center 104 in the form of an http request. The target registry center saves the received starting service instance IP and port information in the form of json data to the data file of the target registry center 104, so that the target registry center 104 will appear a usable service instance at this time. Thus, the target registry center 104 can monitor the state of each microservice in the system 106 in real time.

[0049] The configuration information of the target registry center includes target registry center address and port parameters, target registry center corresponding system and system corresponding system access address, target registry center identifier (if it is a master-slave system architecture, it can also include the code of the target registry center, that is, to distinguish whether it is a master system or a standby system) and connection key information, etc. It should be noted that the configuration information can be pre-configured by the user, for example, in some optional embodiments, before obtaining the configuration information of each target registry center, it includes: receiving the configuration information in units of systems, and the corresponding microservices in the system are registered to the target registry center corresponding to each system in units of microservices. For example, the configuration interface of the comprehensive registry center can be opened, and the related configuration information of the target configuration center can be input in the interface to complete the configuration. In other embodiments, if they are all internal systems, the corresponding target registry center can send its own configuration information to the comprehensive registry center to complete the configuration in units of systems.

[0050] S204: According to the configuration information, obtain the state information of each microservice in the system corresponding to each target registry center.

[0051] Specifically, the state information of the microservice can include the state information of each service instance of the microservice and the number of service instances of the service, for example, the state information of instance Q1 of microservice Q in a system, the state information of instance Q2, and 2 service instances.

[0052] Wherein the target registry center stores the state information of each microservice corresponding to the system, for example, in the data file of the target registry center, so the comprehensive registry center can send a microservice state information acquisition request to each target registry center according to the configuration information, thereby receiving the state information of each microservice sent by each target registry center.

[0053] In one of the embodiments, in order to ensure data security, the integrated registration center further performs identity verification before obtaining the state information of each microservice from the target registration center, so as to avoid information leakage, and in some optional embodiments, the information communicated between the integrated registration center and the target registration center can also be encrypted to ensure information security.

[0054] S206: When it is determined according to the state information of each microservice of the system that all instances of at least one microservice are all faulty, switching the system corresponding to the faulty microservice to a non-faulty system.

[0055] In one of the embodiments, in order to ensure data security, the integrated registration center further performs identity verification before obtaining the state information of each microservice from the target registration center, so as to avoid information leakage, and in some optional embodiments, the information communicated between the integrated registration center and the target registration center can also be encrypted to ensure information security.

[0056] In some optional embodiments, the integrated registration center can switch the system corresponding to the faulty microservice to a non-faulty system, so that the system providing services to the outside can still operate normally, and in order to ensure smooth switching, each system shares a database, so that even if the system fails during the processing of a task, the other system can obtain the corresponding data from the shared database after being started, thereby continuing the uncompleted task to ensure smooth switching of the system.

[0057] In some optional embodiments, the system can provide services to the outside in a cluster manner, so that after receiving a service processing request, the load balancing server distributes the service processing request to the corresponding non-faulty system. The balancing strategy in the load balancing server is updated by the integrated registration center.

[0058] In some optional embodiments, the configuration information further includes the system corresponding to the target registration center and the system access address corresponding to the system; when it is determined according to the state information of each microservice of the system that all instances of at least one microservice are all faulty, switching the system corresponding to the faulty microservice to the corresponding non-faulty system, comprising: when at least one microservice in the system corresponding to the target registration center is faulty, replacing the system access address of the system corresponding to the faulty microservice by the system access address of the non-faulty system.

[0059] In some optional embodiments, switching the system corresponding to the faulty microservice to a non-faulty system comprises: modifying the balancing strategy of the load balancing server to not access the system corresponding to the faulty microservice, and to access the non-faulty system. For example, when the comprehensive registration center determines that one of the systems is faulty, the comprehensive registration center sends information about the faulty system to the load balancing server, so that the load balancing server deletes the faulty system from the cluster that can provide services externally. In some other optional embodiments, if only a primary system and a backup system are included, when the comprehensive registration center determines that the primary system is faulty, the comprehensive registration center sends information about the faulty primary system to the load balancing server, so that, after the load balancing server obtains the information about the faulty primary system, the backup system is switched to provide services externally, for example, the system access address of the backup system is directly used to replace the system access address of the primary system, so that the service is directly routed to the corresponding backup system.

[0060] In some other embodiments, after the system is switched, the comprehensive registration center continues to obtain the state information of each microservice of the faulty system, and when it is determined according to the state information of each microservice of the faulty system that at least one service instance of each microservice in the system is normal, the faulty system is reconfigured as a normal system, and corresponding information is sent to the load balancing server, so that the system can continue to provide services externally. In this way, multiple systems provide services, reduce the processing capacity of each system, and improve the processing efficiency. When there are only a primary system and a backup system, after the primary system recovers, the primary system can be used as the backup system, or the backup system can be switched to the primary system. In this way, the primary system still provides services externally, and the backup system only provides services externally when the primary system is faulty. In this way, in the scenario of domestic software replacement, most services can be provided by domestic software.

[0061] The system switching method and the registration mechanism of the system registration center in the whole system unit avoid system failure when all microservices in a system are completely faulty. When it is determined according to the state information of each microservice of the system that all instances of at least one microservice are faulty, the system corresponding to the faulty microservice is switched to a non-faulty system, so that intelligent switching of the system is realized, and normal services are ensured to be provided externally.

[0062] In one of the embodiments, the configuration information includes target registry addresses; according to the configuration information, the state information of each microservice in the system corresponding to each target registry is obtained, including: according to the registry address, accessing the corresponding target registry to obtain the total instance number and the healthy instance number of each microservice; after obtaining the state information of each microservice in the system corresponding to each target registry according to the configuration information, further including: when the total instance number of the microservice is greater than a preset value and the healthy instance number is less than a preset value, determining that the microservice is faulty; when the total instance number of the microservice is greater than a preset value and the healthy instance number is greater than or equal to a preset value, determining that the microservice is normal.

[0063] The configuration information includes addresses of each target registry, so that the comprehensive registry obtains the state information of each microservice from each target registry, for example, according to the registry address, accessing the corresponding target registry, specifically, accessing the data file of the corresponding target registry to obtain the service instance number and the healthy instance number of each microservice of the system registered in the target registry.

[0064] For example, still taking the above embodiment as an example, the registry M (which can be understood as a program) configures the server addresses, ports, connection key information, system corresponding access load addresses, and registry system codes (used to distinguish whether it is a main system or a backup system) of the registries A and B that need to be connected in the startup configuration file. When starting, the server addresses and port parameters of the registries A and B in the configuration are obtained, and a service query http request interface (a service query interface opened by the registry) is actively sent, and the key is used to verify the identity information.

[0065] At this time, the registry M obtains two service instances Q corresponding to the registry A, and assembles the name, service instance number, registry code, and healthy instance number information of the service instance Q into json format data and temporarily saves it in the memory, and at the same time, persists it to the data file directory under the relative directory of the registry M. At the same time, the interface of the service health state opened by the registry A is called to obtain the healthy service instance number, and the healthy instance number in the saved data in the previous step is updated. In actual application, the data format is as follows: {"registry A code": "A", "service information": [{"service name": "Q", "service instance number": "2", "healthy instance number": "2"}], "healthy": "true", "running time": "5H"}.

[0066] Likewise, the registration center M obtains the service instance information corresponding to the registration center B, and finally obtains the data structure as follows: [{"registration center code A": "A", "service information": [{"service name": "Q", "service instance number": "2", "healthy instance number": "2"}], "whether the main system": "true", "whether healthy": "true", "running time": "5H"}].

[0067] In the above embodiment, only two systems and two target registration centers are taken as examples for description, and in other embodiments, other numbers of systems and target registration centers can also be set, which are not specifically limited here.

[0068] Wherein, when the total instance number of the microservice is greater than the preset value, and the healthy instance number is less than the preset value, it is determined that the microservice is faulty; when the total instance number of the microservice is greater than the preset value, and the healthy instance number is greater than or equal to the preset value, it is determined that the microservice is normal. The preset value here refers to 0, for example, when it is scanned that the instance number of the service in the system corresponding to the registration center A is greater than 1, and the current healthy instance number of the service is less than 1, it represents that there is an individual service unavailable in the current main system in the registration center A, and the "whether healthy" attribute value corresponding to the registration center A code in the memory is modified to false.

[0069] In one of the embodiments, the configuration information includes connection key information; according to the configuration information, the state information of each microservice in the system corresponding to each target registration center is obtained, including: performing one-way or two-way identity verification with the target registration center according to the connection key information; when the identity verification is passed, the state information of each microservice in the system corresponding to each target registration center is obtained according to the configuration information.

[0070] Specifically, the connection key information can be pre-configured, for example, a corresponding token, asymmetric key or symmetric key is generated according to the information of the corresponding target registration center, and then the key is stored to each target registration center and the comprehensive registration center, so that when the state information of the microservice is obtained, one-way or two-way identity verification with the target registration center according to the connection key information can be performed first, for example, identity authentication is performed according to the token, and then the state information of each microservice in the transmission process is encrypted according to the asymmetric key or symmetric key, to ensure data security. Wherein, when identity authentication is performed according to the token, the transmission of the token can also be encrypted by the asymmetric key or symmetric key to ensure security.

[0071] For the convenience of those skilled in the art to understand, please continue to see Figure 3 One of the main system contains different microservices, different microservices have multiple service instances, respectively registered in the registration center A, this whole main system here code S1. A standby system contains different microservices, different microservices also have multiple service instances, respectively registered in the registration center B, this whole standby system here code S2; The main system S1 and the standby system S2, as an atomic unit of system, are registered in the registration center (M), which is different from the traditional service registration and discovery. When S1, S2 is registered in the registration center M, each microservice in S1 system has health detection in the registration center A. When the service is offline or abnormal, the registration center A will send an abnormal health heartbeat to the service instance, and actively offline the abnormal service. If there are still normal running multiple instances of the same service, it will not affect the normal operation of the system. If all instances of the same service are abnormal, the service will be affected at this time. At this time, the registration center M needs to be notified through the heartbeat mechanism that system S1 is abnormal and needs to be offline, and then automatically switch to system S2 to provide normal services to the outside.

[0072] Specifically, first introduce the registration of each microservice of system S1. Each microservice in system S1 is started, and the registration center related configuration (start service discovery, service name, instance IP, port, health detection address, heartbeat start, registration center server and port) is configured in the project startup configuration file. When the service starts, it establishes communication with the server and port where the registration center A is located, and sends the current startup service instance IP and instance port information to the registration center A through http request. The registration center saves the received startup service instance IP and port information in the registration center A data file in json format. At this time, the registration center will appear a usable service instance.

[0073] In this embodiment, one microservice Q in system S1 is taken as an example to illustrate the deployment and startup of two instances (Q1, Q2) of microservice Q according to the above steps. Thus, there are two available instances of service Q in the registration center.

[0074] The registration center M (which can be understood as a program) configures the server address, port, connection key information, system corresponding access load address, and registration center system code (used to distinguish whether it is a main system or a standby system) of the registration center A and B that need to be connected in the startup configuration file. When starting, the target registration center A and B server address and port parameters are obtained, and the service query http request interface (the service query interface exposed by the registration center) is actively sent. The key is used to verify the identity information. The key configuration in the startup configuration is as follows Figure 4As shown, at this time, the registration center M obtains two service instances Q corresponding to the registration center A, and assembles the service Q name, instance number, registration center code, and healthy instance number information into json format data, temporarily saves the data in the memory, and persists the data to the data.conf in the data file directory under the relative directory of the registration center M. Meanwhile, the interface of the service health state opened by the registration center A is called to obtain the number of healthy service instances, and the number of healthy instances in the saved data in the previous step is updated. The data format is as follows: {"registration center A code": "A", "service information": [{"service name": "Q", "service instance number": "2", "healthy instance number": "2"}], "whether healthy": "true", "running time": "5H"}.

[0075] Similarly, the registration center M obtains the service instance information corresponding to the registration center B, and finally obtains the data structure as follows: [{"registration center A code": "A", "service information": [{"service name": "Q", "service instance number": "2", "healthy instance number": "2"}], "whether main system": "true", "whether healthy": "true", "running time": "5H"}, {"registration center B code": "B", "service information": [{"service name": "Q", "service instance number": "2", "healthy instance number": "2"}], "whether main system": "false", "whether healthy": "true", "running time": "5H"}].

[0076] In this way, the corresponding service information of the main system and the standby system is saved to the memory of the registration center M after starting, and the registration center M establishes a connection with the server address, port, and key of the main system and the standby system registration center in the starting configuration file from the start, and controls the heartbeat. According to the starting parameters (heartbeat time interval, default 10s, which can be other values in other embodiments) in the starting configuration file, the registration service information and health information of the main system and the standby system registration center are periodically obtained, the data in the memory is updated, and the latest data is persisted. In this way, the registration center M periodically obtains the latest registration service information and health information in the registration center A and the registration center B through the heartbeat mechanism. Meanwhile, the registration data saved in the current memory information is periodically compared. When it is found that the number of service instances in the system corresponding to the registration center A is greater than 1, and the number of healthy instances of the current service is less than 1, it is represented that the main system in the registration center A exists in the case that individual services are unavailable, and the "whether healthy" attribute value corresponding to the registration center A code in the memory is modified to false.

[0077] In one of the embodiments, the system access address URL is provided by default, the mapped load balancing address URL1 (corresponding to the main system access entry address in the configuration file of the registration center M) and URL2 (corresponding to the standby system access entry address in the configuration file of the registration center M) are configured, and the default load ratio is 1:0, that is, the main system is preferentially used. When it is detected that the main system health attribute is false and the standby system health attribute is true, the load balancing setting system interface is notified, and the load ratio is modified to 0:1, so that the user accesses the URL, and in the case of abnormality of the main system, the standby system is automatically switched to run.

[0078] In the above embodiments, the registration mechanism is realized in the unit of the whole system, the availability of the application in the main system can be dynamically monitored, when all services are abnormal, the standby system is dynamically switched to, and seamless connection of the main system and the standby system is realized.

[0079] It should be understood that, although each step in the flowchart involved in each of the above embodiments is displayed in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other sequences. Moreover, at least part of the steps in the flowchart involved in each of the above embodiments can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or steps or stages in other steps.

[0080] Based on the same inventive concept, the embodiments of the present application also provide a system switching device for implementing the above-mentioned system switching method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more system switching device embodiments provided below can refer to the limitations of the system switching method in the above text, and will not be repeated here.

[0081] In one embodiment, as shown in Figure 5 A system switching device is provided, comprising: a configuration information acquisition module 501, a state information acquisition module 502, and a switching module 503, wherein:

[0082] The configuration information acquisition module 501 is configured to acquire configuration information of each target registration center.

[0083] The state information acquisition module 502 is configured to acquire state information of each microservice in the system corresponding to each target registration center according to the configuration information.

[0084] The switching module 503 is configured to switch the system corresponding to the faulty microservice to a non-faulty system when it is determined that all instances of at least one microservice are faulty according to the state information of the microservices of the system.

[0085] In one of the embodiments, the configuration information includes a registration center address; and according to the configuration information, the state information obtaining module 502 is configured to access a corresponding target registration center according to the registration center address to obtain the total instance quantity and the healthy instance quantity of each microservice.

[0086] The system switching apparatus further includes:

[0087] The state judging module is configured to determine that the microservice is faulty when the total instance quantity of the microservice is greater than a preset value and the healthy instance quantity is less than the preset value, and determine that the microservice is normal when the total instance quantity of the microservice is greater than the preset value and the healthy instance quantity is greater than or equal to the preset value.

[0088] In one of the embodiments, the configuration information further includes a system corresponding to the target registration center and a system access address corresponding to the system; and the switching module 503 is configured to replace the system access address of the system corresponding to the faulty microservice by the system access address of the non-faulty system when at least one microservice in the system corresponding to the target registration center is faulty.

[0089] In one of the embodiments, the configuration information includes connection key information; and the state information obtaining module 502 includes:

[0090] The verification unit is configured to perform one-way or two-way identity verification between the connection key information and the target registration center.

[0091] The state information obtaining unit is configured to obtain the state information of each microservice in the system corresponding to each target registration center according to the configuration information when the identity verification is passed.

[0092] In one of the embodiments, the switching module 503 is configured to modify the balancing strategy of the load balancing server to not access the system corresponding to the faulty microservice and to access the non-faulty system.

[0093] In one of the embodiments, the system switching apparatus further includes:

[0094] The receiving module is configured to receive configuration information in a system unit, and the microservices corresponding to the system are registered in each target registration center corresponding to the system in a microservice unit.

[0095] The modules in the system switching apparatus can be implemented by software, hardware, or a combination thereof. The modules can be embedded in or independent of a processor in a computer device in hardware form, or stored in a memory in the computer device in software form, so as to be invoked and executed by the processor to perform the operations corresponding to the modules.

[0096] In an embodiment, a computer device, which can be a server, has an internal structure as shown in Figure 6 The computer device includes a processor, a memory, and a network interface connected by a system bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The database of the computer device is configured to store configuration information. The network interface of the computer device is configured to communicate with an external terminal through a network connection. The computer program, when executed by the processor, implements a system switching method.

[0097] Those skilled in the art can understand that Figure 6 The structure shown in the above embodiment is only a block diagram of part of the structure related to the scheme of the present application, and does not limit the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0098] In an embodiment, a computer device includes a memory and a processor. The memory stores a computer program. The processor, when executing the computer program, implements the following steps: obtaining configuration information of each target registry; obtaining state information of each microservice in a system corresponding to each target registry according to the configuration information; and when it is determined that all instances of at least one microservice are all faulty according to the state information of each microservice in the system, switching the system corresponding to the faulty microservice to a non-faulty system.

[0099] In an embodiment, the configuration information involved when the processor executes the computer program includes a registry center address; the processor, when executing the computer program, implements, according to the configuration information, obtaining state information of each microservice in a system corresponding to each target registry center, including: accessing the corresponding target registry center according to the registry center address to obtain the total instance quantity and the healthy instance quantity of each microservice; after the processor, when executing the computer program, implements, according to the configuration information, obtaining state information of each microservice in a system corresponding to each target registry center, further including: when the total instance quantity of the microservice is greater than a preset value and the healthy instance quantity is less than a preset value, determining that the microservice is faulty; when the total instance quantity of the microservice is greater than a preset value and the healthy instance quantity is greater than or equal to a preset value, determining that the microservice is normal.

[0100] In an embodiment, the configuration information involved when the processor executes the computer program further includes a system corresponding to the target registry center and a system access address corresponding to the system; the processor, when executing the computer program, implements, when determining that all instances of at least one microservice are all faulty according to the state information of each microservice of the system, switching the system corresponding to the faulty microservice to the corresponding non-faulty system, including: when at least one microservice in the system corresponding to the target registry center is faulty, replacing the system access address of the system corresponding to the faulty microservice by the system access address of the non-faulty system.

[0101] In an embodiment, the configuration information involved when the processor executes the computer program includes connection key information; the processor, when executing the computer program, implements, according to the configuration information, obtaining state information of each microservice in a system corresponding to each target registry center, including: performing one-way or two-way identity verification with the target registry center according to the connection key information; when the identity verification is passed, obtaining state information of each microservice in a system corresponding to each target registry center according to the configuration information.

[0102] In an embodiment, the processor, when executing the computer program, implements switching the system corresponding to the faulty microservice to the non-faulty system, including: modifying the balancing strategy of the load balancing server to not access the system corresponding to the faulty microservice and to access the non-faulty system.

[0103] In an embodiment, before the processor, when executing the computer program, implements obtaining the configuration information of each target registry center, including: receiving configuration information in a system unit, and the corresponding microservice in the system is registered to each target registry center corresponding to the system in a microservice unit.

[0104] In one embodiment, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program. The computer program is executed by a processor to implement the following steps: obtaining configuration information of each target registry center; obtaining, according to the configuration information, state information of each microservice in a system corresponding to each target registry center; and switching the system corresponding to the failed microservice to a non-failed system when it is determined that all instances of at least one microservice are all failed according to the state information of each microservice in the system.

[0105] In one embodiment, the configuration information involved when the computer program is executed by the processor includes a registry center address. The computer program is executed by the processor to implement the following steps: obtaining, according to the configuration information, state information of each microservice in a system corresponding to each target registry center, including: accessing the corresponding target registry center according to the registry center address to obtain the total instance number and the healthy instance number of each microservice; and determining that the microservice is failed when the total instance number of the microservice is greater than a preset value and the healthy instance number is less than the preset value, and determining that the microservice is normal when the total instance number of the microservice is greater than the preset value and the healthy instance number is greater than or equal to the preset value.

[0106] In one embodiment, the configuration information involved when the computer program is executed by the processor further includes a system corresponding to the target registry center and a system access address corresponding to the system. The computer program is executed by the processor to implement the following steps: switching the system corresponding to the failed microservice to the corresponding non-failed system when it is determined that all instances of at least one microservice are all failed according to the state information of each microservice in the system, including: replacing the system access address of the system corresponding to the failed microservice by the system access address of the non-failed system when at least one microservice in the system corresponding to the target registry center is failed.

[0107] In one embodiment, the configuration information involved when the computer program is executed by the processor includes connection key information. The computer program is executed by the processor to implement the following steps: obtaining, according to the configuration information, state information of each microservice in a system corresponding to each target registry center, including: performing one-way or two-way identity verification with the target registry center according to the connection key information; and obtaining, according to the configuration information, state information of each microservice in a system corresponding to each target registry center when the identity verification is passed.

[0108] In one embodiment, the computer program is executed by the processor to implement the following steps: switching the system corresponding to the failed microservice to the non-failed system, including: modifying the balancing strategy of the load balancing server to not access the system corresponding to the failed microservice and to access the non-failed system.

[0109] In one embodiment, the computer program, when executed by the processor, before the step of obtaining the configuration information of each target registry center, comprises: receiving the configuration information in a system unit, and the corresponding microservice in the system is registered in each target registry center in a microservice unit.

[0110] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by the processor, implements the following steps: obtaining the configuration information of each target registry center; obtaining the state information of each microservice in the system corresponding to each target registry center according to the configuration information; when it is determined that all instances of at least one microservice are all faulty according to the state information of each microservice in the system, switching the system corresponding to the faulty microservice to a non-faulty system.

[0111] In one embodiment, the configuration information involved when the computer program is executed by the processor comprises a registry center address; the step of obtaining the state information of each microservice in the system corresponding to each target registry center according to the configuration information, when the computer program is executed by the processor, comprises: accessing the corresponding target registry center according to the registry center address to obtain the total instance number and the healthy instance number of each microservice; after the step of obtaining the state information of each microservice in the system corresponding to each target registry center according to the configuration information, when the computer program is executed by the processor, further comprises: when the total instance number of the microservice is greater than a preset value and the healthy instance number is less than a preset value, determining that the microservice is faulty; when the total instance number of the microservice is greater than a preset value and the healthy instance number is greater than or equal to a preset value, determining that the microservice is normal.

[0112] In one embodiment, the configuration information involved when the computer program is executed by the processor further comprises the system corresponding to the target registry center and the system access address corresponding to the system; the step of switching the system corresponding to the faulty microservice to the corresponding non-faulty system when it is determined that all instances of at least one microservice are all faulty according to the state information of each microservice in the system, when the computer program is executed by the processor, comprises: when at least one microservice in the system corresponding to the target registry center is faulty, replacing the system access address of the system corresponding to the faulty microservice by the system access address of the non-faulty system.

[0113] In one embodiment, the configuration information involved when the computer program is executed by the processor comprises connection key information; the step of obtaining the state information of each microservice in the system corresponding to each target registry center according to the configuration information, when the computer program is executed by the processor, comprises: performing one-way or two-way identity verification with the target registry center according to the connection key information; when the identity verification is passed, obtaining the state information of each microservice in the system corresponding to each target registry center according to the configuration information.

[0114] In one embodiment, the computer program, when executed by the processor, implements the switching of the system corresponding to the faulty microservice to the non-faulty system, comprising: modifying the balancing strategy of the load balancing server to not access the system corresponding to the faulty microservice, and to access the non-faulty system.

[0115] In one embodiment, the computer program, when executed by the processor, implements the obtaining of the configuration information of each target registration center, before the configuration information of each target registration center is obtained, comprising: receiving the configuration information in a system unit, and the corresponding microservice in the system is registered in the target registration center corresponding to each system in a microservice unit.

[0116] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments. Any reference to memory, database or other medium used in the embodiments provided by the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric memory (Ferroelectric Random Access Memory, FRAM), phase change memory (Phase Change Memory, PCM), graphene memory, etc. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The database involved in the embodiments provided by the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided by the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.

[0117] Any technical features in the above embodiments can be combined, and for the sake of brevity, not all possible combinations are described above, however, as long as the combinations of technical features do not have contradictions, they shall be considered within the scope of the present disclosure.

[0118] The above embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it shall not be understood as a limitation on the patent scope of the present application. It shall be pointed out that, for ordinary skilled persons in the art, several modifications and improvements can be made without departing from the concept of the present application, and these shall be within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.

Claims

1. A system switching method applied to an integrated registration center, characterized in that, The method comprises: Obtaining configuration information of each target registry center; According to the configuration information, obtaining the state information of each microservice in the system corresponding to each target registry center; When it is determined that all instances of at least one microservice are all faulty according to the state information of each microservice in the system, the system corresponding to the faulty microservice is switched to a non-faulty system; Before the obtaining of the configuration information of each target registry center, the method comprises: Receiving configuration information in units of systems, and the corresponding microservices in the system are registered in each target registry center in units of microservices.

2. The method of claim 1, wherein, The configuration information comprises a registry center address; and the obtaining of the state information of each microservice in the system corresponding to each target registry center according to the configuration information comprises: According to the registry center address, accessing the corresponding target registry center to obtain the total instance number and the healthy instance number of each microservice; After the obtaining of the state information of each microservice in the system corresponding to each target registry center according to the configuration information, the method further comprises: When the total instance number of the microservice is greater than a preset value and the healthy instance number is less than the preset value, it is determined that the microservice is faulty; When the total instance number of the microservice is greater than a preset value and the healthy instance number is greater than or equal to the preset value, it is determined that the microservice is normal.

3. The method of claim 2, wherein, The configuration information further comprises the system corresponding to the target registry center and the system access address corresponding to the system; and when it is determined that all instances of at least one microservice are all faulty according to the state information of each microservice in the system, the system corresponding to the faulty microservice is switched to the corresponding non-faulty system, which comprises: When all instances of at least one microservice in the system corresponding to the target registry center are all faulty, the system access address of the faulty system corresponding to the microservice is replaced by the system access address of the non-faulty system.

4. The method of claim 1, wherein, The configuration information comprises connection key information; and the obtaining of the state information of each microservice in the system corresponding to each target registry center according to the configuration information comprises: According to the connection key information, performing one-way or two-way identity verification with the target registry center; When the identity verification is passed, obtaining the state information of each microservice in the system corresponding to each target registry center according to the configuration information.

5. The method according to any one of claims 1 to 4, characterized in that, The switching of the system corresponding to the faulty microservice to the non-faulty system comprises: Modifying the balancing strategy of the load balancing server to not access the system corresponding to the faulty microservice and to access the non-faulty system.

6. A system switching apparatus applied to an integrated registration center, characterized in that, The device comprises: A configuration information obtaining module, configured to obtain configuration information of each target registry center; A state information obtaining module, configured to obtain the state information of each microservice in the system corresponding to each target registry center according to the configuration information; A switching module, configured to switch the system corresponding to the faulty microservice to a non-faulty system when it is determined that all instances of at least one microservice are all faulty according to the state information of each microservice in the system; The system switching device further comprises: A receiving module is configured to receive configuration information in a system unit, and corresponding microservices in the system are registered to a target registry center corresponding to each system in a microservice unit. 7.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-6 when the computer program is executed by the processor. The computer program, when executed by the processor, implements the steps of the method of any one of claims 1 to 5.

8. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program, when executed by the processor, implements the steps of the method of any one of claims 1 to 5.

9. A computer program product comprising a computer program, characterized in that, The computer program, when executed by the processor, implements the steps of the method of any one of claims 1 to 5. The computer program, when executed by the processor, implements the steps of the method of any one of claims 1 to 5.

Citation Information

Patent Citations

  • Packet routing method and device, electronic equipment and storage medium

    CN114363233A