A method for switching between active and standby application layer services based on BFD and domain name resolution

By introducing BFD and domain name resolution into the active-standby switching technology, creating a state machine and quickly detecting network faults, it solves the problems of long active-standby switching time and brain splitting in the existing technology, and achieves fast and reliable active-standby switching.

CN115941448BActive Publication Date: 2025-01-24CHINA TELECOM CLOUD TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211460350.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-17
Publication Date
2025-01-24
Estimated Expiration
2042-11-17

AI Technical Summary

Technical Problem

The existing master-support switching technology takes a long time to switch between master and backup, requires additional LAN IP to be used as virtual IP, and is prone to split brain problems.

Method used

An application layer service active-standby switching method based on BFD and domain name resolution is adopted to quickly detect network failures between nodes by creating a state machine and using dynamic BFD sessions to achieve fast active-standby switching, and complete the switch through domain name resolution A records.

Benefits of technology

The fast fault detection and main switching are realized, the switching time is shortened, the reliability and service quality of the network is improved, and the phenomenon of brain cracking is prevented.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115941448B_ABST
    Figure CN115941448B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for switching between active and standby application layer services based on BFD and domain name resolution, and relates to the technical field of application layer services. The method for switching between active and standby application layer services based on BFD and domain name resolution includes creating protocol messages including notification messages and election messages, and constructing a state machine including Init state, Backup state, Candidate state and Master state. A dynamic BFD session is used to quickly detect network failures between nodes, and active and standby switching is completed by adding a domain name resolution A record. The method has a standardized fast fault detection mechanism that is independent of the medium and upper layer protocol, and the fault detection time is much less than 1 second. The method can accelerate network convergence faster, reduce the interruption time of upper layer applications, and improve network reliability and service quality. In the process of active and standby switching, a DNS node broadcast protocol message is added, and the node actively detects the DNS process to prevent brain splitting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of application layer services, and in particular to a method for switching between active and standby application layer services based on BFD and domain name resolution. Background Art

[0002] The master-slave mode is a mode for building high-availability services. In this mode, the master server in the cluster is responsible for processing responses. When the master server fails, it switches to the backup server to process messages. Currently, commonly used high-availability software includes keepalived, etc. High-availability software such as keepalived implements service switching through Virtual Router Redundancy Protocol (VRRP) and virtual IP. The virtual IP is configured on the master node, and the master node and the backup node interact periodically through heartbeat messages. When the heartbeat is interrupted, the backup node considers the master node unavailable, and the backup nodes elect each other based on priority. The node that succeeds in the election configures the virtual IP and sends a free ARP to the LAN, informing that the corresponding MAC address of the virtual IP is the backup node MAC. When subsequent messages access the virtual IP, the messages will be forwarded to the backup node.

[0003] When this method is used for active / standby switching, the active node and the standby node need to work in the same LAN, and an additional LAN IP is required as a virtual IP. In addition, since the heartbeat period in the VRRP protocol is specified as a positive integer greater than 1 second, the active / standby switching time is in seconds, which makes it difficult to shorten the active / standby switching time. If the arbitration mechanism is not introduced, the failure of the heartbeat line between the active and standby nodes will also cause brain splits, resulting in competition for virtual IPs. Summary of the invention

[0004] In view of the deficiencies of the prior art, the present invention provides an application layer service active-standby switching method based on BFD and domain name resolution, which solves the problem of long active-standby switching time and the need for additional LAN IP as a virtual IP.

[0005] To achieve the above objectives, the present invention is implemented through the following technical solutions: a method for switching between active and standby application layer services based on BFD and domain name resolution, comprising the following steps:

[0006] Create protocol messages including notification messages and election messages, and build a state machine including Init state, Backup state, Candidate state and Master state;

[0007] The Init state changes to the Backup state or the Candidate state depending on whether the Master notification is received;

[0008] The Backup state changes to the Candidate state if no notification is received from the master or the BFD session is interrupted;

