epidemic algorithms

84
1 Epidemic Algorithms Slides by Amir H. Payberah ([email protected]), Jim Dowling

Upload: others

Post on 16-Oct-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Epidemic Algorithms

1

Epidemic Algorithms

Slides by Amir H. Payberah ([email protected]), Jim Dowling

Page 2: Epidemic Algorithms

2

● Motivations Existing information dissemination protocols have scalability problems.

Randomized protocols may have a smaller overhead.

Trade­off between reliability and scalability.

● Can be applied To large­scale distributed systems (millions of nodes).

When real­time information dissemination is not required.

Introduction

Page 3: Epidemic Algorithms

3

● Epidemics study the spread of a disease or infection in terms of populations of infected/uninfected individuals and their rates of change.

● How does it work?

Initially, a single individual is infective.

Individuals get in touch with each other, spreading the update.

● Our goal is to spread the infection (update) as fast and completely as possible!

Epidemic Protocols

Page 4: Epidemic Algorithms

4

● Anti­entropy

● Rumor mongering

Two Styles of Epidemic Protocols

Page 5: Epidemic Algorithms

5

● Each peer p periodically contacts a random partner q selected from the current population.

● Then, p and q engage in an information exchange protocol, where updates known to p but not to q are transferred from p to q (push), or vice­versa (pull), or in both direction (push­pull).

Anti­entropy

Page 6: Epidemic Algorithms

6

● Peers are initially ignorant.

● When an update is learned by a peer, it becomes a hot rumor.

● While a peer holds a hot rumor, it periodically chooses a random peer from the current population and sends (pushes) the rumor to it.

● Eventually, a node will lose interest in spreading the rumor.

Rumor Mongering

Page 7: Epidemic Algorithms

7

● Counter vs. Coin

Counter: lose interest after k contacts.

Coin (random): lose interest with probability 1/k.

● Feedback vs. Blind

Feedback: lose interest only if the recipient knows the rumor.

Blind: lose interest regardless of the recipient.

Rumor Mongering: Loss of Interest

Page 8: Epidemic Algorithms

8

● Participants’ load is independent of size

● Information spreads in log(system size) time.

% infe

cted

0.0

1.0

Time →

Epidemic Protocols Scale Very Nicely

Page 9: Epidemic Algorithms

9

● Aggregation protocols

● Membership management (Cyclon)

● Topology management (T­man)

● Etc.

Use of Epidemic Protocols

Page 10: Epidemic Algorithms

10

Aggregation Protocols

Page 11: Epidemic Algorithms

11

● Aggregation is a common name for a set of functions that provide an estimate of some global system property. 

● Aggregation functions enable local access to global information, in order to simplify the task of controlling, monitoring, and optimizing distributed applications. 

● Some examples of aggregation functions:

The average load of nodes in a distributed storage system.

The sum of free space in a distributed storage system.

The total number of nodes in a P2P system.

Aggregation Protocols 

Page 12: Epidemic Algorithms

12

// timed event timer(T time units) q = SelectPeer() send S to q

// handle event recv Sp from p send S to p S = Update(S,Sp)

A Generic Aggregation Framework

// handle event recv Sq from q

S = Update(S,Sq)

Page 13: Epidemic Algorithms

13

● Local state maintained by nodes:  a real number representing the value to be averaged.

● selectPeer() performs a random selection among the set of current nodes.

● update(sp, sq) Avg: return (sp+sq)/2

Max: return max(sp,sq)

Some Comments

Page 14: Epidemic Algorithms

14

164

36

8

102

Average Aggregation (1/5)

Page 15: Epidemic Algorithms

15

164

36

8

102

Average Aggregation (2/5)

Page 16: Epidemic Algorithms

16

164

36

8

66

(10 + 2) / 2 = 6

Average Aggregation (3/5)

Page 17: Epidemic Algorithms

17

164

36

8

66

Average Aggregation (4/5)

Page 18: Epidemic Algorithms

18

1010

36

8

66

(16 + 4) / 2 = 10

Average Aggregation (5/5)

Page 19: Epidemic Algorithms

19

