Docsity

Chord: A Scalable Peer-to-Peer Lookup Protocol, Study notes of Computer Science

Toggle sidebar
bg1
1
CS 598IG
Adv. Topics in Dist. Sys.
Spring 2006
Indranil Gupta
Lecture 3
January 24, 2006
DHT=Distributed Hash Table
• A hash table allows you to insert, lookup and
delete objects with keys
• A distributed hash table allows you to do the same
in a distributed setting (objects=files)
• Performance Concerns:
– Load balancing
– Fault-tolerance
– Efficiency of lookups and inserts
– Locality
• Napster, Gnutella, FastTrack are all DHTs
• So is Chord, a structured peer to peer system that
we study next
Comparative Performance
O(N)O(N)O(N)Gnutella
O(1)O(1)
(O(N)@server)
Napster
#Messages
for a lookup
Lookup
Latency
Memory
Comparative Performance
O(log(N))O(log(N))O(log(N))Chord
O(N)O(N)O(N)Gnutella
O(1)O(1)
(O(N)@server)
Napster
#Messages
for a lookup
Lookup
Latency
Memory
Chord
• Developers: I. Stoica, D. Karger, F. Kaashoek, H.
Balakrishnan, R. Morris, Berkeley and MIT
• Intelligent choice of neighbors to reduce latency
and message cost of routing (lookups/inserts)
• Uses Consistent Hashing on peer’s address
– SHA-1(ip_address,port) 160 bit string
– Truncated to m bits
– Called peer id (number between 0 and )
– Not unique but id conflicts very unlikely
– Can then map peers to one of logical points on a
circle
m
2
1
2
−
m
Ring of peers
N80
N112
N96
N16
0
Say m=7
N32
N45
6 nodes
pf3
pf4
pf5

Partial preview of the text

Download Chord: A Scalable Peer-to-Peer Lookup Protocol and more Study notes Computer Science in PDF only on Docsity!

CS 598IG

Adv. Topics in Dist. Sys.

Spring 2006

Indranil Gupta

Lecture 3

January 24, 2006

DHT=Distributed Hash Table

  • A hash table allows you to insert, lookup and

delete objects with keys

  • A distributed hash table allows you to do the same

in a distributed setting (objects=files)

  • Performance Concerns:
    • Load balancing
    • Fault-tolerance
    • Efficiency of lookups and inserts
    • Locality
  • Napster, Gnutella, FastTrack are all DHTs
  • So is Chord, a structured peer to peer system that

we study next

Comparative Performance

Gnutella O(N) O(N) O(N)

O(1) O(1)

(O(N)@server)

Napster

#Messages

for a lookup

Lookup

Latency

Memory

Comparative Performance

Chord O(log(N)) O(log(N)) O(log(N))

Gnutella O(N) O(N) O(N)

O(1) O(1)

(O(N)@server)

Napster

#Messages

for a lookup

Lookup

Latency

Memory

Chord

  • Developers: I. Stoica, D. Karger, F. Kaashoek, H.

Balakrishnan, R. Morris, Berkeley and MIT

  • Intelligent choice of neighbors to reduce latency

and message cost of routing (lookups/inserts)

  • Uses Consistent Hashing on peer’s address
    • SHA-1(ip_address,port) 160 bit string
    • Truncated to m bits
    • Called peer id (number between 0 and )
    • Not unique but id conflicts very unlikely
    • Can then map peers to one of logical points on a circle
2 m
2 m− 1

Ring of peers

N
N
N
N

Say m=7 0

N
N

6 nodes

Peer pointers (1): successors

N

Say m=7 0

N
N
N
N
N

(similarly predecessors)

Peer pointers (2): finger tables

N

80 + 2 80 + 2^10

80 + 2^2

80 + 2^3

80 + 2^4

80 + 2^5 80 + 2^6

Say m=

N
N
ith entry at peer with id n is first peer with id >= n + 2 i(mod 2 m)
N
N