[0009] After the Candidate state is successfully elected, it will be converted to the Master state;

[0010] The Master state changes to the Backup state after receiving a notification from the master;

[0011] The Backup state, Candidate state, and Master state are converted to the Init state after receiving the shutdown signal.

[0012] Furthermore, the Init state is an initialization state, and the processing flow is as follows:

[0013] Establish BFD sessions with all nodes;

[0014] After receiving the master notification, the state is transferred to the Backup state;

[0015] If no master notification is received within the timeout period, the state is transferred to the Candidate state and a master election message is sent.

[0016] Furthermore, the Master state is the master node state, and the processing flow is as follows:

[0017] Send master notification messages regularly;

[0018] Regularly check the domain name A record of the DNS server;

[0019] When receiving the master notification message, the state is transferred to the Backup state;

[0020] When all BFD sessions are disconnected and the network with the DNS node is disconnected, the state is transferred to the Backup state;

[0021] Upon receiving the shutdown signal, the state is transferred to the Init state.

[0022] Furthermore, the Backup state is a standby state, and the processing flow is as follows:

[0023] If no master notification is received within the timeout period, the state is transferred to the Candidate state;

[0024] The BFD session of the master node is detected to be interrupted, and the state is transferred to the Candidate state;

[0025] After receiving other election messages, the state is transferred to the Candidate state.

[0026] Furthermore, the Candidate state is a campaign state, and the processing flow is as follows:

[0027] Continue to send campaign messages until timeout;

[0028] If no master election message that takes precedence over this node according to the comparison rule is received within the timeout period, the state is transferred to the Master state, a master notification is sent, and the DNS server A record is changed;

[0029] If a master election message that takes precedence over this node according to the comparison rule is received within the timeout period, the state is transferred to the Backup state;

[0030] If the master notification message is received within the timeout period, the state is transferred to the Backup state;

[0031] Upon receiving the shutdown signal, the state is transferred to the Init state.

[0032] Furthermore, the protocol message also includes version, authentication mode, type, priority, number of surviving BFD sessions, source IP, destination IP, notification interval, checksum, and authentication data.

[0033] Furthermore, the protocol message is encapsulated in the UDP protocol and has a length of more than 16 bytes.

[0034] An application layer service active / standby switching system based on BFD and domain name resolution includes a Node node and a DNS node node, wherein:

[0035] The Node node is in the same node as the service that maintains the primary and backup nodes, and is responsible for maintaining the state machine;

[0036] The DNS node is responsible for broadcasting master notifications and election messages to all nodes, logically forming a second heartbeat line between the master and backup nodes, and serving as a benchmark for the Node node to determine whether the connection is lost.

[0037] Furthermore, there are two UDP protocol-based network channels between the Node nodes, one for BFD session connection, and the other for controlling the transmission of notification messages and election messages.

[0038] Furthermore, there is a channel based on HTTP protocol between the Node and the DNS node, which is used for the Node node to call the interface to send the changed DNS, and another channel based on UDP is used for the DNS to receive and forward control messages.

[0039] The present invention has the following beneficial effects:

[0040] Dynamic BFD sessions are used to quickly detect network failures between nodes, and active-standby switching is completed by adding domain name resolution A records. It has a standardized fast fault detection mechanism that is independent of the medium and upper-layer protocols. The fault detection time is much less than 1 second, which can accelerate network convergence more quickly, reduce the interruption time of upper-layer applications, and improve network reliability and service quality. In the process of active-standby switching, DNS node broadcast protocol messages are added, and the nodes actively detect the DNS process to prevent brain splits.

[0041] Of course, any product implementing the present invention does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 It is the state transition diagram of the present invention;

[0043] Figure 2 This is the Init state processing flow chart of the present invention;

[0044] Figure 3 This is a master state processing flow chart of the present invention;

[0045] Figure 4 This is a flowchart of the backup state processing of the present invention;

