Data processing method, electronic device, storage medium, and computer program product

CN122526850APending Publication Date: 2026-08-07CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD
Filing Date
2026-04-16
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

相关的raft算法在没有系统崩溃和离线等异常情况下,并不会主动调整处于领导状态的节点,导致领导状态的节点的性能会极大影响分布式系统的整体性能,造成集群性能的不稳定

Benefits of technology

[0017]由上可知,本申请实施例中,运行于领导状态的第一节点向分布式系统中的一个或多个第二节点发送第一信息,第二节点运行于追随状态;第一节点接收一轮或多轮选举中针对第一节点的反对票,其中,反对票是在满足第一条件的情况下由对应的第二节点发送的,第一条件包括领导节点的性能指标满足相关标准,性能指标是对应的第二节点根据所述第一信息得到的;在一轮或多轮选举中的每一轮选举中接收到的第一节点的反对票的数量均高于第一阈值的情况下,将工作状态由领导状态调整为追随状态。可见,本申请实施例中会根据第一节点的性能指标主动调整运行于领导状态的节点的状态,而不会等到系统崩溃和离线等异常情况再调整第一节点的状态。本申请实施例中,在第一节点的性能指标满足相关标准时,会将第一节点的状态由领导状态调整为追随状态,即淘汰第一节点,使得第一节点不再作为领导节点,由于第一节点不再运行于领导状态,因此第一节点不再负责分布式系统中的日志的复制以及与客户端的通信等,从而可以减少分布式系统的整体性能对原处于领导状态的第一节点性能的依赖,提高集群性能的稳定性。可见,即本申请实施例会根据处于领导状态的第一节点的性能主动调整节点的状态,及时调整不适合运行于领导状态的节点的状态,减少处于领导状态的节点的性能降低对系统性能的负面影响,提高集群性能的稳定性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122526850A_ABST
    Figure CN122526850A_ABST
Patent Text Reader

Abstract

The application discloses a data processing method, an electronic device, a storage medium and a computer program product. The method comprises the following steps: sending first information to one or more second nodes in a first system; the first node runs in a leading state, and the second node runs in a following state; receiving votes against the first node in one or more rounds of election, wherein the votes against the first node are sent by the corresponding second node under the condition that a first condition is met, the first condition comprises that a performance index of the first node meets a related standard, and the performance index is obtained by the corresponding second node according to the first information; and adjusting the working state from the leading state to the following state under the condition that the number of votes against the first node received in each round of the one or more rounds of election is higher than a first threshold. Through the application, the stability of the cluster performance can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a data processing method, electronic device, storage medium, and computer program product. Background Technology

[0002] With the evolution and advancement of internet technology, centralized architectures can no longer meet the demands of massive users and ultra-high concurrency. High-performance, scalable, and highly reliable distributed systems have emerged. An increasing number of distributed systems are using the Raft algorithm to provide consistency and fault tolerance. In a Raft-based distributed system, a leader node is elected. This leader node is responsible for log replication and communication with clients, thus significantly impacting the system's performance. However, the Raft algorithm does not actively adjust the leader node unless there are system crashes or offline events. This results in the leader node's performance greatly affecting the overall performance of the distributed system, leading to cluster instability. Summary of the Invention

[0003] To address the related technical problems, embodiments of this application provide a data processing method, an electronic device, a storage medium, and a computer program product.

[0004] The technical solution of this application embodiment is implemented as follows: This application provides a data processing method applied to a first node. The method includes: Send a first message to one or more second nodes in the first system; the first node is running in a leader state and the second node is running in a follower state; Receive opposing votes against the first node in one or more rounds of election, wherein the opposing votes are sent by the corresponding second node under the condition that a first condition is met, the first condition including that the performance indicators of the first node meet relevant standards, and the performance indicators are obtained by the corresponding second node based on the first information; If the number of opposing votes received by the first node in each round of the election exceeds a first threshold, the working state will be adjusted from the leader state to the follower state.

[0005] In the above scheme, the first information includes one or more of the following: Heartbeat message; Throughput of the first system; The first delay is characterized as the time required for the first system to respond to a client request; The timestamp information is the time when the first node sends a heartbeat message to the corresponding second node.

[0006] In the above scheme, before sending the first information to one or more second nodes in the first system, the method further includes: The system receives votes from one or more third nodes in the first system, where the first node is in a candidate state and each of the one or more third nodes is in a follower state; the second type of vote is cast when the first node's first priority meets the second condition, and the first priority of the first node is determined based on the resource utilization rate of the first node. If the total number of votes from one or more third nodes exceeds a second threshold, the working status is adjusted from candidate status to leader status.

[0007] In the above scheme, the second condition includes one or more of the following: The first priority of the first node is greater than the target priority of the corresponding third node, and the target priority of the third node is related to the maximum value of the priorities of each node in the first system during the initial election round; The term of the first node in the leadership state is longer than the term of the corresponding third node in the leadership state; The term of the first node in the candidate state is longer than the term of the corresponding third node in the candidate state; The logs of the first node are updated more promptly than those of the corresponding third node.

[0008] In the above scheme, before receiving votes from one or more third nodes in the first system, the method further includes: If no heartbeat message is received from the fourth node running in the leader state, and if the first priority of the first node running in the follower state is greater than the target priority of the first node, the working state is adjusted from the follower state to the candidate state, and a second message is sent to the node in the follower state in the first system, the second message including one or more of the following: information for requesting to vote for the first node; the first priority of the first node.

[0009] The method in the above scheme further includes: The write request rate of the first system is determined based on the sum of the write request rates of each node in the first system. The write request rate of each node is the ratio of the write request of the corresponding node to the sum of the write request and read request of the corresponding node. The first threshold is determined based on the write request rate of the first system; wherein the first threshold is positively correlated with the write request rate of the first system; and / or, A third threshold is determined based on the write request rate of the first system; wherein the third threshold is negatively correlated with the write request rate of the first system; the first system responds to client requests under the condition that a third condition is met, the third condition including that the number of nodes in the first system submitting logs to the node running in the leader state is not less than the third threshold.

[0010] The method in the above scheme further includes: The first threshold and the third threshold are determined based on the system tolerance; wherein... The system tolerance is the minimum of the first tolerance and the second tolerance. The first tolerance is the difference between the number of nodes in the first system and the first threshold, and the second tolerance is the difference between the number of nodes in the first system and the third threshold.

[0011] This application provides a data processing method applied to a second node, the method comprising: Receive the first information sent by the first node in the first system; the first node is running in the leader state, and the second node is running in the follower state; Determine the performance indicators of the first node based on the first information; If the performance indicators meet the first condition in each round of election, a dissenting vote against the first node is sent to the first node in that round of election. The dissenting vote is cast by the corresponding second node under the condition that the performance indicators of the first node meet the relevant standards. If the number of dissenting votes received by the first node in each round of election in one or more rounds of election is higher than a first threshold, the working state of the first node is adjusted from the leader state to the follower state.

[0012] This application provides a data processing apparatus, including: The first sending unit is used to send first information to one or more second nodes in the first system; the first node operates in a leader state and the second node operates in a follower state; The first receiving unit is configured to receive opposing votes against the first node in one or more rounds of election, wherein the opposing votes are sent by the corresponding second node under the condition that a first condition is met, the first condition including that the performance indicators of the first node meet relevant standards, and the performance indicators are obtained by the corresponding second node based on the first information. The first adjustment unit is used to adjust the working state from the leader state to the follower state when the number of opposing votes received by the first node in each round of the election in the one or more rounds of election is higher than a first threshold.

