A primary and standby switching method, device, storage medium and equipment

By setting servers to an unknown state and using tailored health check markers and parameters, the method swiftly identifies faulty servers during load balancer switchover, reducing misrouting and resource consumption.

CN116016136BActive Publication Date: 2025-07-15BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211714921.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-27
Publication Date
2025-07-15
Estimated Expiration
2042-12-27

AI Technical Summary

Technical Problem

During the main and standby switching of the load balancer, the status of the faulty server cannot be quickly confirmed, resulting in traffic being scheduled to the faulty server.

Method used

When receiving the main and backup switching signal, all server statuses are set to an unknown state, and the corresponding server mark bits are assigned according to the type of health check referenced. After switching to the host, the target detection parameters are used for health checks. The period of the target detection parameters is shorter than the basic detection parameters, and the upper limit of the number of detections is lower than the basic detection parameters.

Benefits of technology

Quickly confirm the status of the failed server, reduce the time for abnormal traffic scheduling, and reduce the consumption of bandwidth and server resources by health checks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116016136B_ABST
    Figure CN116016136B_ABST
Patent Text Reader

Abstract

An embodiment of the present application provides a primary / standby switching method, apparatus, storage medium, and device. In this method, a set of new detection parameters for use when the standby machine promotes to the primary machine is provided for each type of health check. When a primary / standby switching signal is received, the standby machine first sets the status of all servers to an unknown status, and then assigns the marker bits of all members according to the type of referenced health check. After promoting to the primary machine, new detection parameters are obtained according to the values of the marker bits for health check, and then the server status is set according to the health check, and the marker bits of each server are set to the default value to resume normal detection. Since the new detection parameters have a shorter detection period and / or a smaller upper limit of the number of detection times, therefore, only the new detection parameters are used for status check for the first time after primary / standby switching, which can quickly confirm the status of the faulty server, thereby reducing the time of abnormal traffic scheduling and minimizing the consumption of bandwidth and server resources by health check at the same time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of network communication technologies, and in particular, to a primary / backup switching method, apparatus, storage medium, and device. Background Art

[0002] Dual-machine backup is an important technology to ensure network reliability. To ensure the normal forwarding of service network data even when a communication line or device fails, the shorter the primary / backup switching time, the better. As a traffic scheduling device, the load balancer not only pays attention to the network status but also the working status of the servers. Only when both the network and the server status are normal can the traffic be correctly scheduled. Due to the primary / backup mechanism, before the primary / backup switch, the status of all servers on the standby of the load balancer is set to the abnormal status, indicating that the traffic cannot be scheduled, until the new primary host after the primary / backup switch skips the health check and actively sets the status of the server to the unknown status, indicating that the traffic can be scheduled. This can ensure that the service can be used normally after the primary / backup switch is completed.

[0003] However, if some servers have failed before the primary / backup switch, in this case, when the primary / backup switch occurs, the failed servers will be set to the unknown status, and it often takes three health check detection cycles to confirm the status of the failed servers. During this period, the traffic may be scheduled to the failed servers. Summary of the Invention

[0004] The purpose of the embodiments of this application is to provide a primary / backup switching method, apparatus, storage medium, and device, aiming to solve the problem in the related technologies that during the primary / backup switch of the load balancer, the status of the failed servers cannot be quickly confirmed, resulting in the traffic possibly being scheduled to the failed servers.

[0005] In a first aspect, a primary / backup switching method provided by the embodiments of this application is applied to the standby machine in a dual-machine system, and the standby machine is a load balancing device. The method includes:

[0006] When receiving the primary / backup switching signal, set the status of all servers to the unknown status, and assign values to the flag bits of the corresponding servers according to the types of reference health checks;

[0007] After switching to the primary machine, check the flag bits of each server. If the value of the flag bit is a non-default value, use the target detection parameters corresponding to the value of the flag bit to perform a health check on the server. If the value of the flag bit is the default value, use the basic detection parameters to perform a health check on the server; the detection period of the target detection parameters is shorter than the detection period of the basic detection parameters, and / or, the upper limit of the number of detections of the target detection parameters is lower than the upper limit of the number of detections of the basic detection parameters;