[0046] Figure 5 This is a candidate state processing flow chart of the present invention;

[0047] Figure 6 This is a schematic diagram of the protocol message format of the present invention;

[0048] Figure 7 It is a system structure diagram of the present invention;

[0049] Figure 8 It is a schematic diagram of an embodiment of the present invention. DETAILED DESCRIPTION

[0050] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0051] In the description of the present invention, it should be understood that the terms "opening", "upper", "lower", "thickness", "top", "middle", "length", "inside", "all around" and the like indicating orientation or positional relationship are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the components or elements referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.

[0052] See also Figure 1-Figure 8 The embodiment of the present invention provides a technical solution: a method for switching between active and standby application layer services based on BFD and domain name resolution, comprising the following steps:

[0053] Create protocol messages including notification messages and election messages, and build a state machine including Init state, Backup state, Candidate state, and Master state;

[0054] The Init state is converted to the Backup state or the Candidate state depending on whether the master notification is received;

[0055] The Backup state changes to the Candidate state if no notification is received from the master or the BFD session is interrupted;

[0056] After the Candidate state is successfully elected, it will be converted to the Master state;

[0057] The Master state changes to the Backup state after receiving a notification from the master;

[0058] The Backup state, Candidate state, and Master state are converted to the Init state after receiving the shutdown signal.

[0059] like Figure 1 As shown, the Init state, Backup state, Candidate state and Master state constitute the node state machine, where the Init state is the initialization state, the Master state is the main node state, the Backup state is the standby state, and the Candidate state is the election state.

[0060] Specifically, the Init state is an initialization state, and the processing flow is as follows:

[0061] Establish BFD sessions with all nodes;

[0062] After receiving the master notification, the state is transferred to the Backup state;

[0063] If no master notification is received within the timeout period, the state is transferred to the Candidate state and a master election message is sent.

[0064] In this embodiment, if Figure 2 As shown, when in the Init state, the following work will be done:

[0065] First, a BFD session is established with all nodes. When it receives a master notification, it changes its state to the Backup state. If it does not receive a master notification within the timeout period, it changes its state to the Candidate state and sends a master election message.

[0066] Specifically, the Master state is the master node state, and the processing flow is as follows:

[0067] Send master notification messages regularly;

[0068] Regularly check the domain name A record of the DNS server;

[0069] When receiving the master notification message, the state is transferred to the Backup state;

[0070] When all BFD sessions are disconnected and the network with the DNS node is disconnected, the state is transferred to the Backup state;

[0071] After receiving the shutdown signal, the state is transferred to the Init state.

[0072] In this embodiment, if Figure 3 As shown in the figure, when in the Master state, the following work will be done:

[0073] It sends master notification messages regularly and checks the domain name A record of the DNS server regularly. When it receives a master notification message, it transfers the state to the Backup state. When all BFD sessions are interrupted and the network with the DNS node is disconnected, it transfers the state to the Backup state. If it receives a shutdown signal, it transfers the state to the Init state.

[0074] Specifically, the Backup state is a standby state, and the processing flow is as follows:

[0075] If no master notification is received within the timeout period, the state is transferred to the Candidate state;

[0076] The BFD session of the master node is detected to be interrupted, and the state is transferred to the Candidate state;

[0077] After receiving other election messages, the state is transferred to the Candidate state.

[0078] In this embodiment, if Figure 4 As shown in the figure, when in the Backup state, the following work will be performed in this state:

[0079] If no master notification is received within the timeout period, the state is transferred to the Candidate state. In addition, if the BFD session of the master node is detected to be interrupted, the state is also transferred to the Candidate state. After receiving other election messages, the state is transferred to the Candidate state.

[0080] Specifically, the Candidate state is a campaign state, and the processing flow is as follows:

[0081] Continue to send campaign messages until timeout;

[0082] If no master election message that takes precedence over this node according to the comparison rule is received within the timeout period, the state is transferred to the Master state, a master notification is sent, and the DNS server A record is changed;

