Node election method and system and node replacement method and system

By receiving the TCP packet loss rate and delay information of the node to be selected on the fake central node, setting priority, and quickly determining the primary node and backup node, the node election algorithm in the existing technology has large storage and slow traffic and slow speed. , The problem of poor stability has achieved efficient node elections and data consistency.

CN119094307APending Publication Date: 2024-12-06SHANGHAI LIANGXUN IOT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411166008.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

The existing node election algorithm has problems such as heavy storage burden, large communication volume, slow election speed, poor stability, high algorithm complexity and weak response capabilities to failures, making it difficult to effectively ensure data consistency.

Method used

Using the node election method based on fake center nodes, by receiving the TCP packet loss rate and delay information of the nodes to be selected, setting priority, quickly determining the primary and backup nodes, reducing storage and communication requirements, and optimizing the election through the timer mechanism process to ensure the stability and responsiveness of election results.

Benefits of technology

Reduces storage and communication burden, improves election speed and stability, simplifies algorithm complexity, enhances response to failures, and ensures data consistency and high system availability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119094307A_ABST
    Figure CN119094307A_ABST
Patent Text Reader

Abstract

The invention relates to a node election method and system in a distributed system, and aims to improve node election efficiency and system stability. According to the method, a priority list of nodes to be selected is received through a false center node, and priority setting and sorting are carried out based on a TCP packet loss rate and time delay, so that a main center node and a standby center node with optimal network performance are quickly selected. And an election timer mechanism is introduced, so that invalid election is avoided, and the real-time performance of an election result is ensured. Meanwhile, when the main node is disconnected, the standby node can take over tasks quickly, and continuous operation of the system is guaranteed. In addition, the system further comprises a node replacement method, and the high availability and the fault-tolerant capability of the system are further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of Internet of Things communication technology, and in particular relates to a node election method and system and a node replacement method and system. Background Art

[0002] A distributed system consists of multiple nodes that are interconnected through a network and work together to provide services. Each node may play different roles, such as master node, slave node, or observer.

[0003] In distributed systems, node election is a key mechanism to ensure high availability and consistency. The election algorithm determines which node will assume the responsibility of the master node.

[0004] Existing election algorithms:

[0005] Bully algorithm: elections are based on the size of node IDs, which may lead to frequent re-elections and storage of a large amount of global information.

[0006] Raft algorithm: Based on the majority voting mechanism, it requires extensive communication between nodes, which may result in large communication volume.

[0007] ZAB algorithm: combines node ID and data ID to improve data consistency, but the algorithm is complex and may lead to long election time and broadcast storms.

[0008] There is currently a lack of a lightweight node election method. Summary of the invention

[0009] The technical problem to be solved by the present invention is to provide a node election method and system and a node replacement method and system in view of the deficiencies in the above-mentioned prior art, aiming to solve the problems existing in the existing algorithms, such as heavy storage burden, large communication volume, slow election speed, poor stability, high algorithm complexity, weak fault response capability, and difficulty in ensuring data consistency.

[0010] The first aspect of the present invention discloses a node election method, which is applied to a fake central node, comprising: the fake central node receives a candidate priority list sent from each candidate node, and records the TCP packet loss rate and delay of each candidate node;

[0011] The fake central node temporarily sets the priority of the candidate node with a TCP packet loss rate of 0% to G, and sets the priority of the candidate node with a TCP packet loss rate of not 0% to H, where G is the smallest value among the priority values, and H is the largest value among the priority values. The priority range is G-H, and both G and H are integers.

[0012] The fake central node will re-order the candidate nodes with a temporary priority of G according to the delay from small to large. According to the order, the final priority of the candidate node with the smallest delay is G;

[0013] The candidate node with the final priority of G is configured as the main central node, and the candidate node with the final priority of G+1 is configured as the backup central node.

[0014] In the above node election method, the fake central node is configured with an election timer;

[0015] When a round of timer cycle expires, if the TCP packet loss rate of all candidate nodes is not 0%, the fake central node clears the candidate priority lists sent by all candidate nodes received within this round of timer cycle, resets the election timer, and starts the next round of timer cycle.

[0016] In the above node election method, before a round of timer period expires, the fake central node continues to receive the candidate priority list sent from each candidate node, and records the TCP packet loss rate and delay of each candidate node;

[0017] When a round of timer period expires and there is no situation where the TCP packet loss rate of all candidate nodes is not 0%, the fake central node calculates the final priority of each candidate node.

