p2p systems: gossip protocols - cs.cornell.edu · spatial distribution d. 8 alan demers cornell...

61
P2P Systems: Gossip Protocols CS 6410 By Alane Suhr & Danny Adams 1

Upload: dinhtuyen

Post on 14-Jun-2019

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

P2P Systems: Gossip Protocols

CS 6410By Alane Suhr & Danny Adams

1

Page 2: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Outline

2

❖ Timeline❖ CAP Theorem❖ Epidemic algorithms for replicated database maintenance❖ Managing update conflicts in Bayou, a weakly connected

replicated storage system❖ Conclusion

A

Page 3: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Timeline

3

Lamport

Time, Clocks, and the Ordering of Events in a Distributed System

1978

Lamport

The Byzantine Generals Problem

1982

FLP

Impossibility of Distributed Consensus with One Faulty Process

1985

Demers

Epidemic algorithms for replicated database maintenance

1987

Schneider

Implementing fault-tolerant services using the state machine approach: A tutorial

1990

Terry

Managing update conflicts in Bayou, a weakly connected replicated storage system

1995

Lamport

The part-time parliament

1998

A

Page 4: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

CAP● Consistency -- all nodes contain the same state● Availability -- requests are responded to promptly● Partition

○ part of a system completely independent from the rest of the system

○ ideally should maintain itself autonomously● Partition tolerance -- system can stay online and functional

even when message passing fails4 A

Page 5: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

CAP Theorem

Paxos&

Gossip

● Paxos: prioritize consistency given a network partition

● Gossip: prioritize availability given a network partition

5 A

Page 6: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Gossip

6 D

Page 7: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Gossip Overview

7

❏ Authors❏ Motivations❏ Epidemic Models

❏ Direct Mail❏ Anti-Entropy❏ Rumor mongering

❏ Evaluation❏ DC’s❏ Spatial Distribution

D

Page 8: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

8

Alan DemersCornell University

Dan GreenePARC Research

Scott ShenkerEECS Berkeley

Doug TerryAmazon Web Services

Carl HauserPhD CornellWashington State University

Authors

D

Page 9: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Motivations

9

● Unreliable network● Unreliable nodes● CAP: *AP*

○ always be able to respond to a (read/write) request

○ eventual consistency

D

Page 10: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Epidemic Models

10 A

Page 11: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Proposers and Acceptors● Proposer

○ In Paxos: clients propose an update to the database○ Epidemic model: a node infects its neighbors

● Acceptor○ In Paxos: acceptor accepts an update based on one or

more proposals○ Epidemic model: a node is infected by a neighbor

11 A

Page 12: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Types of Epidemics❖ Direct Mail❖ Anti-Entropy❖ Rumor Mongering

12 A

Page 13: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Advantages

13

➢ Simple algorithms➢ High Availability➢ Fault Tolerant➢ Tunable➢ Scalable➢ Works in Partition

A

Page 14: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Direct Mail14

● Notify all neighbors of an update

● Timely and reasonably efficient

● n messages per update

D

Page 15: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Direct Mail

15 D

Page 16: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Direct Mail

16 D

Page 17: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Direct MailMessages sent: O(n) where n is number of neighbors

Not fault tolerant -- doesn’t guarantee eventual consistency

High volume of traffic with site at the epicenter

17 D

Page 18: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Anti-Entropy

18

❏ Site chooses random partner to share data

❏ Number of rounds til consistency: O(log n)

❏ Sites use custom protocols to resolve conflicts

❏ Fault tolerant

A

Page 19: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Anti-Entropy

19 A

Page 20: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Anti-Entropy

20 A

Page 21: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Anti-Entropy

21 A

Page 22: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Anti-Entropy

22 A

Page 23: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Anti-Entropy

23 A

Page 24: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Anti-Entropy

24 A

Page 25: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Anti-Entropy

25 A

Page 26: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Anti-Entropy

26 A

Page 27: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Anti-Entropy

27

What happens next?

A

Page 28: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

28

Mechanism: Push & Pull

D

Page 29: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Push vs. Pull Push Pull

29

{A, B} {A, C} {A, B} {A, C}

{A, B} {A,B,C} {A, B, C} {A, C}

D

Page 30: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

What is Push-Pull?

30

{A, B} {A, C}

{A, B, C} {A,B,C} D

Page 31: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Propagation times of Push vs. PullPush: Pi+1 = Pie

-1

P= Probability node hasn’t receivedupdate after the ith round

Pull: Pi+1= Pi2

31

Pull is faster!!

D

Page 32: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Rumor Mongering1. Sites choose a random neighbor to

share information with

2. Transmission rate is tuneable

3. How long new updates are interesting is also tuneable

4. Can use push or pull mechanisms

32 A

Page 33: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Rumor Mongering Complexity● O(ln n) rounds leads to consistency with