[0083] If a master election message that takes precedence over this node according to the comparison rule is received within the timeout period, the state is transferred to the Backup state;

[0084] If the master notification message is received within the timeout period, the state is transferred to the Backup state;

[0085] Upon receiving the shutdown signal, the state is transferred to the Init state.

[0086] In this embodiment, if Figure 5 As shown, when in the Candidate state, it continues to send election messages until timeout. If it does not receive a master election message that takes precedence over this node according to the comparison rule within the timeout period, it will transfer its state to the Master state and send a master notification, and change the DNS server A record. If it receives a master election message that takes precedence over this node according to the comparison rule within the timeout period, it will transfer its state to the Backup state. If it receives a master notification message within the timeout period, it will transfer its state to the Backup state. If it receives a shutdown signal, it will transfer its state to the Init state.

[0087] The protocol message also includes version, authentication mode, type, priority, number of surviving BFD sessions, source IP, destination IP, notification interval, checksum, authentication data

[0088] The protocol message is encapsulated in the UDP protocol and has a length of more than 16 bytes.

[0089] In this embodiment, if Figure 6 As shown in the figure, the protocol message format mainly includes version, authentication mode, type, priority, number of live BFD sessions, source IP, destination IP, notification interval, checksum, and authentication data. The message is encapsulated in the UDP protocol and has a length of more than 16 bytes, including:

[0090] The version length is 8 bits. Currently, there is only one defined available version number, and the data is 1.

[0091] The authentication mode is 4 bits long, indicating the authentication method. Currently, only if authentication is not used, the data is 1;

[0092] The type length is 4 bits, 1 represents a notice message, 2 represents a campaign message;

[0093] The priority length is 8 bits, and the supported range is 0 to 255. The priority can be set through node configuration, and the default is a random number between 0 and 255;

[0094] The number of surviving BFD sessions is 8 bits, ranging from 0 to 255. The protocol supports a maximum cluster range of 255. The protocol includes this field to favor nodes with larger surviving BFD connections during active / standby switchover.

[0095] The source IP and destination IP are 32-bit IPv4 addresses;

[0096] The notification interval is 16 bits in milliseconds, ranging from 0 to 65535ms.

[0097] Checksum is 16 bits long and is the check value.

[0098] Authentication data, variable length, used for authentication.

[0099] An application layer service active / standby switching system based on BFD and domain name resolution includes a Node node and a DNS node node, wherein:

[0100] The Node node is in the same node as the service that maintains the primary and backup nodes, and is responsible for maintaining the state machine;

[0101] The DNS node is responsible for broadcasting master notifications and election messages to all nodes, logically forming a second heartbeat line between the master and backup nodes, and serving as a benchmark for the Node node to determine whether the connection is lost.

[0102] Specifically, there are two UDP-based network channels between the Node nodes, one for BFD session connection and the other for controlling the transmission of notification messages and election messages;

[0103] There is a channel based on HTTP protocol between the Node and the DNS node, which is used for the Node node to call the interface to send the changed DNS, and another channel based on UDP is used for the DNS to receive and forward control messages.

[0104] In this embodiment, if Figure 7 As shown, the system nodes include Node nodes and DNS node nodes. The Node node is on the same node as the service that maintains the master and backup nodes and is responsible for maintaining the state machine. The DNS node node is responsible for broadcasting master notifications and election messages to all nodes, logically forming the second heartbeat line between the master and backup nodes, and serving as a benchmark for the Node node to determine whether the connection is lost.

[0105] When the connection between the Master state and the Backup state is lost, if the network to the DNS node is normal, the Master state can still maintain this state, and the Backup state node can also receive the master's notification and maintain the Backup state. The master-slave switch will only occur when the Master state node is disconnected from the Backup state and DNS at the same time. This processing method prevents the occurrence of brain split to a certain extent. The DNS node is also responsible for adding A records to the local DNS service to map the domain name to the master's IP address.