[0008] Set the server status according to the health check results and set the flag positions of each server to the default values.

[0009] In the above implementation process, a set of new detection parameters for use when the standby machine promotes to the host machine is provided for each type of health check. When receiving the primary-standby switch signal, the standby machine first sets all the server statuses to the unknown status, and then assigns the flag positions of all members according to the type of referenced health check. After promoting to the host machine, new detection parameters are obtained according to the values of the flag positions for health check, and then the server status is set according to the health check, and the flag positions of each server are set to the default values to resume normal detection. Since the new detection parameters have a shorter detection period and / or a smaller upper limit of the number of detections, therefore, only the new detection parameters are used for status check for the first time after the primary-standby switch, the status of the faulty server can be quickly confirmed, thereby reducing the time of abnormal traffic scheduling, and at the same time minimizing the consumption of bandwidth and server resources by the health check.

[0010] Further, in some embodiments, the assigning the flag positions of the corresponding servers according to the type of referenced health check includes:

[0011] If the referenced health check is TCP health check, assign the flag position of the corresponding server to the first value;

[0012] If the referenced health check is ICMP health check, assign the flag position of the corresponding server to the second value;

[0013] If the referenced health check is HTTP health check, assign the flag position of the corresponding server to the third value.

[0014] In the above implementation process, according to the type of referenced health check, TCP health check, ICMP health check, and HTTP health check, the server flag positions are sequentially assigned to the first value, the second value, and the third value, so that when the new host performs health check on each server, it can quickly determine which type of health check detection parameters should be obtained for detection according to the values of the flag positions of each server.

[0015] Further, in some embodiments, the default value is 0, the first value is 1, the second value is 2, and the third value is 3.

[0016] In the above implementation process, through the setting of the above values, it is convenient to identify and facilitate the subsequent expansion of the types of health checks.

[0017] Further, in some embodiments, the detection period of the target detection parameters is 1 second or 2 seconds, and the upper limit of the number of detections is 2 times.

[0018] In the above implementation process, through the setting of the above values, the status of the faulty server can be quickly and effectively confirmed.

[0019] Further, in some embodiments, setting the server status according to the health check result includes:

[0020] When the detection request does not receive the correct check result, wait for one detection period and then conduct the next detection. If the upper limit of the detection times is reached, set the status of the server to the abnormal state;

[0021] When the detection request receives the correct check result, set the status of the server to the normal state.

[0022] In the above implementation process, a specific method for setting the server status according to the health check result is provided.

[0023] Further, in some embodiments, the method further includes:

[0024] Reporting the information of the faulty server, where the faulty server is the server in the abnormal state.

[0025] In the above implementation process, after the new host confirms the health status of each server, it can report the information of the faulty server, such as the IP address, server ID, model, health check result, etc. of the faulty server, to the management end, so that the management personnel can timely troubleshoot and repair the faulty server, thereby ensuring the normal processing of the business.

[0026] In a second aspect, a primary-backup switching device provided by an embodiment of the present application is applied to a standby machine in a dual-machine system, and the standby machine is a load balancing device. The device includes:

[0027] An assignment module, configured to, when receiving a primary-backup switching signal, set the status of all servers to the unknown state and assign values to the flag bits of the corresponding servers according to the types of health checks referred to;

[0028] An inspection module, configured to, after switching to the primary machine, check the flag bits of each server. If the value of the flag bit is a non-default value, use the target detection parameters corresponding to the value of the flag bit to perform a health check on the server. If the value of the flag bit is the default value, use the basic detection parameters to perform a health check on the server; the detection period of the target detection parameters is shorter than the detection period of the basic detection parameters, and / or the upper limit of the detection times of the target detection parameters is lower than the upper limit of the detection times of the basic detection parameters;

[0029] A setting module, configured to set the server status according to the health check result and set the flag bits of each server to the default value.

[0030] In a third aspect, an electronic device provided by an embodiment of the present application includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method according to any one of the first aspect are implemented.

[0031] In a fourth aspect, a computer-readable storage medium provided by an embodiment of the present application has instructions stored thereon. When the instructions are run on a computer, the computer is caused to execute the method according to any one of the first aspect.