[0018] In the above node election method, when the fake central node calculates the final priority of each candidate node, if the main central node and the backup central node already exist, the fake central node will temporarily set the candidate nodes with priority G to be re-sorted from small to large according to the latency. According to the sorting, the final priority of the candidate node with the smallest latency is G+2.

[0019] The second aspect of the present invention discloses a node election system, comprising a fake central node, wherein the fake central node is configured to: receive a candidate priority list sent from each candidate node, and record the TCP packet loss rate and delay of each candidate node;

[0020] The fake central node temporarily sets the priority of the candidate node with a TCP packet loss rate of 0% to G, and sets the priority of the candidate node with a TCP packet loss rate of not 0% to H, where G is the smallest value among the priority values, and H is the largest value among the priority values. The priority range is G-H, and both G and H are integers.

[0021] The fake central node will re-order the candidate nodes with a temporary priority of G according to the delay from small to large. According to the order, the final priority of the candidate node with the smallest delay is G;

[0022] The candidate node with the final priority of G is configured as the main central node, and the candidate node with the final priority of G+1 is configured as the backup central node.

[0023] The third aspect of the present invention discloses a node replacement method, which completes the election of a main central node and a backup central node based on the node election method described in the first aspect;

[0024] The main central node is configured to periodically send its own priority list to be selected to the fake central node;

[0025] When the fake central node does not receive the priority list of candidates from the main central node within the specified time, the main central node is marked as disconnected, and the fake central node sends the pending tasks to the backup central node for processing;

[0026] The fake central node starts a timer with a timing period of N waiting cycles. If the priority list to be selected from the main central node is not received within N waiting cycles, the backup central node is configured as the main central node and N is reset;

[0027] When the candidate priority list of the main central node is received within N waiting cycles, N is set to N-1.

[0028] In the above node replacement method, the backup central node is configured to periodically send its own priority list to be selected to the fake central node;

[0029] When both the primary central node and the backup central node are marked as disconnected, the node election method is re-executed to complete the election of the primary central node and the backup central node.

[0030] In the above node replacement method, when the backup central node is configured as the main central node, the candidate node with a priority of G+2 is configured as the backup central node.

[0031] In the above node replacement method, when the backup central node is configured as the main central node, the priorities of all candidate nodes are reduced by 1.

[0032] A fourth aspect of the present invention discloses a node replacement system, comprising a fake central node, wherein the fake central node is configured to: complete the election of a main central node and a backup central node based on the node election method described in the first aspect;

[0033] The main central node is configured to periodically send its own priority list to be selected to the fake central node;

[0034] When the fake central node does not receive the priority list of candidates from the main central node within the specified time, the main central node is marked as disconnected, and the fake central node sends the pending tasks to the backup central node for processing;

[0035] The fake central node starts a timer with a timing period of N waiting cycles. If the priority list to be selected from the main central node is not received within N waiting cycles, the backup central node is configured as the main central node and N is reset;

[0036] When the candidate priority list of the main central node is received within N waiting cycles, N is set to N-1.

[0037] Compared with the prior art, the present invention has the following advantages:

[0038] 1. Reduce storage burden: This solution does not require each node to store global information about all other nodes, but only records TCP packet loss rate and latency, which reduces storage requirements.

[0039] 2. Reduce the frequency of re-election: By giving the highest priority to nodes with a TCP packet loss rate of 0%, the re-election triggered by the addition of new nodes or node failure recovery is reduced.

[0040] 3. Reduce communication volume: In this scheme, nodes do not need to communicate extensively to obtain information from all other nodes. They only need to send and receive data about packet loss rate and latency, thereby reducing the communication volume.

[0041] 4. Speed ​​up the election: The priority and delay sorting mechanism allows the master node and backup node to be quickly determined, avoiding complex voting and comparison processes and speeding up the election.

[0042] 5. Avoid broadcast storms: Since there is no need to broadcast a large amount of voting information, this solution avoids network storms caused by broadcasts.

[0043] 6. Improve election stability: By giving priority to network quality (TCP packet loss rate and latency) when electing nodes, this solution improves the stability of election results.

[0044] 7. Simplify algorithm complexity: The priority setting and sorting mechanism of this scheme is relatively simple, which reduces the complexity of the algorithm and makes it easier to understand and implement.