[0106] There are two UDP-based network channels between nodes, one for BFD session connection and the other for control message (notification, election) transmission. There is a HTTP-based channel between the node and the DNS node, which is used for the node to call the interface to send DNS changes, and the other UDP-based channel is used for DNS to receive and forward control messages.

[0107] Figure 8 This is a schematic diagram of the system structure deployment of the embodiment:

[0108] Start the process:

[0109] Start the nodes in the order of DNS node, node1, node2, and node3. After the above order is adopted, node1 becomes the master node, and node2 and 3 become backup nodes. The DNS domain name resolution points to node1.

[0110] The master-slave switching process (the heartbeat between nodes is disconnected, and the node does not send a master notification during the election period):

[0111] Step 1: Assume that the network between node1 and 2 is disconnected. At this time, node2 detects that the BFD session to the master is disconnected and sends a campaign message to all nodes.

[0112] Step 2: After receiving the election message, other nodes enter the candidate state and send election messages.

[0113] Step 3: Since node2 has only one surviving BFD connection, node3 succeeds in the election and becomes the master node.

[0114] Step 4: node3 sends a request to the DNS node and changes the A record so that the resolved IP address is the IP address of node3.

[0115] Step 5: After node1 receives the master notification from node3, its status changes from master to backup.

[0116] Step 6: After node2 receives the master notification from node3, its status changes from candidate to backup.

[0117] The process of active / standby switching (heartbeat disconnection between nodes, nodes sending master notifications during the election period):

[0118] Step 1: Assume that the network between node1 and 2 is disconnected. At this time, node2 detects that the BFD session to the master is disconnected and sends a campaign message to all nodes.

[0119] Step 2: After receiving the election message, other nodes enter the candidate state and send election messages.

[0120] Step 3: The master node sends a master notification message to all nodes.

[0121] Step 4: After receiving the master notification, the status of node2 and 3 changes from candidate to backup.

[0122] The master-slave switching process (the node is completely disconnected, and the node sends a master notification during the election period):

[0123] Step 1: Assume that node1 is completely disconnected. At this time, node2 detects that the BFD session to the master is disconnected and sends a campaign message to all nodes.

[0124] Step 2: After receiving the election message, other nodes enter the candidate state and send election messages.

[0125] Step 3: Since the number of surviving BFD connections of nodes 2 and 3 is equal, node 2 has a higher priority and succeeds in the election to become the master node.

[0126] Step 4: node2 sends a request to the DNS node and changes the A record so that the resolved IP address is the IP address of node2.

[0127] Step 5: After node2 receives the master notification from node3, its status changes from candidate to backup.

[0128] Step 6: Node1 finds that all BFD sessions are disconnected and the DNS network is unreachable, so it changes the state from master to backup.

[0129] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0130] The preferred embodiments of the present invention disclosed above are only used to help illustrate the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well. The present invention is limited only by the claims and their full scope and equivalents.

Claims

1. A method for switching between active and standby application layer services based on BFD and domain name resolution, characterized in that: The following steps are involved: Create protocol messages including notification messages and election messages, and build a state machine including Init state, Backup state, Candidate state, and Master state; The Init state is converted to the Backup state or the Candidate state depending on whether the master notification is received; The Backup state changes to the Candidate state if no notification is received from the master or the BFD session is interrupted; After the Candidate state is successfully elected, it will be converted to the Master state; The Master state changes to the Backup state after receiving a notification from the master; The Backup state, Candidate state, and Master state are converted to the Init state after receiving the shutdown signal; Among them, the Master state is the master node state, and the processing flow is as follows: Send master notification messages regularly; Regularly check the domain name A record of the DNS server; When receiving the master notification message, the state is transferred to the Backup state; When all BFD sessions are disconnected and the network with the DNS node is disconnected, the state is transferred to the Backup state; After receiving the shutdown signal, the state is transferred to the Init state.