[0032] In a fifth aspect, a computer program product provided by an embodiment of the present application, when run on a computer, causes the computer to execute the method according to any one of the first aspect.

[0033] Other features and advantages disclosed in the present application will be described in the subsequent specification, or, some features and advantages can be inferred from the specification or determined without doubt, or can be learned by implementing the above technologies disclosed in the present application.

[0034] To make the above objects, features, and advantages of the present application more obvious and understandable, the following specifically enumerates preferred embodiments and, in conjunction with the accompanying drawings, provides a detailed description as follows. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] To more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required to be used in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application and should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.

[0036] Figure 1 It is a flowchart of a primary / standby switching method provided by an embodiment of the present application;

[0037] Figure 2 It is a schematic diagram of the working process of a solution for quickly checking the status of a faulty server by a standby machine during primary / standby switching provided by an embodiment of the present application;

[0038] Figure 3 It is a block diagram of a primary / standby switching device provided by an embodiment of the present application;

[0039] Figure 4 It is a block diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0040] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application.

[0041] It should be noted that similar reference numerals and letters indicate similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of the present application, terms such as "first" and "second" are only used for distinguishing descriptions and cannot be construed as indicating or implying relative importance.

[0042] As described in the background art, in the related art, there is a problem that during the primary / standby switchover of a load balancer, the status of a faulty server cannot be quickly confirmed, resulting in traffic possibly being scheduled to the faulty server. Based on this, an embodiment of the present application provides a primary / standby switchover solution to solve the above problem.

[0043] Next, an embodiment of the present application will be introduced:

[0044] As Figure 1 shown, Figure 1 is a flowchart of a primary / standby switchover method provided by an embodiment of the present application. The method is applied to a standby machine in a dual-machine system, and the standby machine is a load balancing device. Generally speaking, a dual-machine system includes a primary machine and a standby machine. In this embodiment, the dual-machine system is composed of two load balancing devices, and these two load balancing devices are backup to each other. Among them, the load balancing device acting as the primary machine is mainly responsible for the traffic scheduling of the external network requesting internal network service resources and the health check of the internal network servers; the load balancing device acting as the standby machine mainly undertakes the work tasks of the primary machine when primary / standby switchover is required.

[0045] The method includes:

[0046] In step 101, when receiving a primary / standby switchover signal, set the status of all servers to an unknown status, and assign a flag bit to the corresponding server according to the type of referenced health check;

[0047] The primary / standby switchover signal mentioned in this step can be automatically triggered by the dual-machine system or manually triggered by a management personnel. Generally speaking, the primary machine and the standby machine are connected by a heartbeat line to monitor each other's health status. When the standby machine does not receive a heartbeat packet sent by the primary machine within a specified time, it is considered that the primary machine has a fault, and then the standby machine receives the primary / standby switchover signal; or when the management personnel trigger the primary / standby switchover process through the console, the standby machine also receives the primary / standby switchover signal.

[0048] After receiving the master-slave switch signal, the standby machine sets the status of all servers to the unknown status, which indicates that the health status of the servers is undetermined but can be scheduled for traffic. At the same time, the standby machine assigns values to the flag bits of the corresponding servers according to the types of referenced health checks. In practical applications, the types of multiple servers for which the load balancing device performs traffic scheduling are different, and the types of health checks referenced for different types of servers may also be different. The types of health checks include TCP (Transmission Control Protocol) health check, ICMP (Internet Control Message Protocol) health check, HTTP (HyperText Transfer Protocol) health check, etc. Among them, the TCP health check determines the health status of the server by establishing a TCP connection with the server. If the TCP handshake successfully establishes a connection, it indicates that the server is in good health; the ICMP health check sends a ping command to check whether the network is reachable and receives a reply packet. If a ping reply packet is received, it indicates that the server connectivity is normal and the server is in good health; the HTTP health check sends an HTTP request and determines the health status of the server according to the response code and response time. If both the response code and response time meet the expected results, it indicates that the server is in good health.