high probability● Push requires O(n ln n) transmissions

until consistency ● Further proved lower bound for all

push-pull transmissions: 0(n ln ln n)

33 Karp et al 2000. Randomized rumor spreading. In FOCS.A

Page 34: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Analogy to epidemiology● Susceptible: site does not know an update yet● Infective: actively sharing an update● Removed: updated and no longer sharing

Rumor mongering: nodes go from susceptible to infective and eventually (probabilistically) to removed

34 A

Page 35: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Rumor mongering

35 A

Page 36: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Rumor mongering

36 A

Page 37: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Rumor mongering

37 A

Page 38: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Rumor mongering

38 A

Page 39: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Rumor mongering

39 A

Page 40: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Rumor mongering

40 A

Page 41: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Rumor mongering

41 A

A

Page 42: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Rumor mongering Pros:

● Fast● Low call on resources● Fault-Tolerant● Less traffic

42

Cons:

● A site can potentially miss an update

A

Page 43: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Backups

● Anti-entropy can be used to “update” the network regularly after direct mail or rumor mongering

● If inconsistency found in anti-entropy, run the original algorithm again

43 D

Page 44: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Death Certificates

❖ How are items deleted using epidemic models?

44 D

Page 45: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

45

I like BreadI DON’T like Bread!

I like orange juice

D

Page 46: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Death Certificates

❖ How to remove items from epidemic model?

46 D

❖ Drawbacks➢ Space➢ Increases traffic➢ DC Can be lost

❖ Dormant death certificates & retention

Page 47: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Evaluating Epidemic Models➢ Residue: remaining susceptibles

when epidemic finishes➢ Traffic:

➢ Delay:○ Tavg: Average time between

start of outbreak and arrival of update @ given site

○ Tlast: Delay until last update

47 D

Page 48: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Spatial Distribution

HelpingOr

Hurting

48 A

Page 49: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Convergence Times and Traffic● Linear network: anti entropy

○ Nearest-neighbors■ O(n) convergence■ O(1) traffic

○ Random connections■ O(log(n)) convergence■ O(n) traffic

49 A

Page 50: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Optimizations for realistic network distributions● Select connections from

list of neighbors sorted by distance

● Treat network as linear● Compute probabilities

based on position in list

50 A

Page 51: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Rumor Mongering Non-Standard Distribution● Increase k --

number of rounds a rumor is “interesting”

● Use push-pull

51 A

Page 52: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Takeaways● Availability >> consistency● Updates can be expensive● Distribution protocols should be

robust● Network design can hurt overall

performance● Byzantine Behavior not addressed

Questions?

52 A

Page 53: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Managing update conflicts in Bayou, a weakly connected replicated storage system

1995

Additional Reading

53 D

Page 54: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

● Weak consistency makes unstable network applications possible

● Developing good interfaces allows for complex functions like merging to be interchangeable via the application

54 D

Page 55: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Timeline

55

Lamport

Time, Clocks, and the Ordering of Events in a Distributed System

1978

Lamport

The Byzantine Generals Problem

1982

FLP

Impossibility of Distributed Consensus with One Faulty Process

1985

Demers

Epidemic algorithms for replicated database maintenance

1987

Schneider

Implementing fault-tolerant services using the state machine approach: A tutorial

1990

Terry

Managing update conflicts in Bayou, a weakly connected replicated storage system

1995

Lamport

The part-time parliament

1998

D

Page 56: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

What is Bayou?● Storage system designed for

mobile computing○ Network is not stable○ Parts of the network may

not be connected all the time○ Goal: high availability○ Guarantees weak

consistency56 D

Page 57: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Bayou System Diagram57

Server

Client

ClientWrite (unique ID)

Server

Anti-Entropy

Read Request

Data

D

Page 58: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Consistent Replicas● Writes are first tentative● Eventually they are

committed, ordered by time● Clients can tell whether

writes are stable (committed)

● Primary servers deal with committing updates

58 A

Page 59: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Detecting and Resolving Conflicts

● Dependency checks● Merge procedures● Described by the clients,

application-dependent

59 A

Page 60: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

Conclusions● Distributed systems need a

form of consensus● Effectively choosing the

correct consensus model for a system has to be weighed carefully with the attributes of the system

60 A

Page 61: P2P Systems: Gossip Protocols - cs.cornell.edu · Spatial Distribution D. 8 Alan Demers Cornell University Dan Greene PARC Research Scott Shenker EECS Berkeley Doug Terry ... push-pull

AcknowledgementsContent Inspired by:

Ki Suh Lee: “Epidemic Techniques”[2009]

Eugene Bagdasaryan: “P2P Gossip Protocols” [2016]

Photos

www.pixabay.com

www.unsplash.com

www.1001freedownloads.com/free-cliparts

61 A