2. According to claim 1, a method for switching between active and standby application layer services based on BFD and domain name resolution, characterized in that: The Init state is the initialization state, and the processing flow is as follows: Establish BFD sessions with all nodes; After receiving the master notification, the state is transferred to the Backup state; If no master notification is received within the timeout period, the state is transferred to the Candidate state and a master election message is sent.

3. The method for switching between active and standby application layer services based on BFD and domain name resolution according to claim 1, characterized in that: The Backup state is a standby state, and the processing flow is as follows: If no master notification is received within the timeout period, the state is transferred to the Candidate state; The master node detects that the BFD session is interrupted and the state changes to the Candidate state; After receiving other election messages, the state is transferred to the Candidate state.

4. The method for switching between active and standby application layer services based on BFD and domain name resolution according to claim 1, characterized in that: The Candidate state is a campaign state, and the processing flow is as follows: Continue to send campaign messages until timeout; If no master election message that takes precedence over this node according to the comparison rule is received within the timeout period, the state is transferred to the Master state, a master notification is sent, and the DNS server A record is changed; If a master election message that takes precedence over this node according to the comparison rule is received within the timeout period, the state is transferred to the Backup state; If the master notification message is received within the timeout period, the state is transferred to the Backup state; After receiving the shutdown signal, the state is transferred to the Init state.

5. The method for switching between active and standby application layer services based on BFD and domain name resolution according to claim 1, characterized in that: The protocol message also includes version, authentication mode, type, priority, number of surviving BFD sessions, source IP, destination IP, notification interval, checksum, and authentication data.

6. The method for switching between active and standby application layer services based on BFD and domain name resolution according to claim 1, characterized in that: The protocol message is encapsulated in the UDP protocol and has a length of more than 16 bytes.

7. An application layer service active / standby switching system based on BFD and domain name resolution, characterized in that: Including Node nodes and DNS node nodes, where: The Node node is in the same node as the service that maintains the primary and backup nodes, and is responsible for maintaining the state machine; The DNS node is responsible for broadcasting master notifications and election messages to all nodes, logically forming a second heartbeat line between the master and standby nodes, and serving as a benchmark for the Node node to determine loss of connection; Create protocol messages including notification messages and election messages, and build a state machine including Init state, Backup state, Candidate state, and Master state; The Init state is converted to the Backup state or the Candidate state depending on whether the master notification is received; The Backup state changes to the Candidate state if no notification is received from the master or the BFD session is interrupted; After the Candidate state is successfully elected, it will be converted to the Master state; The Master state changes to the Backup state after receiving a notification from the master; The Backup state, Candidate state, and Master state are converted to the Init state after receiving the shutdown signal; Among them, the Master state is the master node state, and the processing flow is as follows: Send master notification messages regularly; Regularly check the domain name A record of the DNS server; When receiving the master notification message, the state is transferred to the Backup state; When all BFD sessions are disconnected and the network with the DNS node is disconnected, the state is transferred to the Backup state; After receiving the shutdown signal, the state is transferred to the Init state; The Candidate state is a campaign state, and the processing flow is as follows: Continue to send campaign messages until timeout; If no master election message that takes precedence over this node according to the comparison rule is received within the timeout period, the state is transferred to the Master state, a master notification is sent, and the DNS server A record is changed; If a master election message that takes precedence over this node according to the comparison rule is received within the timeout period, the state is transferred to the Backup state; If the master notification message is received within the timeout period, the state is transferred to the Backup state; After receiving the shutdown signal, the state is transferred to the Init state; There are two UDP-based network channels between the Node nodes, one for BFD session connection and the other for controlling the transmission of notification messages and election messages. There is a channel based on HTTP protocol between the Node and the DNS node, which is used for the Node node to call the interface to send the changed DNS, and another channel based on UDP is used for the DNS to receive and forward control messages.

Citation Information

Patent Citations

  • Switching method and router

    CN102447615A