[0049] Assign values to the flag bits of the corresponding servers according to the types of referenced health checks, that is, modify the flag bits of the servers from the default value to a specific value, and this specific value corresponds to the type of health check referenced for the server. Optionally, if the referenced health check is a TCP health check, assign the flag bit of the corresponding server to the first value; if the referenced health check is an ICMP health check, assign the flag bit of the corresponding server to the second value; if the referenced health check is an HTTP health check, assign the flag bit of the corresponding server to the third value. By setting like this, when the new host performs health checks on each server, it can quickly determine which health check detection parameters should be obtained for detection according to the values of the flag bits of each server.

[0050] Further, in some embodiments, the default value can be 0, the first value can be 1, the second value can be 2, and the third value can be 3. By setting like this, it is convenient to identify and facilitate the subsequent expansion of the types of health checks. Of course, in other embodiments, different settings can also be made according to the requirements of specific scenarios.

[0051] After switching to the host in step 102, check the flag bits of each server. If the value of the flag bit is a non-default value, use the target detection parameters corresponding to the value of the flag bit to perform a health check on the server. If the value of the flag bit is the default value, use the basic detection parameters to perform a health check on the server; the detection period of the target detection parameters is shorter than that of the basic detection parameters, and / or, the upper limit of the number of detection times of the target detection parameters is lower than that of the basic detection parameters;

[0052] The solution of this embodiment provides a set of health check detection parameters for each type of health check to be used when the standby machine is promoted to the host, that is, the target detection parameters in this step. Compared with the basic detection parameters, the target detection parameters have a shorter detection period and / or a lower upper limit of the number of detection times, so that the status of the faulty server can be confirmed in a shorter time. Moreover, the solution of this embodiment adds a flag bit to each server to indicate which detection parameters should be used to send detection requests during health checks. In this way, after the standby machine is switched to the host, it becomes the new host. The new host follows the modified health check process, first checks the flag bits of each server. When the value of the flag bit is not the default value, obtain the corresponding detection parameters according to the value of the flag bit and use these detection parameters to initiate a detection request. When the value of the flag bit is the default value, send a detection request using the basic detection parameters.

[0053] The basic detection parameters mentioned in this step may refer to the detection parameters used during normal detection, that is, the detection period is 10 seconds and the upper limit of the number of detection times is 3 times. Correspondingly, in some embodiments, the detection period of the target detection parameters mentioned in this step is 1 second or 2 seconds, and the upper limit of the number of detection times is 2 times. For example, in the target detection parameters of TCP health check, the detection period can be 2 seconds and the upper limit of the number of detection times can be 2 times. In this way, the new host sends a detection request to the corresponding server. When the correct check result is not received for the request, the new host waits for 2 seconds and then sends the detection request again. If the correct check result is still not received for the request, since the number of times the detection request has been sent has reached the upper limit of the number of detection times, it can be determined that the TCP health check of this server has failed. It has been found through experiments that by setting the above values, the status of the faulty server can be quickly and effectively confirmed. Of course, in other embodiments, the target detection parameters can also be adjusted accordingly according to the requirements of the actual scenario, such as adjusting the detection period to 4 seconds, etc., and this application does not limit this.

[0054] In step 103, set the status of the server according to the health check result, and set the flag bits of each server to the default value.

[0055] The server status mentioned in this step may refer to the health status of the server. Generally speaking, the health status of the server mainly includes the normal status, the unknown status, and the abnormal status. Among them, the normal status indicates that the health check has passed and can be scheduled for traffic; the unknown status indicates that the health status is undetermined and can be scheduled for traffic; the abnormal status indicates that the health check has not passed and cannot be scheduled for traffic. In some embodiments, setting the server status according to the health check result mentioned in this step may include: when the probe request does not receive the correct check result, waiting for a probe cycle and then performing the next probe. If the probe count reaches the upper limit, setting the server status to the abnormal status; when the probe request receives the correct check result, setting the server status to the normal status. That is to say, after the new host sends a probe request, if the server response times out or the response message does not meet the expected result, indicating that the request does not have the correct check result, the new host waits for a probe cycle and then performs the next probe. If the probe limit is reached, the server status is set to the abnormal status, so that the server will no longer be scheduled for traffic. When the request receives the correct check result, the server status is directly set to the normal status, thus completing the current health check process.

