A cluster election method
By determining the node weight information based on network delay and bandwidth in the cloud computing cluster, and electing the node with the best network status as the master node, the problem of unstable service performance caused by random election in the battlefield environment is solved, and the cluster service performance is improved. stability.
Patent Information
- Application Number
- CN202210949068.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-09
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2042-08-09
AI Technical Summary
In a cloud computing cluster, when the master node is randomly elected, network volatility in the battlefield environment cannot be considered, resulting in unstable cluster service performance.
Each node in the cluster determines its own weight information. The weight information is based on the network delay and bandwidth of the node's adjacent nodes. The election information is determined by the weight information. The election information is broadcast to other nodes. The node determines itself based on the received election information. Either a master node or a slave node.
It effectively avoids selecting a node with poor network status as the master node in a battlefield environment, and improves the stability of cluster service performance.
Smart Images

Figure CN115378936B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud computing, and in particular to a cluster election method. Background Art
[0002] In the field of cloud computing, in order to manage large computer clusters and synchronize the operating status information of each computer, distributed consistency components are often relied on. Distributed consistency components are a distributed key-value database. In a cluster that deploys the same set of distributed components, any node writes data, and the data will be efficiently synchronized to other nodes. Based on this principle, cloud computing clusters achieve cluster synchronization of distributed computer status and build the foundation of distributed cloud computing.
[0003] When the consistency component is running, it is divided into master nodes and slave nodes. There will only be one master node at a time. The master node handles the write operations of each service in the distributed computer cluster and is the main hub for external services. The processing efficiency of the master node directly affects the operating efficiency of the entire service. There can be several slave nodes at the same time, which are mainly responsible for receiving data from the master node and have less impact on the entire service.
[0004] The existing master node election algorithm is generated by a random algorithm, and the generation of the master node has nothing to do with the servers in the cluster and the network status. In a server cluster connected by high-speed network cables, since the network conditions between nodes are similar and the network conditions are good, random elections do not affect the service efficiency of consistency components.
[0005] When cloud computing technology is currently used in the combat field, due to the complex battlefield electromagnetic environment and poor network quality, the network bandwidth and latency between nodes fluctuate greatly, and the network conditions between different nodes in the cluster are highly inconsistent. This network environment is quite different from the cloud computing environment in the existing computer room, where the network fluctuation of the server cluster is extremely low. Therefore, the current cluster election algorithm does not take into account the network fluctuation in the battlefield environment. When the master node is elected as a node with poor connection quality with other nodes, the service performance provided by the cluster is greatly reduced, resulting in unstable service performance of the cluster. Summary of the invention
[0006] The technical problem to be solved by the present invention is that the service performance of a cluster is unstable in an unstable environment. The purpose is to provide a cluster election method, which solves the problem that when a cluster faces a battlefield environment, a master node is randomly selected, resulting in unstable cluster service performance.
[0007] The present invention is achieved through the following technical solutions:
[0008] A cluster election method, comprising:
[0009] Each node in the cluster determines its own weight information, and the weight information is used to represent the importance of the node in the cluster;
[0010] Each of the nodes broadcasts its own weight information to other nodes in the cluster, and each of the nodes determines election information based on its own weight information and the weight information of other nodes, and the election information includes node information elected as the master node;
[0011] Each of the nodes broadcasts the election information to corresponding nodes, and each of the nodes determines whether it is a master node or a slave node according to the received election information.
[0012] Furthermore, each node in the cluster determines its own weight information, including:
[0013] Each node in the cluster determines the network latency and bandwidth with its neighboring nodes;
[0014] Each node in the cluster determines its own weight information based on the network latency and bandwidth of its adjacent nodes.
[0015] Furthermore, according to the network delay and bandwidth of its own adjacent nodes, its own weight information is determined, including:
[0016]
[0017] Among them, α represents the weight information of the current node, L i represents the network delay of the ith node adjacent to the current node, B i It represents the bandwidth of the i-th node adjacent to the current node, i=1,2,…,I, and I represents the total number of nodes adjacent to the current node.
[0018] Furthermore, based on its own weight information and the weight information of other nodes, election information is determined, including:
[0019] Determine the maximum weight information based on its own weight information and the weight information of other nodes;
[0020] The node corresponding to the largest weight information is determined as the master node, and the election information is obtained.
[0021] Furthermore, each of the nodes broadcasts the election information to corresponding nodes, and each of the nodes determines whether it is a master node or a slave node according to the received election information, including:
[0022] Each of the nodes broadcasts the election information to the corresponding node;
[0023] Each of the nodes determines whether more than half of the nodes in the received election information elect themselves as the master node. If so, each node determines itself as the master node; otherwise, each node determines itself as the slave node.
[0024] Furthermore, after each of the nodes broadcasts the election information to corresponding nodes, and each of the nodes determines whether it is a master node or a slave node according to the received election information, the method further includes:
[0025] Each of the master node and the slave node updates its own weight information in real time.
[0026] Furthermore, after each of the nodes broadcasts the election information to corresponding nodes, and each of the nodes determines whether it is a master node or a slave node according to the received election information, the method further includes:
[0027] The master node periodically sends a heartbeat signal to all slave nodes, wherein the heartbeat signal includes weight information of the master node;
[0028] Each of the slave nodes obtains network monitoring information according to the heartbeat signal, wherein the network monitoring information includes whether the network has changed or not changed;
[0029] When the network changes, cluster election is performed again.
[0030] Furthermore, each of the slave nodes obtains network monitoring information according to the heartbeat signal, including:
[0031] Each slave node determines whether the master node is disconnected based on the heartbeat signal. If so, it determines that the network has changed and obtains network monitoring information. Otherwise, it determines the optimal network node.
[0032] Each slave node determines whether the master node is the optimal network node based on the heartbeat signal. If so, it determines that the network has not changed and obtains network monitoring information. Otherwise, it determines that the network has changed and obtains network monitoring information.
[0033] Further, each of the slave nodes determines whether the master node is disconnected according to the heartbeat signal, including:
[0034] Each slave node determines whether the master node has sent a heartbeat signal in the previous cycle based on the heartbeat signal. If so, it is determined that the master node is not disconnected, otherwise it is determined that the master node is disconnected; the current cycle represents the cycle in which the master node last sent a heartbeat.
[0035] Further, each of the slave nodes determines whether the master node is the optimal network node according to the heartbeat signal, including:
[0036] Each slave node determines whether its own weight information is greater than the weight information in the heartbeat signal based on the heartbeat signal. If so, it determines that the master node is not the optimal network node, otherwise, it determines that the master node is the optimal network node.
[0037] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0038] The present invention provides a cluster election method, which uses network delay and bandwidth as indicators to select the node with the best network status as the master node of the cluster, thereby avoiding selecting the node with poor network status as the master node in a battlefield environment, thereby ensuring the stability of cluster service performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without creative work. In the drawings:
[0040] Figure 1 A flow chart of a cluster election method provided by an embodiment of the present invention;
[0041] Figure 2 (a) is an experimental data diagram of the existing random election method provided by the embodiment of the present invention, Figure 2 (b) is an experimental data diagram of the cluster election method provided in an embodiment of the present invention.
[0042] Marks and corresponding parts names in the attached drawings:
[0043] 1-first node, 2-second node, 3-third node, 4-fourth node, 5-fifth node. DETAILED DESCRIPTION
[0044] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.
[0045] Example
[0046] like Figure 1 As shown, a cluster election method includes:
[0047] S1. Each node in the cluster determines its own weight information, which is used to represent the importance of the node in the cluster.
[0048] The larger the weight information, the more important the corresponding node is in the cluster, that is, the better the network status of the corresponding node. Using weight information as an election indicator can effectively avoid selecting nodes with poor network status, ensuring the stability of cluster service performance.
[0049] S2. Each node broadcasts its own weight information to other nodes in the cluster, and each node determines election information based on its own weight information and the weight information of other nodes. The election information includes the node information elected as the master node.
[0050] The election information may be to elect oneself as the master node or to elect another node as the master node. When determining the election information, the node with the largest weight may be determined as the master node.
[0051] S3. Each node broadcasts the election information to the corresponding node, and each node determines whether it is a master node or a slave node based on the received election information.
[0052] Since each node receives the weight information of other nodes, when determining the weight information, the node with the largest weight is the same. As long as more than half of the nodes determine that a certain node is the master node, then the node can determine itself as the master node, and the other nodes can determine themselves as slave nodes.
[0053] For example, each node can set a quantity threshold. After receiving election information sent by other nodes, it can determine whether the total number of election information that determines itself as the master node exceeds the quantity threshold. If so, it determines itself as the master node, or determines itself as a slave node.
[0054] In a possible implementation, each node in the cluster determines its own weight information, including:
[0055] Each node in the cluster determines the network latency and bandwidth with its neighboring nodes.
[0056] Each node in the cluster determines its own weight information based on the network latency and bandwidth of its adjacent nodes.
[0057] In a possible implementation, determining the own weight information according to the network delay and bandwidth of the own neighboring nodes includes:
[0058]
[0059] Among them, α represents the weight information of the current node, L i represents the network delay of the ith node adjacent to the current node, B i It represents the bandwidth of the i-th node adjacent to the current node, i=1,2,…,I, and I represents the total number of nodes adjacent to the current node.
[0060] Based on the network delay and bandwidth of all neighboring nodes of a node, the weight information of the node is obtained, which can accurately express the importance of the node in the cluster.
[0061] In a possible implementation, determining election information according to the own weight information and the weight information of other nodes includes:
[0062] Determine the maximum weight information based on its own weight information and the weight information of other nodes.
[0063] The node corresponding to the largest weight information is determined as the master node, and the election information is obtained.
[0064] When a node receives a weight information that is greater than its own weight information, it can give up electing itself as the master node and elect the node with the largest weight information as the master node. After the election, the node can update its own weight information in real time to monitor whether the master node is the optimal node.
[0065] As the network changes, when the weight information of a node is greater than the weight information of the master node, it is necessary to re-elect the master node to ensure the service performance of the cluster.
[0066] In a possible implementation, each node broadcasts the election information to the corresponding node, and each node determines whether it is a master node or a slave node according to the received election information, including:
[0067] Each node broadcasts the election information to the corresponding node.
[0068] Each node determines whether more than half of the nodes in the received election information have elected themselves as the master node. If so, it determines itself as the master node, otherwise it determines itself as the slave node.
[0069] The election information may be broadcast to the corresponding nodes in the following manner: determining the node elected as the master node in the election information, obtaining the target node, and then broadcasting the election information to the target node.
[0070] In a possible implementation, each node broadcasts the election information to the corresponding node, and each node determines whether it is a master node or a slave node based on the received election information, and further includes: each master node and slave node updates its own weight information in real time.
[0071] In a possible implementation manner, each node broadcasts the election information to the corresponding node, and each node determines whether it is a master node or a slave node according to the received election information, further comprising:
[0072] The master node periodically sends a heartbeat signal to all slave nodes. The heartbeat signal includes the weight information of the master node.
[0073] Each slave node obtains network monitoring information based on the heartbeat signal, and the network monitoring information includes whether the network has changed or not.
[0074] When the network changes, cluster election is performed again.
[0075] Because each node (including master nodes and slave nodes) updates its own weight information in real time, the network can be monitored with the updated weight information. When changes in the network are detected, the cluster election is re-performed, which can effectively avoid the loss of connection with the master node or the deterioration of the network status of the master node, resulting in a decrease in cluster service performance, and ensure the stable operation of the cluster.
[0076] In a possible implementation, each slave node obtains network monitoring information according to the heartbeat signal, including:
[0077] Each slave node determines whether the master node is disconnected based on the heartbeat signal. If so, it determines that the network has changed and obtains network monitoring information. Otherwise, it determines the optimal network node.
[0078] Each slave node determines whether the master node is the optimal network node based on the heartbeat signal. If so, it determines that the network has not changed and obtains network monitoring information. Otherwise, it determines that the network has changed and obtains network monitoring information.
[0079] In a possible implementation, each slave node determines whether the master node is disconnected based on the heartbeat signal, including:
[0080] Each slave node determines whether the master node has sent a heartbeat signal in the previous cycle based on the heartbeat signal. If so, it is determined that the master node is not disconnected, otherwise it is determined that the master node is disconnected; the current cycle represents the cycle in which the master node last sent a heartbeat.
[0081] In a possible implementation, each slave node determines whether the master node is the optimal network node according to the heartbeat signal, including:
[0082] Each slave node determines whether its own weight information is greater than the weight information in the heartbeat signal based on the heartbeat signal. If so, it determines that the master node is not the optimal network node, otherwise it determines that the master node is the optimal network node.
[0083] The present invention provides a cluster election method, which uses network delay and bandwidth as indicators to select the node with the best network status as the master node of the cluster, thereby avoiding selecting the node with poor network status as the master node in a battlefield environment, thereby ensuring the stability of cluster service performance.
[0084] In this embodiment, a service cluster consisting of five nodes is provided, and a master node needs to be elected from the five nodes.
[0085] like Figure 2As shown in (a), using the existing random election method to select the master node, the fourth node 4 may be selected as the master node, but the fourth node 4 has a low bandwidth and high latency to connect to other nodes. At this time, the efficiency of the entire service cluster is extremely low, and any data writing takes about 3 seconds (after a write, broadcast and confirmation, where confirmation requires more than half of the slave nodes to return data, and each step takes about 1 second). Figure 2 (a) B 12 represents the bandwidth between the first node 1 and the second node 2, Figure 2 (a) L 12 It represents the network delay between the first node 1 and the second node 2, and so on, which will not be described here one by one.
[0086] like Figure 2 As shown in (b), the cluster election method described in this embodiment is used to select the master node from the first node 1, the second node 2, the third node 3, the fourth node 4 and the fifth node 5. The obtained master node is the third node 3. It only takes about 160ms to complete a data write. Its service performance is better than the master node generated by the existing random election method.
[0087] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A cluster election method, characterized in that: include: Each node in the cluster determines its own weight information, and the weight information is used to represent the importance of the node in the cluster; Each of the nodes broadcasts its own weight information to other nodes in the cluster, and each of the nodes determines election information based on its own weight information and the weight information of other nodes, and the election information includes node information elected as the master node; Each of the nodes broadcasts the election information to corresponding nodes, and each of the nodes determines whether it is a master node or a slave node according to the received election information; Each node in the cluster determines its own weight information, including: each node in the cluster determines the network delay and bandwidth with its neighboring nodes; each node in the cluster determines its own weight information based on the network delay and bandwidth of its neighboring nodes; Determine its own weight information based on the network delay and bandwidth of its adjacent nodes, including: Among them, α represents the weight information of the current node, L i represents the network delay of the ith node adjacent to the current node, B i represents the bandwidth of the i-th node adjacent to the current node, i = 1, 2, ..., I, I represents the total number of nodes adjacent to the current node; Each of the nodes broadcasts the election information to the corresponding nodes, and each of the nodes determines whether it is a master node or a slave node based on the received election information, including: each of the nodes broadcasts the election information to the corresponding nodes; each of the nodes determines whether more than half of the nodes in the received election information elect themselves as the master node, and if so, determines itself as the master node, otherwise determines itself as a slave node.
2. The cluster election method according to claim 1, characterized in that: According to its own weight information and the weight information of other nodes, the election information is determined, including: Determine the maximum weight information based on its own weight information and the weight information of other nodes; The node corresponding to the largest weight information is determined as the master node, and the election information is obtained.
3. The cluster election method according to claim 1, characterized in that: After each of the nodes broadcasts the election information to corresponding nodes, and each of the nodes determines whether it is a master node or a slave node according to the received election information, the method further includes: Each of the master node and the slave node updates its own weight information in real time.
4. The cluster election method according to claim 3, characterized in that: After each of the nodes broadcasts the election information to the corresponding nodes, and each of the nodes determines whether it is a master node or a slave node according to the received election information, the method further includes: The master node periodically sends a heartbeat signal to all slave nodes, wherein the heartbeat signal includes weight information of the master node; Each of the slave nodes obtains network monitoring information according to the heartbeat signal, wherein the network monitoring information includes whether the network has changed or not changed; When the network changes, cluster election is performed again.
5. The cluster election method according to claim 4, characterized in that: Each of the slave nodes obtains network monitoring information according to the heartbeat signal, including: Each slave node determines whether the master node is disconnected based on the heartbeat signal. If so, it determines that the network has changed and obtains network monitoring information. Otherwise, it determines the optimal network node. Each slave node determines whether the master node is the optimal network node based on the heartbeat signal. If so, it determines that the network has not changed and obtains network monitoring information. Otherwise, it determines that the network has changed and obtains network monitoring information.
6. The cluster election method according to claim 5, characterized in that: Each of the slave nodes determines whether the master node is disconnected according to the heartbeat signal, including: Each slave node determines whether the master node has sent a heartbeat signal in the previous cycle based on the heartbeat signal. If so, it is determined that the master node is not disconnected, otherwise it is determined that the master node is disconnected; the current cycle represents the cycle in which the master node last sent a heartbeat.
7. The cluster election method according to claim 5, characterized in that: Each of the slave nodes determines whether the master node is the optimal network node according to the heartbeat signal, including: Each slave node determines whether its own weight information is greater than the weight information in the heartbeat signal based on the heartbeat signal. If so, it determines that the master node is not the optimal network node, otherwise, it determines that the master node is the optimal network node.
Citation Information
Patent Citations
Improved distributed consistency algorithm
CN106559263A
Cluster deployment method and device, equipment, and computer readable storage medium
CN114070739A
Cloud-edge collaborative cluster construction method and system
CN114257601A