● If the graph is connected, each node converges to the average of the original values.

● After each exchange the variance is reduced.

Some Comments

Page 20: Epidemic Algorithms

20

Illustration of Averaging

Page 21: Epidemic Algorithms

21

● Any ideas?

Network Size Estimation

Page 22: Epidemic Algorithms

22

● Any ideas?

● All nodes set their states to 0.

● The initiator sets its state to 1 and starts gossiping for the average.

● Eventually (after predefined k rounds) all nodes converge to the avg=1/N.

Network Size Estimation

Page 23: Epidemic Algorithms

23

Membership Management

Page 24: Epidemic Algorithms

24

● In a gossip­based protocol, each node in the system periodically exchanges information with a subset of peers.

● The choice of this subset is crucial.

● Ideally, the peers should be selected following a uniform random sample of all nodes currently in the system.

Membership Management

Page 25: Epidemic Algorithms

25

● Each node may be assumed to know every other node in the system.

● However, providing each node with a complete membership table from which a random sample can be drawn, is unrealistic in a large­scale dynamic system.

Achieving a Uniform Random Sample

Page 26: Epidemic Algorithms

26

● Peer sampling

● Every node maintains a relatively small local membership table that provides a partial view on the complete set of nodes.

● Periodically refreshes the table using a gossiping procedure.

An Alternative Solution

Page 27: Epidemic Algorithms

27

// timed event every T time unitshandle q = view.SelectPeer() buf = ((myAddress, 0)) view.permute() move oldest H items to the end of view buf.append(view.head(c/2-1)) send buf to q recv bufq from q view.select(c, H, S, bufq) view.increaseAge()

Peer Sampling Generic Framework (1/3)

Page 28: Epidemic Algorithms

28

// receiver handler handle recv bufp from p buf = ((myAddress, 0)) view.permute() move oldest H items to the end of view buf.append(view.head(c/2-1)) send buf to p view.select(c, H, S, bufp) view.increaseAge()

Peer Sampling Generic Framework (2/3)

Page 29: Epidemic Algorithms

29

// view select methodmethod view.select(c, H, S, bufp) view.append(bufp) view.removeDuplicates() view.removeOldItems(min(H, view.size-c)) view.removeHead(min(S, view.size-c)) view.removeAtRandom(view.size-c)

Peer Sampling Generic Framework (3/3)

Page 30: Epidemic Algorithms

30

● Peer Selection Rand: uniform random

Tail: highest age

● View Propagation Push

Push­Pull

● View Selection Blind: H = 0, S = 0

Healer: H = c / 2

Swapper: H = 0, S = c / 2

Design Space

Peer Selection

View Propagation

View Selection

Rand

Tail

Push Push-Pull

Blind

Heale

r

Swappe

r

Page 31: Epidemic Algorithms

31

Gossip­based Peer Sampling Protocol (1/7)

n1n2

n3

n4n5

n6n7

n8

n9

n10

n11

Page 32: Epidemic Algorithms

32

Gossip­based Peer Sampling Protocol (2/7)

n1n2

n3

n4n5

n6n7

n8

n9

n10

n11

n8n7n10n5

n1n6n3n11

Page 33: Epidemic Algorithms

33

Gossip­based Peer Sampling Protocol (3/7)

n1n2

n3

n4n5

n6n7

n8

n9

n10

n11

n8n7n10n5

n1n6n3n11

shuffle request

n8n7

Page 34: Epidemic Algorithms

34

Gossip­based Peer Sampling Protocol (4/7)

n1n2

n3

n4n5

n6n7

n8

n9

n10

n11

n8n7n10n5

n1n6n3n11

shuffle response

n1n6

n8n7

Page 35: Epidemic Algorithms

35

Gossip­based Peer Sampling Protocol (5/7)

n1n2

n3

n4n5

n6n7

n8

n9

n10

n11

n8n7n10n5

n1n6n3n11

n1n6

n8n7

Page 36: Epidemic Algorithms

36

Gossip­based Peer Sampling Protocol (6/7)

n1n2

n3

n4n5

n6n7

n8

n9

n10

n11

n8n7n10n5