[0056] After the new host uses the new probe parameters to perform the status check for the first time, it can already confirm the status of the faulty server. At this time, the new host sets the marker positions of each server to the default values, indicating that subsequent health checks will use the basic probe parameters, that is, resume normal probing. This can reduce the consumption of health check traffic, thereby avoiding occupying too much network bandwidth and server resources.

[0057] Furthermore, in some embodiments, the above method may further include: reporting the information of the faulty server, where the faulty server is a server in the abnormal status. That is to say, after the new host confirms the health status of each server, it can report the information of the faulty server, such as the IP address of the faulty server, the server ID, the model, the health check result, etc. to the management end, so that the management personnel can timely troubleshoot and repair the faulty server, thereby ensuring the normal processing of the business.

[0058] In the embodiment of the present application, a new set of detection parameters for each type of health check is provided for use when the standby machine is promoted to the host machine. When a primary / standby switch signal is received, the standby machine first sets the status of all servers to an unknown status, and then assigns the flag bits of all members according to the type of referenced health check. After being promoted to the host machine, new detection parameters are obtained according to the values of the flag bits for health check, and the server status is set according to the health check, and the flag bits of each server are set to the default value to resume normal detection. Since the new detection parameters have a shorter detection period and / or a smaller upper limit of the number of detections, therefore, only the new detection parameters are used for status check for the first time after the primary / standby switch, and the status of the faulty server can be quickly confirmed, thereby reducing the time of abnormal traffic scheduling and minimizing the consumption of bandwidth and server resources by health check.

[0059] To illustrate the solution of the present application in more detail, a specific embodiment will be introduced next:

[0060] The primary / standby switch service is an important means to ensure network reliability. The service network includes two load balancers and multiple servers. Among them, the two load balancers are the primary and standby machines in the primary / standby scenario, and are mainly responsible for the traffic scheduling of the external network requesting the internal network service resources and the health check of the internal network servers. Before this embodiment, due to the primary / standby mechanism, before the primary / standby switch, the status of all servers on the standby load balancer was set to an abnormal status. After the primary / standby switch, the new host skips the health check and actively sets the status of the servers to an unknown status, so as to ensure that the service can be used normally after the primary / standby switch is completed. But this also brings another problem. If some servers have failed before the primary / standby switch, in this case, when the primary / standby switch occurs, the faulty servers will be set to an unknown status, and it often takes three health check detection cycles to confirm the status of the faulty servers. During this period, traffic may be scheduled to the faulty servers. If the health check detection period is directly shortened, the health check traffic will increase significantly, and the occupied network bandwidth and server resources will also increase significantly. Based on this, this embodiment provides a solution for the standby machine to quickly check the status of faulty servers during the primary / standby switch to solve the above problems.

[0061] The solution of this embodiment is applied to the load balancer that is the standby machine before the primary / standby switch and the new host after the primary / standby switch. The working process of this solution is as Figure 2 shown and includes:

[0062] S201. Receive the primary / standby switch signal;

[0063] S202. Set all members to an unknown status;

[0064] S203. Assign values to the flag bits of all members according to the type of health check. Specifically, the default value of the flag bit is 0. If the health check type for the server is TCP health check, set its flag bit to 1. If the health check type for the server is ICMP health check, set its flag bit to 2. If the health check type for the server is HTTP health check, set its flag bit to 3;

[0065] S204. Promote to the host;

[0066] S205. Check the flag bits of each member, and obtain the corresponding detection parameters according to the flag bits to send a health check detection request. Specifically, if the value of the flag bit is 0, perform a health check according to the original detection parameters, that is, the detection period is 10s and the upper limit of the number of detections is 3 times. If the value of the flag bit is non-zero, obtain the corresponding detection parameters according to the value of the flag bit. For example, when the value of the flag bit is 1, the detection period in the new detection parameters is 2s and the upper limit of the number of detections is 2 times. When the value of the flag bit is 2, the detection period in the new detection parameters is 1s and the upper limit of the number of detections is 1 time, and use these detection parameters to perform a health check;