[0013] This application also provides a data processing apparatus, including: The second receiving unit is used to receive the first information sent by the first node in the first system; the first node is running in a leader state and the second node is running in a follower state. The first determining unit is configured to determine the performance indicators of the first node based on the first information. The second sending unit is configured to send a dissenting vote against the first node in each round of election, provided that the performance indicators meet a first condition. The dissenting vote is cast by the corresponding second node when the first condition is met, and the first condition includes that the performance indicators of the first node meet relevant standards. If the number of dissenting votes received by the first node in each round of election is higher than a first threshold, the working state of the first node is adjusted from the leader state to the follower state.

[0014] This application also provides an electronic device, including: a processor and a memory for storing a computer program capable of running on the processor. The processor is used to execute the steps of any of the above-mentioned technical solutions when running the computer program.

[0015] This application also provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above methods.

[0016] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above methods.

[0017] As can be seen from the above, in this embodiment, the first node running in the leader state sends first information to one or more second nodes in the distributed system, and the second nodes run in the follower state. The first node receives opposing votes in one or more rounds of elections, wherein the opposing votes are sent by the corresponding second node under the condition that a first condition is met. The first condition includes that the performance index of the leader node meets relevant standards, and the performance index is obtained by the corresponding second node based on the first information. If the number of opposing votes received from the first node in each round of elections is higher than a first threshold, the working state is adjusted from the leader state to the follower state. It can be seen that in this embodiment, the state of the node running in the leader state is actively adjusted according to the performance index of the first node, rather than waiting for abnormal situations such as system crashes or offline conditions to adjust the state of the first node. In this embodiment, when the performance metrics of the first node meet the relevant standards, the state of the first node is adjusted from the leader state to the follower state, i.e., the first node is removed from the leader position. Since the first node is no longer running in the leader state, it is no longer responsible for log replication and communication with clients in the distributed system. This reduces the overall performance dependence of the distributed system on the performance of the first node that was originally in the leader state, improving the stability of the cluster performance. Therefore, this embodiment proactively adjusts the state of nodes based on the performance of the first node in the leader state, promptly adjusting the state of nodes unsuitable for the leader state, reducing the negative impact of reduced performance of nodes in the leader state on system performance, and improving the stability of the cluster performance. Attached Figure Description

[0018] Figure 1 A schematic diagram illustrating the state transitions of a Raft node provided in an embodiment of this application; Figure 2 A schematic diagram of the Raft log replication process provided in an embodiment of this application; Figure 3 A flowchart illustrating a data processing method provided in an embodiment of this application; Figure 4 This is a timing diagram of the leader node re-election process when the highest priority node fails, as provided in the embodiments of this application. Figure 5 A flowchart illustrating another data processing method provided in an embodiment of this application; Figure 6 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application; Figure 7 This is a schematic diagram of the structure of another data processing device provided in the embodiments of this application; Figure 8This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0019] The technical solutions of the embodiments of this application will now be described with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0020] It should be understood that the term "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, the term "one or more" in this document is an exemplary expression and can be replaced with any possible expression, such as one or more, at least one, or at least one item, etc.

[0021] It should also be understood that the term "instruction" mentioned in the embodiments of this application can be a direct instruction, an indirect instruction, or an indication of a relationship. For example, A instructing B can mean that A directly instructs B, such as B being able to obtain information through A; it can also mean that A indirectly instructs B, such as A instructing C, so B can obtain information through C; or it can mean that there is a relationship between A and B.

[0022] It should also be understood that the term "correspondence" mentioned in the embodiments of this application may indicate a direct or indirect correspondence between the two, or an association between the two, or a relationship of instruction and being instructed, configuration and being configured, etc.

[0023] It should be noted that terms such as "first" and "second" are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0024] Furthermore, the technical solutions described in the embodiments of this application can be combined arbitrarily without conflict.

[0025] Before providing a further detailed description of the embodiments of this application, the technologies related to the embodiments of this application will be described: With the transformation and advancement of internet technology, especially the development of cloud computing, centralized architectures can no longer meet the demands of massive users and ultra-high concurrency. Therefore, high-performance, easily scalable, and highly reliable distributed systems have emerged as an effective technology to address these challenges. While pursuing horizontal scaling, deploying more machines means facing a higher risk of failure. Distributed systems need to hide errors from clients; therefore, most distributed systems use consensus algorithms to provide consistency and fault tolerance. The Raft algorithm is a consensus algorithm that is easier to understand and implement than Paxos. The Raft algorithm is based on a replica state machine model. Its core consists of log replication and leader election. The state of a node transitions between leader, follower, and candidate based on different conditions. In related technologies, the node's state transition is based on a random timeout majority election model. The probability of each node being elected as leader is uncertain, and the voting criteria consider the length of each node's term and the amount of log data. A distributed system has only one leader at any given time and maintains periodic heartbeat messages with all followers. (See also...) Figure 1 When a Follower times out without receiving a heartbeat message from the Leader, it transforms into a Candidate. The Candidate then sends a vote request message to other nodes, applying to become the new Leader. If the Candidate receives confirmation messages from more than half of the nodes before the timeout, it becomes the Leader. Once the Candidate receives a valid heartbeat message from the Leader, it returns to the Follower state. The Follower responds to the Candidate's vote request and also to the Leader's request. If the request includes a log entry, it safely adds the log to its local state machine and sends the processing result to the Leader.

[0026] The Leader is the only server node that communicates with clients. It is responsible for receiving requests from clients and forwarding them to the Followers to perform consistency operations. See also... Figure 2In a 5-node Raft distributed system, the Leader receives write requests from clients, packages them into log entries, assigns terms and unique indexes, and persists them sequentially to local disk. Log entries are sent to Followers via AppendEntries Remote Procedure Calls (RPCs). Upon receiving a log entry, a Follower performs a security check and persists it. If successful, it notifies the Leader of the append operation via an AppendEntriesResult RPC. Once a majority of nodes have appended, the Leader updates the committed index, applies the log entries to the state machine, and notifies other Followers of the apply operation via a heartbeat message carrying the latest committed index. After the Leader completes the apply, it returns a success message to the client.

[0027] The Raft algorithm used in related technologies has the following three problems: The first problem is the inability to guarantee that the Leader is the best performing node. In Raft's random timeout election mechanism, the voting criteria only consider the leader node's term and log data volume, failing to guarantee that the selected Leader is the best performing node in the cluster. It may even choose a node with poor performance as the Leader. The Leader is responsible for log replication across the entire cluster, and to maintain its position, it needs to periodically send heartbeat messages to the Followers. When there are many nodes in the cluster, the Leader's workload is very high. In heterogeneous cloud computing environments, the performance of resource nodes varies significantly. This random timeout election mechanism cannot fully consider the performance of each node and utilize the resources in the cluster system, inevitably leading to single-point bottlenecks in the distributed system, resulting in resource waste and system performance degradation.

[0028] The second problem is that it doesn't account for changes in Leader performance. The Raft algorithm doesn't consider the impact of changes in the current leader node's performance on cluster performance during normal operation. Applying this approach directly to a real-world environment can lead to cluster instability. Once a Leader is elected, Raft won't actively replace it even if its performance degrades due to external factors, barring system crashes or offline events. Therefore, the overall system performance during normal operation heavily depends on the Leader's performance.