n1n3n6n11

n1n6

n8n7

UpdateState

UpdateState

Page 37: Epidemic Algorithms

37

Gossip­based Peer Sampling Protocol (7/7)

n1n2

n3

n4n5

n6n7

n8

n9

n10

n11

n8n7n10n5

n1n3n3n11

n1n6

n8n7

Page 38: Epidemic Algorithms

38

● Peer Selection Rand: uniform random

Tail: highest age

● View Propagation Push

Push­Pull

● View Selection Blind: H = 0, S = 0

Healer: H = c / 2

Swapper: H = 0, S = c / 2

Newscast as a Peer Sampling Example

Peer Selection

View Propagation

View Selection

Rand

Tail

Push Push-Pull

Blind

Heale

r

Swappe

r

Page 39: Epidemic Algorithms

39

Newscast (1/7)

n1

n3

n5

n6n7

n10

n11Id, timen7, 9n10, 16n5, 12

Id, timen1, 7n3, 14n6, 10

Page 40: Epidemic Algorithms

40

Newscast (2/7)

n1

n3

n5

n6n7

n10

n11Id, timen7, 9n10, 16n5, 12

● Pick a random peer from my view

Id, timen1, 7n3, 14n6, 10

Page 41: Epidemic Algorithms

41

Newscast (3/7)

n1

n3

n5

n6n7

n10

n11Id, timen7, 9n10, 16n5, 12

● Pick a random peer from my view

● Send each other view + own fresh link

Id, timen1, 7n3, 14n6, 10

Id, timen7, 9n10, 16n5, 12

Id, timen11, 20

Page 42: Epidemic Algorithms

42

Newscast (4/7)

n1

n3

n5

n6n7

n10

n11Id, timen7, 9n10, 16n5, 12

● Pick a random peer from my view

● Send each other view + own fresh link

Id, timen1, 7n3, 14n6, 10

Id, timen7, 9n10, 16n5, 12

Id, timen1, 7n3, 14n6, 10

Id, timen11, 20

Id, timen5, 20

Page 43: Epidemic Algorithms

43

Newscast (5/7)

n1

n3

n5

n6n7

n10

n11Id, timen7, 9n10, 16n5, 12

● Pick a random peer from my view

● Send each other view + own fresh link

● Keep c freshest links (remove own info and duplicates)

Id, timen1, 7n3, 14n6, 10

Id, timen7, 9n10, 16n5, 12

Id, timen1, 7n3, 14n6, 10

Id, timen11, 20

Id, timen5, 20

Page 44: Epidemic Algorithms

44

Newscast (6/7)

n1

n3

n5

n6n7

n10

n11Id, timen7, 9n10, 16n5, 12

● Pick a random peer from my view

● Send each other view + own fresh link

● Keep c freshest links (remove own info and duplicates)

Id, timen1, 7n3, 14n6, 10

Id, timen7, 9n10, 16n5, 12

Id, timen1, 7n3, 14n6, 10

Id, timen11, 20

Id, timen5, 20

Page 45: Epidemic Algorithms

45

Newscast (7/7)

n1

n3

n5

n6n7

n10

n11Id, timen3, 14n10, 16n5, 20

● Pick a random peer from my view

● Send each other view + own fresh link

● Keep c freshest links (remove own info and duplicates)

Id, timen3, 14n10, 16n11, 20

Page 46: Epidemic Algorithms

46

● Peer Selection Rand: uniform random

Tail: highest age

● View Propagation Push

Push­Pull

● View Selection Blind: H = 0, S = 0

Healer: H = c / 2

Swapper: H = 0, S = c / 2

Cyclon as a Peer Sampling Example

Peer Selection

View Propagation

View Selection

Rand

Tail

Push Push-Pull

Blind

Heale

r

Swappe

r

Page 47: Epidemic Algorithms

47

Cyclon (1/5)

n1

n3

n5

n6n7

n10

n11Id, timen7, 9n10, 16n5, 4

Id, timen1, 7n3, 14n6, 10

Page 48: Epidemic Algorithms

48

Cyclon (2/5)

n1

n3

