• 沒有找到結果。

Randomized Algorithm: Eager Probabilistic Broadcast

3.8 Probabilistic Broadcast

3.8.4 Randomized Algorithm: Eager Probabilistic Broadcast

Algorithm 3.9, called “Eager Probabilistic Broadcast,” implements probabilistic broadcast. The sender selects k processes at random and sends them the message.

In turn, each of these processes selects another k processes at random and forwards the message to those processes, and so on. The parameter k is called the fanout of a gossip algorithm. The algorithm may cause a process to send the message back to the same process from which it originally received the message, or to send it to another process that has already received the message.

Each step consisting of receiving a message and resending it is called a round of gossiping. The algorithm performs up to R rounds of gossiping for each message.

The description of the algorithm uses a functionpicktargets(k), which takes the fanout k as input and outputs a set of processes. It returns k random samples chosen from Π \ {self} according to the uniform distribution without replacement. The

Algorithm 3.9: Eager Probabilistic Broadcast Implements:

ProbabilisticBroadcast, instance pb.

Uses:

FairLossPointToPointLinks, instance fll.

upon eventpb,Initdo delivered:=; procedure gossip(msg)is

foralltpicktargets(k)do triggerfll,Send| t,msg; upon eventpb,Broadcast | m ⟩do

delivered:= delivered∪ {m}; triggerpb,Deliver|self,m; gossip([GOSSIP, self, m, R]);

upon eventfll,Deliver| p,[GOSSIP,s, m, r]do ifm̸∈deliveredthen

delivered:= delivered∪ {m}; triggerpb,Deliver| s,m;

ifr > 1then gossip([GOSSIP,s, m, r− 1]);

functionrandom(S) implements the random choice of an element from a set S for this purpose. The pseudo code looks like this:

function picktargets(k)returns set of processes is targets:=;

while#(targets) < kdo

candidate:=random\ {self}); if candidate̸∈targetsthen

targets:= targets∪ {candidate}; return targets;

The fanout is a fundamental parameter of the algorithm. Its choice directly im-pacts the performance of the algorithm and the probability of successful reliable delivery (in the probabilistic validity property of probabilistic broadcast). A higher fanout not only increases the probability of having the entire population infected but also decreases the number of rounds required to achieve this. Note also that the al-gorithm induces a significant amount of redundancy in the message exchanges: any given process may receive the same message many times. A three-round execution of the algorithm with fanout three is illustrated in Fig.3.6for a system consisting of nine processes.

However, increasing the fanout is costly. The higher the fanout, the higher the load imposed on each process and the amount of redundant information exchanged

(a) round 1 (b) round 2 (c) round 3 Figure 3.6:Epidemic dissemination or gossip (with fanout3)

over the network. Therefore, to select the appropriate fanout value is of particular importance. Note that there are runs of the algorithm where a transmitted message may not be delivered to all correct processes. For instance, all processes that receive the message directly from the sender may select exactly the same set of k target pro-cesses and forward the message only to them, and the algorithm may stop there. In such a case, if k is much smaller than N, not all processes will deliver the message.

As another example, there might be one process that is simply never selected by any process and never receives the message. This translates into the fact that reliable delivery is not guaranteed, that is, the probability that some process never delivers the message is nonzero. But by choosing large enough values of k and R in relation to N, this probability can be made arbitrarily small.

Correctness. The no creation and no duplication properties are immediate from the underlying point-to-point links and from the use of the variable delivered.

For the probabilistic validity property, the probability that for a particular broad-cast message, all correct processes become infected and deliver the message depends on the fanout k and on the maximum number of rounds R.

We now derive a simple estimate of the probability that a particular correct pro-cess delivers a message. Suppose that the underlying fair-loss links deliver every message sent by the first infected correct process (i.e., the original sender) but no further message; in other words, only the sender disseminates the broadcast mes-sage. In every round, a fraction of γ = k/N processes become infected like this (some may have been infected before). The probability that a given correct pro-cess remains uninfected is at most1 − γ. Hence, the probability that this process is infected after R rounds is at least about E1= 1 − (1 − γ)R.

Toward a second, more accurate estimate, we eliminate the simplification that only one process infects others in a round. Suppose a fraction of d = (N − f)/N processes are correct; assume further that in every round, the number of actually infected processes is equal to their expected number. Denote the expected number of infected and correct processes after round r by Ir. Initially, only the sender is infected and I0= 1. After round r for r > 0, we observe that Ir−1correct processes stay infected. Among the remaining N − Ir−1processes, we expect that a fraction of d is correct and a fraction of γ of them becomes infected:

0 0.2 0.4 0.6 0.8 1

0 5 10 15 20

Probability of delivery

Number of rounds (R) E1E2

Figure 3.7:Illustration of gossip delivery probability to one correct process using the

“Eager Probabilistic Broadcast” algorithm with R = 1, . . . , 20 rounds, in terms of estimates E1and E2from the text

Ir = Ir−1+ dγ(N − Ir−1).

As all Irprocesses infect others in round r + 1, the infections in round r + 1 spread about as fast as if one process would have infected the others during additional Ir

rounds. Summing this up over all R rounds, we obtain our second estimate: the probability of some correct process being infected after R rounds is about

E2 = 1 − (1 − γ)!R−1r=0 Ir.

The two estimates E1 and E2 of the delivery probability for one process are plot-ted in Fig.3.7 for a system of N = 100 processes, assuming that f = 25 faulty processes crash initially, and fanout k = 10.

Performance. The number of rounds needed for a message to be delivered by all correct processes also depends on the fanout. Every round involves one communi-cation step. The algorithm may send O(N) messages in every round and O(NR) messages in total, after running for R rounds; generally, the number of messages sent by the algorithm is dominated by the messages of the last round.