280 likes | 417 Views
Peer-to-peer systems. 6.033 Lecture 12, 2012 Frans Kaashoek. DP1: deadline Thursday 5p. A torrent file. { 'announce': 'http://bttracker.debian.org:6969/announce', 'info': { 'name': 'debian-503-amd64-CD-1.iso', 'piece length': 262144,
E N D
Peer-to-peer systems 6.033 Lecture 12, 2012 Frans Kaashoek DP1: deadline Thursday 5p
A torrent file { 'announce': 'http://bttracker.debian.org:6969/announce', 'info': { 'name': 'debian-503-amd64-CD-1.iso', 'piece length': 262144, 'length': 678301696, 'pieces': '841ae846bc5b6d7bd6e9aa3dd9e551559c82abc1...d14f1631d776008f83772ee170c42411618190a4' } }
K V K V K V K V K V K V K V K V K V K V K V A DHT in Operation: Peers
K V K V K V K V K V K V K V K V K V K V K V A DHT in Operation: Overlay
K V K V K V K V K V K V K V K V K V K V K V A DHT in Operation: put() put(K1,V1)
K V K V K V K V K V K V K V K V K V K V K V A DHT in Operation: put() put(K1,V1)
(K1,V1) K V K V K V K V K V K V K V K V K V K V K V A DHT in Operation: put()
K V K V K V K V K V K V K V K V K V K V K V A DHT in Operation: get() get(K1)
K V K V K V K V K V K V K V K V K V K V K V A DHT in Operation: get() get(K1) Challenge: nodes join and leave
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
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?
Consistent hashing Key 5 K5 Node 105 N105 K20 Circular 7-bit ID space N32 N90 K80 A key is stored at its successor: node with next higher ID
Basic lookup N120 N10 “Where is key 80?” N105 N32 “N90 has K80” N90 K80 N60
Simple lookup algorithm Lookup(my-id, key-id) n = my successor if my-id < n < key-id call Lookup(id) on node n // next hop else return my successor // done • Correctness depends only on successors
“Finger table” allows log(N)-time lookups ½ ¼ 1/8 1/16 1/32 1/64 1/128 N80
Finger i points to successor of n+2i N120 112 ½ ¼ 1/8 1/16 1/32 1/64 1/128 N80
Lookup with fingers Lookup(my-id, key-id) look in local finger table for highest node n s.t. my-id < n < key-id if n exists call Lookup(id) on node n // next hop else return my successor // done
Lookups take O(log(N)) hops N5 N10 N110 K19 N20 N99 N32 Lookup(K19) N80 N60
Joining: linked list insert N25 N36 1. Lookup(36) K30 K38 N40
Join (2) N25 2. N36 sets its own successor pointer N36 K30 K38 N40
Join (3) N25 3. Copy keys 26..36 from N40 to N36 N36 K30 K30 K38 N40
Join (4) N25 4. Set N25’s successor pointer N36 K30 K30 K38 N40 Update finger pointers in the background Correct successors produce correct lookups
Failures might cause incorrect lookup N120 N10 N113 N102 Lookup(90) N85 N80 N80 doesn’t know correct successor, so incorrect lookup
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
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
Lookup with fault tolerance Lookup(my-id, key-id) look in local finger table and successor-list for highest node n s.t. my-id < n < key-id if n exists call Lookup(id) on node n // next hop if call failed, remove n from finger table return Lookup(my-id, key-id) else return my successor // done
Other design issues • Concurrent joins • Locality • Heterogeneous node • Dishonest nodes • …
Summary • Peer-to-peer: server-less systems • Example: bittorrent • Peer-to-peer lookup • Example: Chord