n5

n6n7

n10

n11Id, timen7, 9n10, 16n5, 4

Id, timen1, 7n3, 14n6, 10

● Pick the oldest peer from my view and remove it from the view.

Page 49: Epidemic Algorithms

49

Cyclon (3/5)

n1

n3

n5

n6n7

n10

n11Id, timen7, 9n10, 16 Id, time

n1, 7n3, 14n6, 10

● Pick the oldest peer from my view and remove it from the view.

● Exchange some of the peers in neighbours (swap policy)

● The active peer sends its fresh address

Id, timen10, 9n11, 20

Page 50: Epidemic Algorithms

50

Cyclon (4/5)

n1

n3

n5

n6n7

n10

n11Id, timen7, 9n10, 16 Id, time

n1, 7n3, 14n6, 10

● Pick the oldest peer from my view and remove it from the view.

● Exchange some of the peers in neighbours (swap policy). 

● The active peer sends its fresh address

Id, timen10, 9n11, 20

Id, timen3, 14n6, 10

Page 51: Epidemic Algorithms

51

Cyclon (5/5)

n1

n3

n5

n6n7

n10

n11Id, timen7, 9n3, 14n6, 10

Id, timen1, 7n10, 9n11, 20

● Pick the oldest peer from my view and remove it from the view.

● Exchange some of the peers in neighbours (swap policy). 

● The active peer sends its fresh address

Page 52: Epidemic Algorithms

52

Cyclon Properties: Connectivity

● In a fail­free environment, no peer becomes disconnected in the undirected graph.

● Pointers move, so peers change from being neighbor of one peer to being the neighbor of another peer

Page 53: Epidemic Algorithms

53

Cyclon Properties: Convergence

● Starting from a state, where peers are connected in a chain.

● Convergence is defined by having the same average path length as a random graph.

Page 54: Epidemic Algorithms

54

Cyclon Properties: Clustering Coefficient

● Clustering Coefficient (of a node): the ratio of existing links among the node’s neighbors over the total number of possible links among them.

● Shows what percentage the neighbors of a node are also neighbors among themselves.

Page 55: Epidemic Algorithms

55

Cyclon Properties: lndegree Distribution

Page 56: Epidemic Algorithms

56

Topology Management

Page 57: Epidemic Algorithms

57

T­Man

● T­man is a protocol that can construct and maintain any topology with the help of a ranking function.

● The ranking function orders any set of nodes according to their desirability to be neighbors of a given node

Page 58: Epidemic Algorithms

58

// timed event every T time unitshandle q = view.selectPeer() myDescriptor = (myAddress, myProfile) buf = merge(view, myDescriptor) buf = merge(buf, rnd.view) send buf to q recv bufq from q

buf = merge(bufq,view) view = selectView(buf)

A Generic T­Man Framework (1/2)

Page 59: Epidemic Algorithms

59

// receiver handlerHandle

recv bufp from p myDescriptor = (myAddress, myProfile) buf = merge(view, myDescriptor) buf = merge(buf, rnd.view) send buf to p buf = merge(bufp,view) view = selectView(buf)

A Generic T­Man Framework (2/2)

Page 60: Epidemic Algorithms

60

Some Comments

● SelectPeer Sort all nodes in the view based on ranking. Pick randomly one node from the first half.

● rnd.view provides a random sample of the nodes from the entire network, e.g., 

using cyclon

● SelectView Sort all nodes in buffer (about double size of the view) Pick out c highest ranked nodes.

Page 61: Epidemic Algorithms

61

Ranking Function

● Sample ranking functions: Line: d(a, b) = |a – b| Ring: d(a, b) = min(N ­ |a – b|, |a – b|)

Page 62: Epidemic Algorithms

62

Illustration of T­Man

Page 63: Epidemic Algorithms

63

Connectivity Problemson the Open Internet

Page 64: Epidemic Algorithms

64

NAT Environments (1/4)

n1

n2n3

n4

n5

n6

n7

n8

n9

n10

n11

Private node

Public node

shuffle request

Page 65: Epidemic Algorithms

65

NAT Environments (1/4)

n1