[0029] Third, the number of arbitrators cannot be dynamically adjusted. The Raft algorithm uses majority arbitration in both the election and replication phases, with each arbitrator consisting of a strict majority of nodes in each phase. This design leads to high network load and significant latency, making Raft unsuitable for latency-sensitive systems. Furthermore, a fixed number of arbitrators cannot dynamically balance throughput and availability based on the cluster's state.

[0030] It is evident that the Raft algorithm in related technologies is not suitable for cloud computing systems with high requirements for performance and latency, and there is an urgent need to propose a new and improved Raft design scheme.

[0031] To address at least one of the aforementioned technical problems, this application proposes a data processing method. In this method, a first node running in a leader state sends first information to one or more second nodes in a distributed system, while the second nodes run in a follower state. The first node receives opposing votes in one or more rounds of elections, where the opposing votes are sent by the corresponding second node under the condition that a first condition is met. The first condition includes the leader node's performance indicators meeting relevant standards, and these performance indicators are obtained by the corresponding second node based on the first information. If the number of opposing votes received from the first node in each round of elections exceeds a first threshold, the working state is adjusted from the leader state to the follower state. Therefore, this application proactively adjusts the state of the node running in the leader state based on the first node's performance indicators, rather than waiting for abnormal situations such as system crashes or offline events to adjust the first node's state. In this embodiment, when the performance metrics of the first node meet the relevant standards, the state of the first node is adjusted from the leader state to the follower state, i.e., the first node is removed from the leader position. Since the first node is no longer running in the leader state, it is no longer responsible for log replication and communication with clients in the distributed system. This reduces the overall performance dependence of the distributed system on the performance of the first node that was originally in the leader state, improving the stability of the cluster performance. Therefore, this embodiment proactively adjusts the state of nodes based on the performance of the first node in the leader state, promptly adjusting the state of nodes unsuitable for the leader state, reducing the negative impact of reduced performance of nodes in the leader state on system performance, and improving the stability of the cluster performance.

[0032] The present application will now be described in further detail with reference to the accompanying drawings and embodiments.

[0033] Please see Figure 3 The method provided in this application embodiment can be applied to the first node. The data processing method provided in this application embodiment includes: Step 301: Send a first message to one or more second nodes in the first system; the first node is running in a leader state, and the second node is running in a follower state; For example, the first system in this application embodiment includes one or more of the following: a distributed system; a middleware system in a cloud computing infrastructure; a highly reliable metadata management system; a distributed storage system; a cloud-native distributed database system; and a blockchain system. In a typical application scenario of this application, the first system is a distributed system.

[0034] For example, a typical application scenario of this application embodiment is its application to the improvement of consensus algorithms. Specifically, it can be used to improve the mechanism for electing a leader node and the mechanism for removing a leader node in the consensus algorithm. The consensus algorithm includes one or more of the following: Raft; Paxos; Zab. Algorithms such as Raft, Paxos, and Zab have different characteristics and application scenarios in distributed systems and can meet different needs.

[0035] For example, in the embodiments of this application, a node running in the leader state can be referred to as a leader node or a leader. For instance, when the first node is running in the leader state, the first node can be referred to as a leader node.

[0036] For example, in the embodiments of this application, a node running in the follow state can be referred to as a follower node or a follower. For instance, when the second node is running in the follow state, the first node can be referred to as a follower node.

[0037] For example, when the first node is running in the leader state, the first node is responsible for communication between the first system and the client, as well as the replication of the first system's logs.

[0038] For example, the first information includes information used to help measure the performance metrics of the first node and / or the first system, as can be seen in the following practical applications: In practical applications, the first information includes one or more of the following: Heartbeat message; Throughput of the first system; The first delay is characterized as the time required for the first system to respond to a client request; The first timestamp information is the time when the first node sends a heartbeat message to the corresponding second node.

[0039] In this embodiment, the throughput, latency, and timestamp information of the first system can help dynamically determine the performance indicators of the first node (i.e., the leader node) and the impact of the first node on the performance of the first system from multiple dimensions. Based on these performance indicators, it can help determine whether the first node needs to be eliminated and other nodes can be adopted as the leader node, thereby reducing the negative impact on the first system when the performance of the first node is low. Through the above mechanism, changes in system performance can be addressed, enhancing the stability, security, and overall performance of the first system.

[0040] For example, in this embodiment of the application, the heartbeat message is also referred to as a heartbeat request or heartbeat, and the heartbeat message is periodically sent by the node running in the leader state to the node running in the follower state.

[0041] For example, the throughput of the first system refers to the number of client requests that the first system can process per second.

[0042] For example, network latency can be obtained based on the first timestamp information. Network latency is the time required for a node running in the leader state to send a heartbeat message to a node running in the follower state. For instance, network latency can be the difference between the time when the corresponding second node receives the heartbeat message and the time when the first node sends the heartbeat message to the corresponding second node.

[0043] For example, the first delay can also be referred to as the consensus delay.

[0044] For example, the first latency, the throughput of the first system, etc. listed above are examples of the first information provided in the embodiments of this application. The embodiments of this application do not limit the first information to include the above information. The first information may also include other information, such as the workload of the first node, such as the bandwidth of the current network, etc.

[0045] It should be noted that, in the embodiments of this application, the heartbeat message, the latency of the first system and the throughput of the first system included in the first information are not limited to being sent at the same time. The heartbeat message, the latency of the first system and the throughput of the first system can also be sent at different times. For example, the heartbeat message can be sent first and then the latency of the first system can be sent.

[0046] Step 302: Receive opposing votes against the first node in one or more rounds of election, wherein the opposing votes are sent by the corresponding second node under the condition that a first condition is met, the first condition including that the performance indicators of the leader node meet relevant standards, and the performance indicators are determined by the corresponding second node based on the first information; For example, the performance metrics in the embodiments of this application include one or more of the following: throughput of the first system; first latency; network latency; workload of the first node; and bandwidth of the current network.

[0047] For example, based on throughput, first latency, and network latency, relevant standards for the performance indicators of the leader node (e.g., the first node) are established. When the performance indicators of the first node meet the relevant standards, it indicates that the performance of the first node has degraded. The formula (1) corresponding to the relevant standards is as follows:

[0048] Where TPS represents the throughput of the first system. Indicates the first delay. Indicates network latency. These represent the thresholds for throughput, first latency, and network latency, respectively, and r represents the number of heartbeat message rounds. This represents the threshold for fluctuations among the three factors between two heartbeats.

[0049] For example, referring to the above formula, the relevant standards for performance indicators in this application embodiment include one or more of the following: the throughput of the first system is less than the corresponding threshold; and / or, the throughput of the first system changes significantly between two heartbeat message interactions; and / or, the first latency is greater than the corresponding threshold; the first latency changes significantly between two heartbeat message interactions; and / or, the network latency is greater than the corresponding threshold; the network latency changes significantly between two heartbeat message interactions. When the performance indicators of a node running in the leader state (e.g., the first node) meet the relevant standards, it indicates that the performance of the node running in the leader state has decreased.

[0050] For example, the specific threshold parameter settings are shown in Table 1: Table 1 - Threshold Parameter Settings