[0067] S206. Determine whether a correct inspection result is received. If yes, execute S207; otherwise, execute S210;

[0068] S207. Wait for a detection period;

[0069] S208. Determine whether the upper limit of the number of detections is reached. If yes, execute S209; otherwise, return to S205;

[0070] S209. Set the server status to the abnormal status, and then execute S211. Specifically, when a faulty server is detected, no response will be received. After multiple detections, when the detection upper limit is reached, the server status is set to the abnormal status. At this time, the faulty server will no longer be scheduled for traffic;

[0071] S210. Set the server status to the normal status, and then execute S211. Specifically, when the server responds normally, the server status is set to the normal status. At this time, the normal server will continue to be scheduled for traffic;

[0072] S211. Set the value of the current member's flag bit to 0. Specifically, after the status of the server is confirmed, restore the normal detection parameters of the health check to reduce the impact caused by the adjustment of the detection parameters;

[0073] S212. Wait for a detection period, and then return to S205.

[0074] In the solution of this embodiment, when the primary / standby switchover occurs, the health check detection parameters are flexibly switched, enabling the new host to quickly confirm the status of the faulty server, reducing the time for the faulty server to be in an unknown state, thereby reducing the time for abnormal traffic scheduling. Moreover, the new detection parameters are only used for status check during the first health check after the primary / standby switchover, minimizing the consumption of bandwidth and server resources by the health check.

[0075] Corresponding to the embodiment of the foregoing method, the present application further provides an embodiment of a primary / standby switchover device and a terminal to which it is applied:

[0076] As Figure 3 shown, Figure 3 is a block diagram of a primary / standby switchover device provided by an embodiment of the present application. The device is applied to the standby machine in a dual-machine system, and the standby machine is a load balancing device. The device includes:

[0077] An assignment module 31, configured to set the status of all servers to an unknown state when receiving a primary / standby switchover signal, and assign a flag bit to the corresponding server according to the type of health check referred to;

[0078] An inspection module 32, configured to, after switching to the primary machine, check the flag bits of each server. If the value of the flag bit is a non-default value, use the target detection parameters corresponding to the value of the flag bit to perform a health check on the server. If the value of the flag bit is the default value, use the basic detection parameters to perform a health check on the server; the detection period of the target detection parameters is shorter than that of the basic detection parameters, and / or, the upper limit of the number of detection times of the target detection parameters is lower than that of the basic detection parameters;

[0079] A setting module 33, configured to set the status of the server according to the health check result, and set the flag bits of each server to the default value.

[0080] The implementation processes of the functions and roles of each module in the above device are specifically described in detail in the implementation processes of the corresponding steps in the above method, and will not be elaborated here.

[0081] The present application further provides an electronic device. Please refer to Figure 4 , Figure 4 is a structural block diagram of an electronic device provided by an embodiment of the present application. The electronic device may include a processor 410, a communication interface 420, a memory 430, and at least one communication bus 440. Among them, the communication bus 440 is used to realize direct connection communication between these components. Among them, the communication interface 420 of the electronic device in the embodiment of the present application is used to communicate signaling or data with other node devices. The processor 410 may be an integrated circuit chip with signal processing capabilities.

[0082] The above-mentioned processor 410 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The above-mentioned processor 410 may be a microprocessor, or the processor 410 may also be any conventional processor, etc.

[0083] The memory 430 may be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. The memory 430 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 410, the electronic device can execute the Figure 1 various steps involved in the method embodiments.

[0084] Optionally, the electronic device may further include a storage controller and an input / output unit.

[0085] The memory 430, the storage controller, the processor 410, the peripheral interface, and the input / output unit are directly or indirectly electrically connected to each other to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses 440. The processor 410 is used to execute the executable module stored in the memory 430, such as the software function module or computer program included in the electronic device.

[0086] The input / output unit is used to provide the user with the creation of tasks and the creation of a start optional period or a preset execution time for the task to achieve the interaction between the user and the server. The input / output unit may be, but is not limited to, a mouse, a keyboard, etc.