[0045] 8. Enhanced response capability to failures: By setting up a backup central node, the solution enhances the response capability to failures of the primary node and ensures high availability of the system.

[0046] 9. Ensure data consistency: By selecting the node with the best network performance as the master node, this solution helps reduce synchronization delays caused by network problems, thereby helping to maintain data consistency.

[0047] 10. Avoid dependence on specific conditions: This solution does not rely on specific conditions such as odd number of nodes, providing greater flexibility and scalability.

[0048] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 The figure is a flow chart of the node election method of the present invention.

[0050] Figure 2 The present invention is a flowchart of the node replacement method. DETAILED DESCRIPTION

[0051] like Figure 1 As shown, a node election method is applied to a fake central node, comprising: the fake central node receives a candidate priority list sent from each candidate node, and records the TCP packet loss rate and delay of each candidate node;

[0052] The fake central node temporarily sets the priority of the candidate node with a TCP packet loss rate of 0% to G, and sets the priority of the candidate node with a TCP packet loss rate of not 0% to H, where G is the smallest value among the priority values, and H is the largest value among the priority values. The priority range is G-H, and both G and H are integers.

[0053] The fake central node will re-order the candidate nodes with a temporary priority of G according to the delay from small to large. According to the order, the final priority of the candidate node with the smallest delay is G;

[0054] The candidate node with the final priority of G is configured as the main central node, and the candidate node with the final priority of G+1 is configured as the backup central node.

[0055] In actual implementation, G is 0, H is 255, there can be only one main central node, and there can be multiple backup central nodes (no more than 255). The smaller the priority value, the higher the priority.

[0056] In the initial stage, all candidate nodes are started as the main central node by default, so their priority in the candidate priority list is set to 0, and all other candidate nodes (in the initial stage, the candidate node is allowed to preset the information of other candidate nodes. If there is no preset, the other candidate node information of the node is empty) are set to 255.

[0057] The advantage of using TCP as the transmission protocol is that the protocol is based on the connection status. The success rate and delay of TCP connection establishment can evaluate the node's ability to handle the TCP protocol and objectively reflect the node's resource utilization status. It has indicative significance for evaluating the quality of communication between subsequent candidate nodes and the fake central node. For this reason, the fake central node will open the TCP special port for listening when it starts.

[0058] By considering TCP packet loss rate and delay, this method optimizes the node election process and ensures that the selected nodes have good network performance.

[0059] Prioritizing nodes with a TCP packet loss rate of 0% as master nodes helps improve the stability of the entire distributed system.

[0060] By setting the priorities G and H, the network quality of the candidate nodes can be quickly distinguished, thus speeding up the election decision.

[0061] In this embodiment, the fake central node is configured with an election timer;

[0062] When a round of timer cycle expires, if the TCP packet loss rate of all candidate nodes is not 0%, the fake central node clears the candidate priority list sent by all candidate nodes received within this round of timer cycle, resets the election timer, starts the next round of timer cycle, re-records, and then calculates. This process is repeated until the priority of each candidate node is determined.

[0063] When the TCP packet loss rate of all candidate nodes is not 0%, the candidate priority list is cleared and the timer is reset to avoid invalid elections based on low-quality nodes.

[0064] In this embodiment, before a round of timer cycle expires, the fake central node continues to receive the candidate priority list sent from each candidate node, and records the TCP packet loss rate and delay of each candidate node; when a round of timer cycle expires, and there is no situation where the TCP packet loss rate of all candidate nodes is not 0%, the fake central node calculates the final priority of each candidate node.

[0065] The status of the candidate nodes is continuously received and recorded within the timer period to ensure that the election is based on the latest data, thus improving the accuracy of the election.

[0066] In this embodiment, when the fake central node calculates the final priority of each candidate node, if the main central node and the backup central node already exist, the fake central node will temporarily set the candidate nodes with a priority of G and reorder them from small to large according to the delay. According to the sorting, the final priority of the candidate node with the smallest delay is G+2 (that is, the priority is 2).

[0067] When there are active and standby nodes, the redundancy and fault tolerance of the system are enhanced by adjusting the final priority of the node with priority G.

[0068] Another embodiment of the present invention discloses a node election system, including a fake central node, wherein the fake central node is configured to: receive a candidate priority list sent from each candidate node, and record the TCP packet loss rate and delay of each candidate node;