[0051] For example, in the embodiments of this application, the relevant standards of performance indicators can be used as the criteria for a node running in the follower state (e.g., a second node) to determine whether to cast a dissenting vote for a node running in the leader state.

[0052] For example, to facilitate dynamic evaluation of the leader's performance, this application embodiment establishes an enhanced heartbeat procedure. Taking the leader as the first node running in the leadership state as an example, in addition to the standard heartbeat message, the first node also transmits the throughput of the first system. First delay And first timestamp information, etc. After the second node receives the heartbeat message, the followers first check in sequence. and Whether the relevant criteria established in Formula 1 are met. If the relevant criteria are not met, the follower will calculate the network latency. And evaluate the results using Formula 1. If , , If none of these three factors meet the relevant criteria in formula (1), then the second node running in the follower state will continue to use the services of the first node running in the leader state. Conversely, if , , If any factor in the equation satisfies any one of the conditions in formula (1), the second node running in the follower state will vote against the first node running in the leader state.

[0053] Step 303: If the number of opposing votes received by the first node in each round of the election is higher than the first threshold, the working state is adjusted from the leader state to the follower state.

[0054] It is understandable that while a leader with high hardware performance can be elected through priority election mechanisms, this method cannot guarantee consistent performance throughout the elected leader's term, especially under frequently changing network environments and fluctuating loads. Therefore, it is necessary to dynamically elect the best leader based on node performance metrics (such as workload and current network status). To improve the performance and security of the Raft algorithm, this application's embodiments design a dynamic elimination mechanism, as detailed in steps 301-303 above, along with related examples and practical applications. Through this dynamic elimination mechanism, followers can vote against leaders with low performance and high latency. After receiving one or more rounds of majority votes against a leader, the leader ceases to be the leader and changes its working state from leadership to follower.

[0055] It is understandable that when the first node changes its work status from leader to follower, it can be seen as eliminating the first node, which is no longer a leader node.

[0056] For example, when the first node changes its working state from leader to follower, a new leader node can be re-elected.

[0057] For example, to prevent the Leader from being ousted after only one round of dissenting votes, which could lead to excessive elections and subsequent system instability and insecurity, it's important to understand that a single round of dissenting votes might only represent a momentary fluctuation in Leader performance rather than a sustained decline. Therefore, it can be stipulated that if the first node running in the leader state receives a majority of dissenting votes after multiple rounds (e.g., three rounds), that first node will be removed, triggering a new election. Finally, when the entire cluster load is high, the performance metrics of the newly elected Leader may also exceed thresholds, leading to continuous Leader removal and election triggers, impacting the performance and stability of the primary system. To avoid this, it can be stipulated that after multiple consecutive (e.g., three) triggers of the removal of the leader node, indicating high load across the entire primary system, Leader removal should not be triggered. Instead, the dynamic Leader removal mechanism should be disabled for a period, the specific duration of which can be configured according to the business system.

[0058] As can be seen from the above, the dynamic elimination mechanism provided in this application fully reflects the changes in system performance, thereby enhancing stability, security and overall performance. The above examples and steps are summarized as a dynamic elimination mechanism.

[0059] The dynamic elimination mechanism in the embodiments of this application has been described above. In addition to the dynamic elimination mechanism, the embodiments of this application also propose a priority election mechanism, which can be used to elect a leader node, and the dynamic elimination mechanism can be used to determine whether the leader node needs to be eliminated and a new leader node needs to be elected. The priority election mechanism in the embodiments of this application is described below: For example, in Figure 3 In the method and related examples shown, the first node initially runs in the leader state, meaning it initially acts as the leader node. Prior to this, a priority election mechanism can be used for election, and the first node becomes the leader node elected through this mechanism. For example, when the first node is running in the follower state, if its first priority meets certain conditions, its working state changes from follower to candidate. Then, it requests votes from one or more third nodes running in the follower state. If the number of votes received meets certain conditions, the first node's working state changes from candidate to leader. See the following practical applications for details: It should be noted that, in the embodiments of this application, the node running in the candidate state can be called a candidate node or a candidate. For example, when the first node is running in the candidate state, the first node can be called a candidate node.

[0060] In practical applications, before receiving votes from one or more third nodes in the first system, the method further includes: If no heartbeat message is received from the fourth node running in the leader state, and if the first priority of the first node running in the follower state is greater than the target priority of the first node, the working state is adjusted from the follower state to the candidate state, and a second message is sent to the node in the follower state in the first system, the second message including one or more of the following: information for requesting to vote for the first node; the first priority of the first node.

[0061] For example, the first priority of each node is determined based on the resource utilization rate of each node.

[0062] For example, in the embodiments of this application, resource utilization includes one or more of the following: Central Processing Unit (CPU) utilization; memory utilization; disk input / output (I / O) utilization; graphics processing unit (GPU) resource utilization; tensor processing unit (TPU) resource utilization; and bandwidth resource utilization.

[0063] For example, in this embodiment of the application, the hardware performance index of a node can be determined based on the resource utilization rate of each node (e.g., the first node), and then the first priority of the node can be determined based on the hardware performance index.

[0064] Understandably, in relevant Raft algorithms, voting criteria are based solely on term size and log data volume. This approach cannot adapt to hardware heterogeneity or workload imbalances among distributed nodes. To address these issues, embodiments of this application establish priorities based on hardware performance metrics and then design a priority-based election mechanism to facilitate the selection of high-performance leaders.

[0065] In practical applications, before sending the first information to one or more second nodes in the first system, the method further includes: The system receives votes from one or more third nodes in the first system, where the first node is in a candidate state and each of the one or more third nodes is in a follower state; the second type of vote is cast when the first node's first priority meets the second condition, and the first priority of the first node is determined based on the resource utilization rate of the first node. If the total number of votes from one or more third nodes exceeds a second threshold, the working status is adjusted from candidate status to leader status.

[0066] In this embodiment, the priority of a node can be determined based on its resource utilization rate, and then a candidate node can be determined as a leader node based on its priority. The above election process effectively takes into account the hardware performance of the node, ensuring that a high-performance leader is responsible for communication with the client and log replication of the followers.

[0067] It should be noted that the above practical application takes the first priority determined based on resource utilization as an example. In this embodiment, resource utilization can also be determined based on other indicators. For example, the first priority can be determined based on the election timeout duration. Specifically, this can be achieved by modifying the election timeout duration. The first priority of the node is defined as three levels: priority 1, priority 2, and priority 3. The election timeout duration corresponding to priority 1 is 50-100ms; the election timeout duration corresponding to priority 2 is 100-150ms; and the election timeout duration corresponding to priority 3 is 150-200ms. That is, the shorter the timeout duration, the higher the priority. Among them, priority 1 is the highest priority.

[0068] For example, in the embodiments of this application, the second threshold and / or the first threshold may be referred to as the number of election arbitrators. The election can only be considered valid if the number of votes (i.e. the number of people participating in the election arbitration) is greater than the number of election arbitrators.

[0069] In practical applications, the second condition includes one or more of the following: The first priority of the first node is greater than the target priority of the corresponding third node, and the target priority of the third node is related to the maximum value of the priorities of each node in the first system during the initial election round; The term of the first node in the leadership state is longer than the term of the corresponding third node in the leadership state; The term of the first node in the candidate state is longer than the term of the corresponding third node in the candidate state; The logs of the first node are updated more promptly than those of the corresponding third node.