[0087] It can be understood that Figure 4 the structure shown is only schematic, and the electronic device may further include more or fewer components than Figure 4 shown, or have the same asFigure 4 The different configurations shown. Figure 4 Each component shown in can be implemented by hardware, software, or a combination thereof.

[0088] The embodiments of the present application also provide a storage medium, on which instructions are stored. When the instructions are run on a computer, the computer program, when executed by a processor, implements the method described in the method embodiments. To avoid repetition, it will not be elaborated here.

[0089] The present application also provides a computer program product, which, when run on a computer, causes the computer to execute the method described in the method embodiments.

[0090] In several embodiments provided by the present application, it should be understood that the disclosed apparatus and method can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the drawings show the possible architectures, functions, and operations of apparatuses, methods, and computer program products according to multiple embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order from that marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0091] In addition, in each embodiment of the present application, the various functional modules can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.

[0092] When the above-mentioned functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs.

[0093] The above are only the embodiments of this application and are not used to limit the protection scope of this application. For those skilled in the art, this application can have various changes and modifications. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of this application shall be included in the protection scope of this application. It should be noted that similar reference numerals and letters indicate similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.

[0094] The above is only the specific implementation manner of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed by this application and should be covered by the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.

[0095] It should be noted that in this text, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such a process, method, article or device. Without further limitations, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the said element.

Claims

1. A primary / backup switching method, characterized in that, The method is applied to a standby machine in a dual-machine system, and the standby machine is a load balancing device. The method includes: When receiving a primary-standby switching signal, set the status of all servers to an unknown status, and assign values to the flag bits of the corresponding servers according to the types of referenced health checks; After switching to the primary machine, check the flag bits of each server. If the value of the flag bit is a non-default value, use the target detection parameters corresponding to the value of the flag bit to perform a health check on the server. If the value of the flag bit is the default value, use the basic detection parameters to perform a health check on the server; the detection period of the target detection parameters is shorter than that of the basic detection parameters, and / or the upper limit of the number of detection times of the target detection parameters is lower than that of the basic detection parameters; Set the status of the server according to the health check result, and set the flag bits of each server to the default value.

2. The method according to claim 1, wherein The assigning values to the flag bits of the corresponding servers according to the types of referenced health checks includes: If the referenced health check is a TCP health check, assign the first value to the flag bit of the corresponding server; If the referenced health check is an ICMP health check, assign the second value to the flag bit of the corresponding server; If the referenced health check is an HTTP health check, assign the third value to the flag bit of the corresponding server.

3. The method according to claim 2, wherein The default value is 0, the first value is 1, the second value is 2, and the third value is 3.

4. The method according to claim 1, wherein The detection period of the target detection parameters is 1 second or 2 seconds, and the upper limit of the number of detection times is 2 times.

5. The method according to claim 1, wherein The setting the status of the server according to the health check result includes: When a correct check result is not received for the detection request, wait for one detection period and then perform the next detection. If the upper limit of the number of detection times is reached, set the status of the server to an abnormal status; When a correct check result is received for the detection request, set the status of the server to a normal status.

6. The method according to claim 5, wherein The method further includes: Report the information of the faulty server, where the faulty server is the server in the abnormal status.

7. A main-standby switching device, characterized in that, The device is applied to a standby machine in a dual-machine system, and the standby machine is a load balancing device. The device includes: An assignment module, configured to set the status of all servers to an unknown status when receiving a primary-standby switching signal, and assign values to the flag bits of the corresponding servers according to the types of referenced health checks; An inspection module, configured to check the flag bits of each server after switching to the primary machine. If the value of the flag bit is a non-default value, use the target detection parameters corresponding to the value of the flag bit to perform a health check on the server. If the value of the flag bit is the default value, use the basic detection parameters to perform a health check on the server; the detection period of the target detection parameters is shorter than that of the basic detection parameters, and / or the upper limit of the number of detection times of the target detection parameters is lower than that of the basic detection parameters; A setting module, configured to set the status of the server according to the health check result, and set the flag bits of each server to the default value.

8. A computer program product, characterized in that, When the computer program product runs on a computer, it causes the computer to execute the method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

10. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Master-slave switching method and device

    CN106656617A