[0069] The fake central node temporarily sets the priority of the candidate node with a TCP packet loss rate of 0% to G, and sets the priority of the candidate node with a TCP packet loss rate of not 0% to H, where G is the smallest value among the priority values, and H is the largest value among the priority values. The priority range is G-H, and both G and H are integers.

[0070] The fake central node will re-order the candidate nodes with a temporary priority of G according to the delay from small to large. According to the order, the final priority of the candidate node with the smallest delay is G;

[0071] The candidate node with the final priority of G is configured as the main central node, and the candidate node with the final priority of G+1 is configured as the backup central node.

[0072] The technical principles of the node election system and the node election method are the same, and the technical details will not be repeated here.

[0073] like Figure 2 As shown, another embodiment of the present invention discloses a node replacement method, which completes the election of a main central node and a backup central node based on the node election method;

[0074] The main central node is configured to periodically send its own priority list to be selected to the fake central node;

[0075] When the fake central node does not receive the priority list of candidates from the main central node within the specified time, the main central node is marked as disconnected, and the fake central node sends the pending tasks to the backup central node for processing;

[0076] The fake central node starts a timer with a timing period of N waiting cycles. If the priority list to be selected from the main central node is not received within N waiting cycles, the backup central node is configured as the main central node and N is reset;

[0077] When the candidate priority list of the main central node is received within N waiting cycles, N is set to N-1.

[0078] By periodically receiving the priority list of candidates from the master node and transferring the task to the backup node when the master node loses connection, a node replacement mechanism is implemented to ensure the continuous operation of the system.

[0079] It should be noted that when the main central node loses connection, the main central node will not be changed immediately, but will wait for N cycles. If the candidate priority list of the main central node is received again within N cycles, the fake central node believes that the main central node has been "resurrected", but there is also the possibility of "losing connection" again. In order to "punish" it and prevent its repeated "disconnection" from negatively affecting the system, the fake central node sets the N of the main central node to N-1 (N returns to the default value after re-election of the main central node), until N = 0, it means that the fake central node no longer trusts the main central node, so it must immediately reselect the main central node. On the contrary, if the candidate priority list of the main central node is not received within N cycles, the fake central node sets the priority of the backup central node to 0, upgrades it to the main central node, and then takes the candidate node with a priority of 2 from the most recent node election method in which the non-main central node or backup central node participates, sets its priority to 1, and upgrades it to the backup central node. Similarly, the backup central node is configured to periodically send its own priority list of candidates to the fake central node; when the main central node and the backup central node are both marked as lost, the node election method is re-executed to complete the election of the main central node and the backup central node.

[0080] If the main central node and the backup central node simultaneously experience the above-mentioned "disconnection" situation, the fake central node will return to the node election method to determine the identities of the new main central node and the backup central node. As described in the node election method, since the election of other candidate nodes is ongoing, in this case the fake central node does not need to wait for an election cycle, but directly elects the main central node and the backup central node from the results of the previous election, and then publishes all candidate nodes.

[0081] When both the primary node and the backup node lose connection, a re-election is triggered, providing double protection to ensure that the system can quickly resume normal operation.

[0082] When the standby central node is configured as the main central node, the candidate node with a priority of G+2 is configured as the standby central node.

[0083] When the standby node becomes the master node, the node with priority G+2 is selected as the new standby node, which optimizes the standby node selection process and improves the stability of the system.

[0084] When the backup central node is configured as the primary central node, the priorities of all candidate nodes are reduced by 1.

[0085] The subtraction operation simplifies the process of adjusting the priorities of other candidate nodes after the standby node is promoted to the primary node, thereby improving the response speed of the system.

[0086] Another embodiment of the present invention discloses a node replacement system, including a fake central node, wherein the fake central node is configured to: complete the election of a main central node and a backup central node based on the node election method;

[0087] The main central node is configured to periodically send its own priority list to be selected to the fake central node;

[0088] When the fake central node does not receive the priority list of candidates from the main central node within the specified time, the main central node is marked as disconnected, and the fake central node sends the pending tasks to the backup central node for processing;

[0089] The fake central node starts a timer with a timing period of N waiting cycles. If the priority list to be selected from the main central node is not received within N waiting cycles, the backup central node is configured as the main central node and N is reset;

[0090] When the candidate priority list of the main central node is received within N waiting cycles, N is set to N-1.

[0091] The technical principles of the node replacement system and the node replacement method are the same, and the technical details will not be repeated here.