[0070] For example, the initial election round is the first round in which the leader node is elected using the aforementioned priority election mechanism.

[0071] For example, the target priority of the third node can be the maximum value of the priorities of all nodes in the first system during the initial election round; and / or, the target priority of the third node can have a functional relationship with the maximum value of the priorities of all nodes in the first system during the initial election round, such as an exponential or linear function relationship, if no new leader is elected before the next election timeout. The priority of each node in the first system will decrease linearly or exponentially based on the maximum priority among all nodes in the initial election round.

[0072] For example, if a new leader is not elected before the next election expires, the goal priority... It will decrease exponentially, calculated as . for The goals and priorities of the previous election The initial value is the maximum priority among the nodes in the first system during the initial election round.

[0073] The priority election mechanism in this application embodiment is illustrated below with specific examples: For example, to evaluate the hardware performance metrics of each node, embodiments of this application consider the utilization of three resources: CPU utilization, memory utilization, and disk I / O utilization. Specifically, the hardware performance metrics can be expressed as a weighted sum of idle resources:

[0074] in, The hardware performance metrics representing node i These are the weighting coefficients. Represents CPU utilization. Represents memory usage. Represents disk I / O utilization. Let be the weighting coefficient, satisfying and It can be observed that... A larger value indicates more free resources and better hardware performance.

[0075] For example, to determine the node with the best performance, this application introduces a first priority, which is a priority index determined by the proportion of the node's performance to the overall performance of all nodes in the system. Specifically, the node... The first priority is defined as:

[0076] in, This represents the first priority of node i. This represents the performance metrics of node i. denoted as the total number of nodes in the first system.

[0077] For example, according to formula (3), each node can calculate and store its own first priority. To accelerate the leader election process, embodiments of this application further introduce a target priority. , defined as the maximum value among all nodes with the highest priority:

[0078] For example, based on the first priority and the target priority, this application embodiment designs a priority-based leader election mechanism, as shown in the following example: For example, in the initial election round within the first system, i.e., when the above-described priority election mechanism is used for the first time, the node with the highest priority is naturally elected as the leader. Each time a follower node i (e.g., the first node running in a follower state) receives a heartbeat message from the current leader node, follower node i calculates and updates its target priority according to formula (3). This mechanism ensures that high-priority nodes can maintain their leadership position and avoid contention. Please refer to... Figure 4 , Figure 4 The sequence diagram for leader re-election in the event of a failure of the highest priority node shows that if follower node i does not receive a heartbeat message from the leader, it will lower its target priority. First priority of following node i Compare. If Following node i will not initiate a leader election and will wait for the next leader election timeout. Conversely, if The following node i will increase its current term and become a candidate node. Then, the candidate node (e.g., the first node in the candidate state) initiates a leader election and sends the voting request along with the candidate node's first priority to other following nodes (e.g., the third node running in the follower state). Subsequently, the following nodes will receive the priority of the candidate node. (For example It can be the first node ) and its locally stored target priority Compare. If The following node rejects the candidate node's vote request. If Follower nodes then compare the candidate node's term and log data with their own. If the candidate node's term is shorter or its log updates are less timely than those of the follower nodes, the follower will refuse to vote. Otherwise, the follower nodes vote for the candidate node. Finally, if a candidate node receives votes from a majority of nodes in the cluster during the same term, the candidate wins the election and becomes the leader node.

[0079] As can be seen from the above, the election process described in this application embodiment effectively takes into account the hardware performance of the nodes, ensuring that the high-performance leader is responsible for communication with the client and log replication of the followers.

[0080] For ease of analysis, this embodiment designates the number of arbitrators in the leader election and log replication phases of Raft as the election arbitrator number EQ and the replication arbitrator number RQ, respectively. EQ is the aforementioned first threshold, and RQ is the aforementioned third threshold. Related technologies' Raft algorithms require both leader election and log replication to strictly adhere to a majority arbitrator number. For example, in related technologies, when... In a cloud computing system with nodes, the leader can only operate after receiving at least [a certain number of] [receives / resources]. They will be elected only after receiving at least [number] votes, and only after receiving at least [number] votes. A client request will only be responded to after a log commit. This approach ensures that there is at least one overlapping node between the two arbitrators, thus providing high node tolerance and security. However, this majority requirement can significantly increase data commit latency and reduce overall throughput, posing a significant challenge to balancing system security and performance.

[0081] To address the aforementioned issues, this application proposes a Dynamic Election Replication Model (DERM). This model dynamically adjusts the EQ (first threshold) and RQ (third threshold) based on the system's write request rate and tolerance policy. Compared to the laissez-faire Raft algorithm in related technologies, the DERM provided in this application implements more flexible and secure intersection conditions for the number of arbitrators at different stages.

[0082] Where N represents the total number of nodes in the first system.

[0083] Based on formula (5), this application embodiment constructs two strategies to determine EQ and RQ, namely the write request ratio strategy and the F-Tolerance strategy.

[0084] First, we will introduce the write request ratio strategy, also known as the write request rate strategy.

[0085] In practical applications, the method further includes: The write request rate of the first system is determined based on the sum of the write request rates of each node in the first system. The write request rate of each node is the ratio of the write request of the corresponding node to the sum of the write request and read request of the corresponding node. The first threshold is determined based on the write request rate of the first system; wherein the first threshold is positively correlated with the write request rate of the first system; and / or, The third threshold is determined based on the write request rate of the first system; wherein the third threshold is negatively correlated with the write request rate of the first system; the first system responds to client requests under the condition that a third condition is met, the third condition including that the number of nodes in the first system submitting logs to the node running in the leader state is greater than the third threshold.

[0086] It should be noted that the first threshold can be determined based on the write request rate of the first system. In this embodiment of the application, the second threshold can also be determined based on the write request rate of the first system. For details, please refer to the calculation method of the first threshold.

[0087] For example, suppose a node in the first system The current number of write requests and read requests are respectively and Compared to read requests, write requests have a greater impact on system performance, mainly because write requests will only receive a response when the log commit reaches the RQ (i.e., the third threshold). Read requests, on the other hand, can circumvent this limitation using methods such as Read Index or LeaseRead. Therefore, this application's embodiments introduce nodes... Write request rate , Defined as the proportion of all requests processed by write request node i, i.e.:

[0088] in, This represents the write request rate of node i. This represents the read request rate of node i.

[0089] Then, the write request rate of the first system can be expressed as the sum of the write request rates of each node, rounded up:

[0090] As the read frequency (RQ) increases, consensus latency becomes increasingly high, especially with a large RQ. The time required for the first system to respond to the client results in excessive latency. Based on this analysis, this application proposes a write request ratio strategy, which can simultaneously adjust both the read frequency (EQ) and the RQ.

[0091] As can be seen from equation (8), with As the write request rate increases, RQ decreases and EQ increases. This means that when the write request rate increases, the first system can appropriately reduce RQ to reduce consensus latency. In addition, the sum of RQ and EQ in equation (8) also satisfies the security condition required by equation (5). Therefore, the write request ratio strategy proposed in this application embodiment can help the first system dynamically select the optimal number of arbitrators to adapt to the current load while ensuring security.