n2n3

n4

n5

n6

n7

n8

n9

n10

n11

Private node

Public node

shuffle response

Page 66: Epidemic Algorithms

66

NAT Environments (1/4)

n1

n2n3

n4

n5

n6

n7

n8

n9

n10

n11

Private node

Public node

shuffle response

UpdateState

UpdateState

Page 67: Epidemic Algorithms

67

NAT Environments (1/4)

n1

n2n3

n4

n5

n6

n7

n8

n9

n10

n11

Private node

Public node

shuffle request

Page 68: Epidemic Algorithms

68

Solutions for Communicating with Private Nodes (1/2)

● Relay communications to the private node using a public relay node.

Page 69: Epidemic Algorithms

69

Solutions for Communicating with Private Nodes (2/2)

● Use a NAT hole­punching algorithm to establish a direct connection to the private node using a public rendezvous node.

Page 70: Epidemic Algorithms

  70

Relaying or Hole Punching?

● Relaying?

Lower latency message exchange.

• Enables lower gossip cycle periods. 

• Necessary in dynamic networks

● Hole punching?

Decreases load on public nodes.

• But not if shuffle messages are small.

Page 71: Epidemic Algorithms

  71

Gozar as a NAT­aware Peer Sampling Example

● In Gozar, each private node connects to one or more public nodes, called partners that act as a relay or rendezvous server on behalf of the private node.

● A node's descriptor consists of both its own address, its NAT type, and its partners' addresses at the time of descriptor creation.

● When a node wants to gossip with a private node, it uses the partner addresses in its descriptor to communicate with the private node.

Page 72: Epidemic Algorithms

72

Partnering (1/10)

Bootstrap servern1n1

n2

n3

n4

n5

...

...

...

...

Page 73: Epidemic Algorithms

73

Partnering (2/10)

Bootstrap servern1n1

n2

n3

n4

n5

...

...

...

...

Page 74: Epidemic Algorithms

74

Partnering (3/10)

Bootstrap servern1n1

n2

n3

n4

n5n1, public, nulln4, public, null...

...

...

...

...

Page 75: Epidemic Algorithms

75

Partnering (4/10)

Bootstrap servern1n1

n2

n3

n4

n5n1, public, nulln4, public, null...

request

request

...

...

...

...

Page 76: Epidemic Algorithms

76

Partnering (5/10)

Bootstrap servern1n1

n2

n3

n4

n5n1, public, nulln4, public, null...

ACK

NACK

...

...

...

...

Page 77: Epidemic Algorithms

77

Partnering (6/10)

Bootstrap servern1n1

n2

n3

n4

n5n1, public, nulln4, public, null...

...

...

...

...

Page 78: Epidemic Algorithms

78

Partnering (7/10)

Bootstrap servern1n1

n2

n3

n4

n5n1, public, nulln4, public, null...

Shuffle exchange

n2, private, n1...

...

...

...

Page 79: Epidemic Algorithms

79

Partnering (8/10)

Bootstrap servern1n1

n2

n3

n4

n5n1, public, nulln4, public, null...

Shuffle exchange

n2, private, n1...

n2, private, n1...

...

...

Page 80: Epidemic Algorithms

80

Partnering (9/10)

Bootstrap servern1n1

n2

n3

n4

n5n1, public, nulln4, public, null...

Shuffle request

n2, private, n1...

n2, private, n1...

...

...

Page 81: Epidemic Algorithms

81

Partnering (10/10)

Bootstrap servern1n1

n2

n3

n4

n5n1, public, nulln4, public, null...

Shuffle response

n2, private, n1...

n2, private, n1...

...

...

Page 82: Epidemic Algorithms

82

Summary

Page 83: Epidemic Algorithms

  83

Summary

● Epidemics algorithms are important technique to solve problems in dynamic large scale systems

Scalable

Simple

Robust to node failures, message loss and transient network disruptions (network partitions … )

● Applications:

Aggregation

Membership management

Topology management

Page 84: Epidemic Algorithms

84

Question

AcknowledgementSome slides were derived from the slides of Alberto Montresor and Seif Haridi