i ft[i]^ N 0 96 1 96 2 96 3 96 4 96 5 112 6 16

Finger Table at N

What about the files?

  • Filenames also mapped using same consistent

hash function

  • SHA-1(filename) 160 bit string
  • File cnn.com/index.html that maps to key K42 is stored at

first peer with id greater than 42

  • Note that we are considering a different file-

sharing application here : cooperative web caching

  • The same discussion applies to any other file sharing application, including that of mp3 files.

Mapping Files

N

Say m=7 0

N
N

File with key K stored here

N
N
N

Search

N

Say m=7 0

N
N

File cnn.com/index.html with key K42 stored here

Who has cnn.com/index.html? (hashes to K42)

N
N
N

Search

N

Say m=7 0

N
N

File cnn.com/index.html with key K42 stored here

At node n, send query for key k to largest successor/finger entry < k if none exist, send query to successor(n)

N
N
N

Who has cnn.com/index.html? (hashes to K42)

Search under peer failures (2)

N

Say m=7 0

N
N

File cnn.com/index.html with key K42 stored here

X

X

Lookup fails (N45 is dead)

N
N
N

Who has cnn.com/index.html? (hashes to K42)

Search under peer failures (2)

N

Say m=7 0

N
N

File cnn.com/index.html with key K42 stored here

X

One solution: replicate file/key at r successors and predecessors

N
N
N

K42 replicated

K42 replicated

Who has cnn.com/index.html? (hashes to K42)

Need to deal with dynamic

changes

 Peers fail

  • New peers join
  • Peers leave

All the time

 Need to update successors and fingers, and copy

keys

New peers joining

N

Say m=7 0

N
N
N
N
N
N

Introducer directs N40 to N N32 updates successor to N N40 initializes successor to N45, and inits fingers from it N40 periodically talks to neighbors to update finger table

Stabilization protocol

New peers joining (2)

N

Say m=7 0

N
N
N
N
N
N

N40 may need to copy some files/keys from N (files with fileid between 32 and 40)

K34,K

New peers joining (3)

  • A new peer affects O(log(N)) other finger

entries in the system

  • Number of messages per peer join=

O(log(N)*log(N))

  • Similar set of operations for dealing with

peers leaving

Experimental Results

  • Sigcomm 01 paper had results from

simulation of a C++ prototype

  • SOSP 01 paper had more results from a 12-

node Internet testbed deployment

  • We’ll touch briefly on the first set
  • 10000 peer system

Solution: Each real node joins as r multiple virtual nodes smaller load variation, lookup cost is O(log(N*r)= O(log(N)+log(r))

Load Balancing

Large variance

Lookups

Average Messages per Lookup

Number of Nodes

log, as expected

Stabilization Protocol

  • Concurrent peer joins, leaves, failures might cause

loopiness of pointers, and failure of lookups

  • Chord peers periodically run a stabilization algorithm that checks and updates pointers and keys
  • Ensures non-loopiness of fingers, eventual success of lookups and O(log(N)) lookups w.h.p.
  • [TechReport on Chord webpage] defines weak and strong notions of stability
  • Each stabilization round at a peer involves a constant number of messages
  • Strong stability takes O( N^2 )stabilization rounds (!)

Fault-tolerance

500 nodes (avg. path len=5) Stabilization runs every 30 s

1 joins&fails every 10 s (3 fails/stabilization round) => 6% failed lookups

Numbers look fine here, but does stabilization scale with N?

Wrap-up Notes

  • Memory: O(log(N)) successor pointer, m finger entries
  • Indirection: store a pointer instead of the actual file
  • Does not handle partitions (can you suggest a possible

solution?)

Next Lecture

  • Sensor Networks and Theoretical

Distributed Computing – Basics

  • Please read papers / references from web page.

Please print out yourself

  • Signup for presentations by next Tuesday

A question before you go

What new design techniques about p2p

systems have you learnt in this class?

As you head out that door, think about at least

3 new design techniques (about p2p

systems) that you have learnt in this lecture.