[0092] To dynamically balance system throughput, latency, and availability, DERM further introduces the concept of F-tolerance. The F-Tolerance strategy in the embodiments of this application is described below: In practical applications, the method further includes: The first threshold and the third threshold are determined based on the system tolerance; wherein... The system tolerance is the minimum of the first tolerance and the second tolerance. The first tolerance is the difference between the number of nodes in the first system and the first threshold, and the second tolerance is the difference between the number of nodes in the first system and the third threshold.

[0093] For example, the system tolerance mentioned above includes one or more of the following: a pre-set system tolerance; and / or a user-given system tolerance; a system tolerance determined based on the throughput and availability of the first system. In this embodiment, the first threshold and the third threshold can be dynamically adjusted by dynamically adjusting the system tolerance.

[0094] For example, given an RQ's F-tolerance, i.e., the first tolerance... , Defined as even if any is deleted from the cluster Even with a number of nodes, an RQ can still be formed. Therefore, It can be written as:

[0095] First tolerance level For EQ's F-tolerance, Represented in the same way, that is:

[0096] Then, in this embodiment of the application, the system tolerance F is defined as... and The minimum value, that is:

[0097] For example, given system tolerance In this case, it can be based on Determine RQ and EQ. Through the F setting, throughput and availability can be dynamically balanced. As F increases, RQ increases, resulting in decreased throughput and increased availability.

[0098] For example, for the first system deploying the Raft algorithm with an even number of nodes, DERM can effectively ensure that the F-tolerance does not decrease while reducing the number of RQs. Taking a four-node system deploying the original Raft algorithm as an example, the EQ in the first stage is 3, the RQ in the second stage is also 3, and the F-tolerance of the system is 1. For a four-node system deployed using the F-Tolerance strategy, the EQ in the first stage is also 3, but the RQ in the second stage can be reduced to 2, which also meets the security requirement (5), and the F-tolerance of the system is also equal to 1. It can be seen that DERM can improve system throughput and reduce data submission latency without reducing availability.

[0099] It should be noted that the embodiments of this application are not limited to using the above-described dynamic election replication model. Other replication strategies can also be used to improve throughput and reduce latency. For example, the communication complexity of the leader node can be reduced by allowing follower nodes to participate in the distribution of log information.

[0100] This application also provides a data processing method that can be applied to a second node. Please refer to [link to relevant documentation]. Figure 5 The data processing method includes: Step 501: Receive the first information sent by the first node in the first system; the first node is running in the leader state, and the second node is running in the follower state; Step 502: Determine the performance indicators of the first node based on the first information; Step 503: If the performance index meets the first condition in each round of election, send a dissenting vote against the first node in that round of election, wherein the dissenting vote is cast by the corresponding second node under the condition that the first condition is met, the first condition including that the performance index of the first node meets the relevant standard; if the number of dissenting votes received by the first node in each round of election in one or more rounds of election is higher than the first threshold, the working state of the first node is adjusted from the leader state to the follower state.

[0101] It should be noted that, Figure 5 The related explanations, descriptions, and practical applications of the methods shown can be referenced together. Figure 3 The diagram includes related explanations, interpretations, and practical applications.

[0102] In practical applications, the first information includes one or more of the following: Heartbeat message; Throughput of the first system; The first delay is characterized as the time required for the first system to respond to a client request; The timestamp information is the time when the first node sends a heartbeat message to the corresponding second node.

[0103] As can be seen from the above, the embodiments of this application mainly include three parts: a priority election mechanism, a dynamic elimination mechanism, and a dynamic election replication model. The scheme provided by the embodiments of this application has the following characteristics: First, it can elect a Leader with the best performance. To solve the problem of uneven performance of distributed nodes, the embodiments of this application propose a priority election mechanism. During the Leader election phase, the node performance is evaluated based on the node's idle CPU, memory, and disk I / O resources, and the priority is determined according to the proportion of each node's performance in the cluster. The node with the higher priority is more likely to be elected as the Leader. The system can elect a Leader with excellent performance, thereby improving the throughput of the entire system. Second, the embodiments of this application propose a dynamic elimination mechanism. In order to reduce the impact of the Leader's performance decline on system efficiency, the Follower will comprehensively consider factors such as throughput, consensus latency, and network latency to dynamically evaluate the Leader's operating status. If the Leader's performance indicators drop to a relevant threshold, the Follower will vote against the Leader. If the current Leader receives a majority of opposing votes in one or more rounds, it will be eliminated and become a Follower. The system can dynamically re-elect a higher-performing Leader, thereby ensuring the stability of the entire cluster's performance. Third, this application proposes a dynamic election replication model, which adjusts the number of arbitrations during the election replication phase based on the write request rate and system tolerance. When the model identifies a high proportion of write requests, it reduces the number of replication arbitrations, allowing the leader to respond without waiting for a majority of followers. This adjustment effectively reduces network load and latency while increasing throughput. Furthermore, the concept of tolerance is introduced to facilitate a dynamic trade-off between latency, throughput, and availability.

[0104] The embodiments of this application have the following advantages: First, it ensures that the Leader's performance remains optimal throughout system operation. Based on various hardware performance and network metrics, this application establishes a priority election and dynamic elimination mechanism. This approach helps elect the best-performing leader and replaces them when performance deteriorates, thereby reducing the negative impact of low-performing leaders on the system. Second, it solves the problem of excessive consensus latency due to a majority of arbitrators. To address the increased consensus latency caused by the requirement for a majority of arbitrators in the Raft algorithm, this application proposes a dynamic election replication model to adjust the number of arbitrators. By constructing two strategies—write request rate and F-Tolerance—the system can dynamically balance throughput, latency, and availability.

[0105] With the rapid development of cloud computing and distributed systems, the demand for high-performance and highly available consensus algorithms is increasing. This application proposes an improved Raft design that integrates priority and election replication models. This scheme features a dynamic adjustment mechanism and high performance, balancing throughput, latency, and availability based on the system's read / write request ratio and fault tolerance strategy. This improves system efficiency during failover and recovery, reduces the Recovery Time Objective (RTO) or Recovery Point Objective (RPO) values, and thus ensures business continuity.

[0106] The embodiments of this application can be applied to related solutions of RocketMQ. By redesigning the deployment architecture of the message queue RocketMQ, automatic failover and recovery can be achieved, reducing the workload of operation and maintenance personnel and thus reducing operation and maintenance costs. Through priority election and dynamic elimination mechanisms, the utilization rate of system resources is improved, and performance degradation and cost waste caused by single point bottlenecks are reduced, providing high-performance, low-latency services in cloud-native environments.

[0107] Based on the embodiments described above, this application also provides a data processing apparatus, see [link to previous document]. Figure 6 The data processing device includes: The first sending unit 601 is used to send first information to one or more second nodes in the first system; the first node operates in a leader state and the second node operates in a follower state. The first receiving unit 602 is configured to receive opposing votes against the first node in one or more rounds of election, wherein the opposing votes are sent by the corresponding second node under the condition that a first condition is met, the first condition including that the performance indicators of the first node meet relevant standards, and the performance indicators are obtained by the corresponding second node based on the first information. The first adjustment unit 603 is used to adjust the working state from the leader state to the follower state when the number of opposing votes received by the first node in each round of the election in the one or more rounds of election is higher than a first threshold.

[0108] In one embodiment, the first information includes one or more of the following: Heartbeat message; Throughput of the first system; The first delay is characterized as the time required for the first system to respond to a client request; The timestamp information is the time when the first node sends a heartbeat message to the corresponding second node.

