chord: a scalable peer-to-peer lookup service for internet applications robert morris ion stoica,...

36
Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT and Berkeley

Upload: felicity-griffin

Post on 16-Dec-2015

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Chord: A Scalable Peer-to-peer Lookup Service for Internet

Applications

Robert MorrisIon Stoica, David Karger,

M. Frans Kaashoek, Hari Balakrishnan

MIT and Berkeley

Page 2: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

A peer-to-peer storage problem

• 1000 scattered music enthusiasts• Willing to store and serve replicas• How do you find the data?

Page 3: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

The lookup problem

Internet

N1

N2 N3

N6N5

N4

Publisher

Key=“title”Value=MP3 data… Client

Lookup(“title”)

?

Page 4: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Centralized lookup (Napster)

Publisher@

Client

Lookup(“title”)

N6

N9 N7

DB

N8

N3

N2N1SetLoc(“title”, N4)

Simple, but O(N) state and a single point of failure

Key=“title”Value=MP3 data…

N4

Page 5: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Flooded queries (Gnutella)

N4Publisher@

Client

N6

N9

N7N8

N3

N2N1

Robust, but worst case O(N) messages per lookup

Key=“title”Value=MP3 data…

Lookup(“title”)

Page 6: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Routed queries (Freenet, Chord, etc.)

N4Publisher

Client

N6

N9

N7N8

N3

N2N1

Lookup(“title”)

Key=“title”Value=MP3 data…

Page 7: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Routing challenges

• Define a useful key nearness metric• Keep the hop count small• Keep the tables small• Stay robust despite rapid change

• Freenet: emphasizes anonymity• Chord: emphasizes efficiency and

simplicity

Page 8: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Chord properties

• Efficient: O(log(N)) messages per lookup• N is the total number of servers

• Scalable: O(log(N)) state per node• Robust: survives massive failures

• Proofs are in paper / tech report• Assuming no malicious participants

Page 9: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Chord overview

• Provides peer-to-peer hash lookup:• Lookup(key) IP address• Chord does not store the data

• How does Chord route lookups?• How does Chord maintain routing

tables?

Page 10: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Chord IDs

• Key identifier = SHA-1(key)• Node identifier = SHA-1(IP address)• Both are uniformly distributed• Both exist in the same ID space

• How to map key IDs to node IDs?

Page 11: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Consistent hashing [Karger 97]

N32

N90

N105

K80

K20

K5

Circular 7-bitID space

Key 5Node 105

A key is stored at its successor: node with next higher ID

Page 12: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Basic lookup

N32

N90

N105

N60

N10N120

K80

“Where is key 80?”

“N90 has K80”

Page 13: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Simple lookup algorithm

Lookup(my-id, key-id)n = my successorif my-id < n < key-id

call Lookup(id) on node n // next hop

elsereturn my successor // done

• Correctness depends only on successors

Page 14: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

“Finger table” allows log(N)-time lookups

N80

½¼

1/8

1/161/321/641/128

Page 15: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Finger i points to successor of n+2i

N80

½¼

1/8

1/161/321/641/128

112

N120

Page 16: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Lookup with fingers

Lookup(my-id, key-id)look in local finger table for

highest node n s.t. my-id < n < key-idif n exists

call Lookup(id) on node n // next hop

elsereturn my successor // done

Page 17: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Lookups take O(log(N)) hops

N32

N10

N5

N20

N110

N99

N80

N60

Lookup(K19)

K19

Page 18: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Joining: linked list insert

N36

N40

N25

1. Lookup(36)K30K38

Page 19: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Join (2)

N36

N40

N25

2. N36 sets its ownsuccessor pointer

K30K38

Page 20: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Join (3)

N36

N40

N25

3. Copy keys 26..36from N40 to N36

K30K38

K30

Page 21: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Join (4)

N36

N40

N25

4. Set N25’s successorpointer

Update finger pointers in the backgroundCorrect successors produce correct lookups

K30K38

K30

Page 22: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Failures might cause incorrect lookup

N120

N113

N102

N80

N85

N80 doesn’t know correct successor, so incorrect lookup

N10

Lookup(90)

Page 23: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Solution: successor lists

• Each node knows r immediate successors• After failure, will know first live successor• Correct successors guarantee correct

lookups

• Guarantee is with some probability

Page 24: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Choosing the successor list length

• Assume 1/2 of nodes fail• P(successor list all dead) = (1/2)r

• I.e. P(this node breaks the Chord ring)• Depends on independent failure

• P(no broken nodes) = (1 – (1/2)r)N

• r = 2log(N) makes prob. = 1 – 1/N

Page 25: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Lookup with fault tolerance

Lookup(my-id, key-id)look in local finger table and successor-listfor highest node n s.t. my-id < n < key-idif n existscall Lookup(id) on node n // next hopif call failed,remove n from finger tablereturn Lookup(my-id, key-id)else return my successor // done

Page 26: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Chord status

• Working implementation as part of CFS

• Chord library: 3,000 lines of C++• Deployed in small Internet testbed• Includes:

• Correct concurrent join/fail• Proximity-based routing for low delay• Load control for heterogeneous nodes• Resistance to spoofed node IDs

Page 27: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Experimental overview

• Quick lookup in large systems• Low variation in lookup costs• Robust despite massive failure• See paper for more results

Experiments confirm theoretical results

Page 28: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Chord lookup cost is O(log N)

Number of Nodes

Avera

ge M

ess

ag

es

per

Looku

p

Constant is 1/2

Page 29: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Failure experimental setup

• Start 1,000 CFS/Chord servers• Successor list has 20 entries

• Wait until they stabilize• Insert 1,000 key/value pairs

• Five replicas of each

• Stop X% of the servers• Immediately perform 1,000 lookups

Page 30: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Massive failures have little impact

0

0.2

0.4

0.6

0.8

1

1.2

1.4

5 10 15 20 25 30 35 40 45 50

Faile

d L

ooku

ps

(Perc

en

t)

Failed Nodes (Percent)

(1/2)6 is 1.6%

Page 31: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Related Work

• CAN (Ratnasamy, Francis, Handley, Karp, Shenker)

• Pastry (Rowstron, Druschel)• Tapestry (Zhao, Kubiatowicz, Joseph)

• Chord emphasizes simplicity

Page 32: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Chord Summary

• Chord provides peer-to-peer hash lookup• Efficient: O(log(n)) messages per lookup• Robust as nodes fail and join• Good primitive for peer-to-peer systems

http://www.pdos.lcs.mit.edu/chord

Page 33: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT
Page 34: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

Join: lazy finger update is OK

N36

N40

N25

N2

K30

N2 finger should now point to N36, not N40Lookup(K30) visits only nodes < 30, will undershoot

Page 35: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

CFS: a peer-to-peer storage system

• Inspired by Napster, Gnutella, Freenet• Separates publishing from serving• Uses spare disk space, net capacity• Avoids centralized mechanisms

• Delete this slide?• Mention “distributed hash lookup”

Page 36: Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications Robert Morris Ion Stoica, David Karger, M. Frans Kaashoek, Hari Balakrishnan MIT

CFS architecturemove later?

Block storageAvailability / replicationAuthenticationCachingConsistencyServer selectionKeyword search

Lookup

Dhash distributedblock store

Chord

• Powerful lookup simplifies other mechanisms