[0092] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any way. Any simple modification, change and equivalent structural change made to the above embodiment based on the technical essence of the present invention still falls within the protection scope of the technical solution of the present invention.

Claims

1. A node election method, characterized in that: The method is applied to a fake central node, comprising: the fake central node receives a candidate priority list sent from each candidate node, and records the TCP packet loss rate and delay of each candidate node; The fake central node temporarily sets the priority of the candidate node with a TCP packet loss rate of 0% to G, and sets the priority of the candidate node with a TCP packet loss rate of not 0% to H, where G is the smallest value among the priority values, and H is the largest value among the priority values. The priority range is G-H, and both G and H are integers. The fake central node will re-order the candidate nodes with a temporary priority of G according to the delay from small to large. According to the order, the final priority of the candidate node with the smallest delay is G; The candidate node with the final priority of G is configured as the main central node, and the candidate node with the final priority of G+1 is configured as the backup central node.

2. A node election method according to claim 1, characterized in that: The fake central node is configured with an election timer; When a round of timer cycle expires, if the TCP packet loss rate of all candidate nodes is not 0%, the fake central node clears the candidate priority lists sent by all candidate nodes received within this round of timer cycle, resets the election timer, and starts the next round of timer cycle.

3. A node election method according to claim 2, characterized in that: Before a round of timer cycle expires, the fake central node continues to receive the candidate priority list sent from each candidate node, and records the TCP packet loss rate and delay of each candidate node; When a round of timer period expires and there is no situation where the TCP packet loss rate of all candidate nodes is not 0%, the fake central node calculates the final priority of each candidate node.

4. A node election method according to claim 3, characterized in that: When the fake central node calculates the final priority of each candidate node, if the main central node and the backup central node already exist, the fake central node will temporarily set the candidate nodes with priority G to be reordered from small to large according to the latency. According to the sorting, the final priority of the candidate node with the smallest latency is G+2.

5. A node election system, characterized in that: The pseudo central node is configured to: receive a priority list of candidates sent from each candidate node, and record a TCP packet loss rate and a delay of each candidate node; The fake central node temporarily sets the priority of the candidate node with a TCP packet loss rate of 0% to G, and sets the priority of the candidate node with a TCP packet loss rate of not 0% to H, where G is the smallest value among the priority values, and H is the largest value among the priority values. The priority range is G-H, and both G and H are integers. The fake central node will re-order the candidate nodes with a temporary priority of G according to the delay from small to large. According to the order, the final priority of the candidate node with the smallest delay is G; The candidate node with the final priority of G is configured as the main central node, and the candidate node with the final priority of G+1 is configured as the backup central node.

6. A node replacement method, characterized in that: Complete the election of the main central node and the backup central node based on the node election method described in any one of claims 1 to 4; The main central node is configured to periodically send its own priority list to be selected to the fake central node; When the fake central node does not receive the priority list of candidates from the main central node within the specified time, the main central node is marked as disconnected, and the fake central node sends the pending tasks to the backup central node for processing; The fake central node starts a timer with a timing period of N waiting cycles. If the priority list to be selected from the main central node is not received within N waiting cycles, the backup central node is configured as the main central node and N is reset; When the candidate priority list of the main central node is received within N waiting cycles, N is set to N-1.

7. A node replacement method according to claim 6, characterized in that: The standby central node is configured to periodically send its own priority list to be selected to the fake central node; When both the primary central node and the backup central node are marked as disconnected, the node election method is re-executed to complete the election of the primary central node and the backup central node.

8. A node replacement method according to claim 6, characterized in that: When the standby central node is configured as the main central node, the candidate node with a priority of G+2 is configured as the standby central node.

9. A node replacement method according to claim 8, characterized in that: When the backup central node is configured as the primary central node, the priorities of all candidate nodes are reduced by 1.

10. A node replacement system, characterized in that: Including a fake central node, the fake central node is configured to: complete the election of the main central node and the backup central node based on the node election method described in any one of claims 1 to 4; The main central node is configured to periodically send its own priority list to be selected to the fake central node; When the fake central node does not receive the priority list of candidates from the main central node within the specified time, the main central node is marked as disconnected, and the fake central node sends the pending tasks to the backup central node for processing; The fake central node starts a timer with a timing period of N waiting cycles. If the priority list to be selected from the main central node is not received within N waiting cycles, the backup central node is configured as the main central node and N is reset; When the candidate priority list of the main central node is received within N waiting cycles, N is set to N-1.