[0109] In one embodiment, the apparatus further includes a third receiving unit and a second adjusting unit. Before sending the first information to one or more second nodes in the first system, the third receiving unit is used to receive votes from one or more third nodes in the first system. The first node is running in a candidate state, and each of the one or more third nodes is running in a follower state. The second type of vote is cast when the first priority of the first node satisfies a second condition. The first priority of the first node is determined based on the resource utilization rate of the first node. The second adjustment unit is used to adjust the working state from candidate state to leader state when the total number of votes from one or more third nodes is greater than a second threshold.

[0110] In one embodiment, the second condition includes one or more of the following: The first priority of the first node is greater than the target priority of the corresponding third node, and the target priority of the third node is related to the maximum value of the priorities of each node in the first system during the initial election round; The term of the first node in the leadership state is longer than the term of the corresponding third node in the leadership state; The term of the first node in the candidate state is longer than the term of the corresponding third node in the candidate state; The logs of the first node are updated more promptly than those of the corresponding third node.

[0111] In one embodiment, the apparatus further includes a third adjustment unit, which, prior to receiving votes from one or more third nodes in the first system, is configured to; If no heartbeat message is received from the fourth node running in the leader state, and if the first priority of the first node running in the follower state is greater than the target priority of the first node, the working state is adjusted from the follower state to the candidate state, and a second message is sent to the node in the follower state in the first system, the second message including one or more of the following: information for requesting to vote for the first node; the first priority of the first node.

[0112] In one embodiment, the device further includes a second determining unit and a third determining unit. The second determining unit is used to determine the write request rate of the first system. The write request rate of the first system is determined based on the sum of the write request rates of each node in the first system. The write request rate of each node is the ratio of the write request of the corresponding node to the sum of the write request and read request of the corresponding node. The third determining unit is configured to determine the first threshold based on the write request rate of the first system; wherein the first threshold is positively correlated with the write request rate of the first system; and / or, A third threshold is determined based on the write request rate of the first system; wherein the third threshold is negatively correlated with the write request rate of the first system; the first system responds to client requests under the condition that a third condition is met, the third condition including that the number of nodes in the first system submitting logs to the node running in the leader state is not less than the third threshold.

[0113] In one embodiment, the apparatus further includes a fourth determining unit, the fourth determining unit being configured to determine the first threshold and the third threshold based on system tolerance; wherein, The system tolerance is the minimum of the first tolerance and the second tolerance. The first tolerance is the difference between the number of nodes in the first system and the first threshold, and the second tolerance is the difference between the number of nodes in the first system and the third threshold.

[0114] In practical applications, the first adjustment unit 603, the second adjustment unit, the third adjustment unit, the second determination unit, the third determination unit, and the fourth determination unit can be implemented by the processor in the data processing device, and the first sending unit 601, the first receiving unit 602, and the third receiving unit can be implemented by the processor in the data processing device in conjunction with the communication interface.

[0115] Based on the embodiments described above, this application also provides a data processing apparatus, see [link to previous document]. Figure 7 The data processing device includes: The second receiving unit 701 is used to receive first information sent by the first node in the first system; the first node is running in a leader state and the second node is running in a follower state. The first determining unit 702 is used to determine the performance indicators of the first node based on the first information; The second sending unit 703 is configured to send a dissenting vote against the first node in each round of election, provided that the performance indicators meet a first condition. The dissenting vote is cast by the corresponding second node when the first condition is met, and the first condition includes that the performance indicators of the first node meet relevant standards. If the number of dissenting votes received by the first node in each round of election is higher than a first threshold, the working state of the first node is adjusted from the leader state to the follower state.

[0116] It should be noted that the data processing apparatus provided in the above embodiments is only illustrated by the division of the above program modules. In practical applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the apparatus can be divided into different program modules to complete all or part of the processing described above. In addition, the data processing apparatus and data processing method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.

[0117] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiments of this application, this application also provides an electronic device, see [link to relevant documentation]. Figure 8 The electronic device includes: a first communication interface 1, a first processor 2, and a first memory 3.

[0118] In one example, a first communication interface 1 is used to send first information to one or more second nodes in a first system; the first node operates in a leader state, and the second node operates in a follower state; The first communication interface 1 is also used to receive opposing votes against the first node in one or more rounds of election, wherein the opposing votes are sent by the corresponding second node under the condition that a first condition is met, the first condition including that the performance indicators of the first node meet relevant standards, and the performance indicators are obtained by the corresponding second node based on the first information. The first processor 2 is configured to adjust its working state from a leader state to a follower state when the number of opposing votes received from the first node in each round of the election (in one or more rounds) is higher than a first threshold.

[0119] In one embodiment, the first information includes one or more of the following: Heartbeat message; Throughput of the first system; The first delay is characterized as the time required for the first system to respond to a client request; The timestamp information is the time when the first node sends a heartbeat message to the corresponding second node.

[0120] In one embodiment, before sending the first information to one or more second nodes in the first system, the first processor 2 is further configured to receive votes from one or more third nodes in the first system, wherein the first node is running in a candidate state and each of the one or more third nodes is running in a follower state; the second type of vote is cast when the first priority of the first node satisfies a second condition, and the first priority of the first node is determined based on the resource utilization rate of the first node; The first processor 2 is also configured to adjust the working state from the candidate state to the leader state when the total number of votes from the one or more third nodes is greater than a second threshold.

[0121] In one embodiment, the second condition includes one or more of the following: The first priority of the first node is greater than the target priority of the corresponding third node, and the target priority of the third node is related to the maximum value of the priorities of each node in the first system during the initial election round; The term of the first node in the leadership state is longer than the term of the corresponding third node in the leadership state; The term of the first node in the candidate state is longer than the term of the corresponding third node in the candidate state; The logs of the first node are updated more promptly than those of the corresponding third node.

[0122] In one embodiment, before receiving votes from one or more third nodes in the first system, the first processor 2 is further configured to: If no heartbeat message is received from the fourth node running in the leader state, and if the first priority of the first node running in the follower state is greater than the target priority of the first node, the working state is adjusted from the follower state to the candidate state, and a second message is sent to the node in the follower state in the first system, the second message including one or more of the following: information for requesting to vote for the first node; the first priority of the first node.

[0123] In one embodiment, the first processor 2 is further configured to: The write request rate of the first system is determined based on the sum of the write request rates of each node in the first system. The write request rate of each node is the ratio of the write request of the corresponding node to the sum of the write request and read request of the corresponding node. The first threshold is determined based on the write request rate of the first system; wherein the first threshold is positively correlated with the write request rate of the first system; and / or, A third threshold is determined based on the write request rate of the first system; wherein the third threshold is negatively correlated with the write request rate of the first system; the first system responds to client requests under the condition that a third condition is met, the third condition including that the number of nodes in the first system submitting logs to the node running in the leader state is not less than the third threshold.

[0124] In one embodiment, the first processor 2 is further configured to: determine the first threshold and the third threshold based on system tolerance; wherein, The system tolerance is the minimum of the first tolerance and the second tolerance. The first tolerance is the difference between the number of nodes in the first system and the first threshold, and the second tolerance is the difference between the number of nodes in the first system and the third threshold.

[0125] It should be noted that the data processing apparatus provided in the above embodiments is only illustrated by the division of the above program modules. In practical applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the apparatus can be divided into different program modules to complete all or part of the processing described above. In addition, the data processing apparatus and data processing method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.

