Performance Analysis of the Raft Consensus Algorithm for Private Blockchains

  • network model
    • premise:
      • Assuming the communication delay is much smaller than the heartbeat interval, a heartbeat is a step in the Markov chain
      • p: packet loss probability, assumed to be a continuous value for a given network
      • Et: The election timeout value of each round, selected in the given range [a,b]
      • τ: two heartbeat intervals
      • Using discrete and integer time scales
      • If the follower fails to accept K= [Et/τ ] heartbeats successfully, assume that there is currently no valid leader and then change to the candidate state to start the election.
        The K value is selected from the set, K ∈ {K1,K2,...,Kr}, K1 = [a/τ ], Kr = [b/τ ]
      • g(n): stage position of a given node at time n
      • b(n): the remaining value of the node's election timer at time n
      • P{i, ki − 1|i, ki} = P{g(n +1) = i, b(n + 1) = ki − 1|g(n) = i, b( n) = ki}
    • Unique non-zero one-step transition probability


      (1) Followers did not accept the current leader and then the election timer is reduced by 1
      (2) Followers received a heartbeat and then reset the election timer
      (3) The election timer is 0, and the follower turns into a candidate
      • When the election timeout value is unique in this state, r=1, t=K
        • Then the three formulas in special cases can be expressed as: k ∈ {1,...,K}. P is a (K+1, K+1) matrix
    • {i,0} is the absorbing state, i = 1, 2,...,r, and there are r absorbing states. Other states are temporary states, and there are t temporary states.

    • state transition matrix


      Q is a t×t matrix (qij is the possibility of transition from si state to sj state), R is a t×r non-zero matrix (rmn is the possibility of transitioning from transient state sm to absorbing state sn), and I is r×r unit matrix
  • Possibility of network split: When more than half of the N nodes become candidate nodes, the leader will be unqualified, resulting in network split
    • Case 1: N node network, transformation matrix like (8), split possibility before nth step

      • is the (1, K+1)th element of the Pn matrix; Yn is the number of nodes that transition to the n state before the nth step for all nodes starting from the initial state
      • Proof: P{Yn = m} is the probability that m nodes before the nth step become candidate nodes
        • In the case of P{Yn ≥ [(N/2)]+1}
      • Nature 1:
      • Property 2: When N tends to ∞, p(n)(k+1) tends to 0, the possibility of network splitting before the nth step
    • average number of responses
      • Step n expects participants to:

      • Step n follower:

      • In the nth step, the average number of replies collected by the leader is

    • The number of heartbeats the follower expects to receive
      • Theorem 2: A follower starts from the initial state and expects to receive n11 heartbeats before moving to the candidate state (n11 is the first item in the matrix)

        • Proof: According to the Markov chain
          • now that
          • The absolute value of the Q eigenvalue is less than 1, IQ is reversible, and is induced by N = (I − Q)^-1
          • When n tends to infinity, Q^n tends to 0, so when n tends to infinity
          • therefore,
          • Let X^(k)=1 if and only if the chain is in state sj after k steps, and 0 otherwise. Established when k=0:
          • Suppose the expected number of times the chain is in state sj in n steps before starting from state si
          • Comparing (34) and (30) proves when n tends to infinity
    • Time to Convert to Candidate
      • Theorem 3: Assuming the follower starts from the initial state, the expected time for the follower to transition to the candidate state is, n is the element of N

    • Time to elect a new leader:
      • Te=Et × Ne, Et is the timeout value uniformly selected from the range [a, b], Ne is the number of elections required to detect the failed leader and re-elect a new leader
      • The probability that the first candidate will win in an election round

      • Expected value of Ne

      • Te expected value (Etmax is the timeout maximum value)

  • Simulation Experiment: Effect of Packet Loss Rate, Election Timeout and Network Size on Availability and Network Split Probability
    • Validation of model validity: results and discrete event simulators validate probabilities (graphics illustrate validity)
      • Step 1: For each follower i, determine whether the follower receives a heartbeat according to a given packet loss rate. If the follower receives a heartbeat, the election time counter is reset. Otherwise, its election time counter is reduced by 1. If the election time counter is 0, it means follower i is a candidate, and follower i is removed from follower list.
      • Step 2: Add up the number of candidates. If the number of candidate nodes is greater than half of the total number of nodes, record time t as the network split time. Otherwise, update t = t + τ, go back to step 1
    • Comparing the probability and time of network splitting at different scales, the larger the network size, the better the stability of network splitting time
    • Compare the expectation and variance of the network split time under different packet loss rates, - increasing the election timeout can help reduce the probability of network split caused by packet loss, especially in the case of low packet loss rate
    • Compare the time interval for the follower to receive the heartbeat - the packet loss rate has a significant impact on the heartbeat interval of the receiving end, and the election timeout has no obvious effect
    • Compare the performance of Ne under different p values ​​- the average Ne of a large network is smaller than that of a small network, and when the packet loss rate p is small, the election of a large network is not as dependent on p as a small network
  • Contact with reality: mentioning that the probability of packet loss may lead to node crashes (without detailed expansion or explanation of the crash situation), a system efficiency evaluation index is proposed

Supongo que te gusta

Origin blog.csdn.net/qq_56061892/article/details/126135449
Recomendado
Clasificación