[0126] In yet another example, the first communication interface 1 is used to receive first information sent by a first node in a first system; the first node is running in a leader state, and the second node is running in a follower state; The first processor 2 is configured to determine the performance metrics of the first node based on the first information; The first communication interface 1 is further configured to send a dissenting vote against the first node in each round of election if the performance index meets a first condition, wherein the dissenting vote is cast by the corresponding second node under the condition that the first condition includes the first node's performance index meeting relevant standards; and if the number of dissenting votes received by the first node in each round of election in one or more rounds of election is higher than a first threshold, the working state of the first node is adjusted from the leader state to the follower state.

[0127] Of course, in practical applications, the various components in an electronic device are coupled together through bus system 4. It can be understood that bus system 4 is used to achieve communication and connection between these components. In addition to the data bus, bus system 4 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 8 The general will label all buses as Bus System 4.

[0128] The first memory 3 in this embodiment is used to store various types of data to support operation in the electronic device. Examples of such data include any computer program used to operate on the electronic device.

[0129] The methods disclosed in the embodiments of this application can be applied to the first processor 2, or implemented by the first processor 2. The first processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware or by instructions in the form of software in the first processor 2. The first processor 2 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The first processor 2 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly reflected as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in the first memory 3. The first processor 2 reads the information in the first memory 3 and completes the steps of the aforementioned method in combination with its hardware.

[0130] In an exemplary embodiment, the electronic device may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to perform the aforementioned methods.

[0131] It is understood that the first memory 3 in this application embodiment can be a volatile memory pool or a non-volatile memory pool, or both. The non-volatile memory pool can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory pool can be a disk storage pool or a magnetic tape storage pool. The volatile memory pool can be a random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The storage pools described in the embodiments of this application are intended to include, but are not limited to, these and any other suitable types of storage pools.

[0132] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a first memory 3 storing a computer program, which can be executed by a first processor 2 to complete the steps described in the aforementioned method.

[0133] In an exemplary embodiment, this application also provides a computer program product, including a computer program that can be executed by a first processor 2 to perform the steps described in the foregoing method.

[0134] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application.

Claims

1. A data processing method, characterized in that, Applied to the first node, the data processing method includes: Send a first message to one or more second nodes in the first system; the first node is running in a leader state and the second node is running in a follower state; Receive opposing votes against the first node in one or more rounds of election, wherein the opposing votes are sent by the corresponding second node under the condition that a first condition is met, the first condition including that the performance indicators of the first node meet relevant standards, and the performance indicators are obtained by the corresponding second node based on the first information; If the number of opposing votes received by the first node in each round of the election exceeds a first threshold, the working state will be adjusted from the leader state to the follower state.

2. The method according to claim 1, characterized in that, The first information includes one or more of the following: Heartbeat message; Throughput of the first system; The first delay is characterized as the time required for the first system to respond to a client request; The timestamp information is the time when the first node sends a heartbeat message to the corresponding second node.

3. The method according to claim 1, characterized in that, Before sending the first information to one or more second nodes in the first system, the method further includes: The system receives votes from one or more third nodes in the first system, where the first node is in a candidate state and each of the one or more third nodes is in a follower state; the second type of vote is cast when the first node's first priority meets the second condition, and the first priority of the first node is determined based on the resource utilization rate of the first node. If the total number of votes from one or more third nodes exceeds a second threshold, the working status is adjusted from candidate status to leader status.

4. The method according to claim 3, characterized in that, The second condition includes one or more of the following: The first priority of the first node is greater than the target priority of the corresponding third node, and the target priority of the third node is related to the maximum value of the priorities of each node in the first system during the initial election round; The term of the first node in the leadership state is longer than the term of the corresponding third node in the leadership state; The term of the first node in the candidate state is longer than the term of the corresponding third node in the candidate state; The logs of the first node are updated more promptly than those of the corresponding third node.

5. The method according to claim 3, characterized in that, Before receiving votes from one or more third nodes in the first system, the method further includes: If no heartbeat message is received from the fourth node running in the leader state, and if the first priority of the first node running in the follower state is greater than the target priority of the first node, the working state is adjusted from the follower state to the candidate state, and a second message is sent to the node in the follower state in the first system, the second message including one or more of the following: information for requesting to vote for the first node; the first priority of the first node.

6. The method according to claim 1, characterized in that, The method further includes: The write request rate of the first system is determined based on the sum of the write request rates of each node in the first system. The write request rate of each node is the ratio of the write request of the corresponding node to the sum of the write request and read request of the corresponding node. The first threshold is determined based on the write request rate of the first system; wherein the first threshold is positively correlated with the write request rate of the first system; and / or, A third threshold is determined based on the write request rate of the first system; wherein the third threshold is negatively correlated with the write request rate of the first system; the first system responds to client requests under the condition that a third condition is met, the third condition including that the number of nodes in the first system submitting logs to the node running in the leader state is not less than the third threshold.

7. The method according to claim 1, characterized in that, The method further includes: The first threshold and the third threshold are determined based on the system tolerance; wherein... The system tolerance is the minimum of the first tolerance and the second tolerance. The first tolerance is the difference between the number of nodes in the first system and the first threshold, and the second tolerance is the difference between the number of nodes in the first system and the third threshold.

8. A data processing method, characterized in that, Applied to the second node, the data processing method includes: Receive the first information sent by the first node in the first system; the first node is running in the leader state, and the second node is running in the follower state; Determine the performance indicators of the first node based on the first information; If the performance indicators meet the first condition in each round of election, a dissenting vote against the first node is sent to the first node in that round of election. The dissenting vote is cast by the corresponding second node under the condition that the performance indicators of the first node meet the relevant standards. If the number of dissenting votes received by the first node in each round of election in one or more rounds of election is higher than a first threshold, the working state of the first node is adjusted from the leader state to the follower state.

9. A data processing apparatus, characterized in that, include: The first sending unit is used to send first information to one or more second nodes in the first system; The first node runs in the leader state, and the second node runs in the follower state; The first receiving unit is configured to receive opposing votes against the first node in one or more rounds of election, wherein the opposing votes are sent by the corresponding second node under the condition that a first condition is met, the first condition including that the performance indicators of the first node meet relevant standards, and the performance indicators are obtained by the corresponding second node based on the first information. The first adjustment unit is used to adjust the working state from the leader state to the follower state when the number of opposing votes received by the first node in each round of the election in the one or more rounds of election is higher than a first threshold.

10. A data processing apparatus, characterized in that, include: The second receiving unit is used to receive the first information sent by the first node in the first system; The first node runs in the leader state, and the second node runs in the follower state; The first determining unit is configured to determine the performance indicators of the first node based on the first information. The second sending unit is configured to send a dissenting vote against the first node in each round of election, provided that the performance indicators meet a first condition. The dissenting vote is cast by the corresponding second node when the first condition is met, and the first condition includes that the performance indicators of the first node meet relevant standards. If the number of dissenting votes received by the first node in each round of election is higher than a first threshold, the working state of the first node is adjusted from the leader state to the follower state.

11. An electronic device, characterized in that, include: The processor and the memory used to store computer programs that can run on the processor. When the processor is used to run the computer program, it performs the steps of the method according to any one of claims 1 to 8.

12. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8.

13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8.