250 likes | 436 Views
Chord: A Scalable Peer-to-Peer Lookup Service for Internet Applications. Ion Stoica Robert Morris David Liben-Nowell David R. Hari Balakrishnan Karger M. Frans Kaashoek Frank Dabek. 1097304151 莊宜豐. Outline.
E N D
Chord: A Scalable Peer-to-Peer Lookup Service for Internet Applications Ion Stoica Robert Morris David Liben-Nowell David R. Hari Balakrishnan Karger M. Frans Kaashoek Frank Dabek 1097304151 莊宜豐
Outline IntroductionChord ProtocolHashingFinger TableLookupSimple Scalable Conclusion
Introduction Peer-to-Peer Client / server architecture Slide 3
Chord Protocol : System Model • Load balance: • Chord acts as a distributed hash function, spreading keys evenly over the nodes. • Decentralization: • Chord is fully distributed: no node is more important than any other. • Scalability: • The cost of a Chord lookup grows as the log of the number of nodes, so even very large systems are feasible. • Availability: • Chord automatically adjusts its internal tables to reflect newly joined nodes as well as node failures, ensuring that, the node responsible for a key can always be found. • Flexible naming: • Chord places no constraints on the structure of the keys it looks up.
Chord:Distributed Hash Table • Chord provides support for just one operation: given a key, it maps the key onto a node. • Hashing function assigns each node and key an m-bit identifier usingSHA-1 base hash function. • Node’s IP address is hashed. • Each node has a m-bits node ID ( 0~2m-1) • Keys, too, are m-bit identifiers
N1 N56 N8 k54 k10 N51 N14 Circular ID Space N48 N21 N42 k24 k38 N38 k30 N32 An ID Ring of length 2m-1 m= 6
Chord:Distributed Hash Table • Each node, n, maintains a routing table with (at most) m entries, called the finger table.
Finger Table i=1 i=2 i=3 i=4 i=5 i=6 Bit=6 start.node() Successor()
start.node () When Node=8,i=3 start.node(n+2i-1=N12) i=3 i=4 When Node=8,i=4 start.node(n+2i-1=N16) Successor() start.node()
Successor () When Node=8,i=3 start.node(n+2i-1=N12) i=3 next.node(N14) Node=8,i=3 start.node(N12)<= next.node (N14) Successor(N12)=next.node (N14) =N14
Key/node space partitions start.node() i=4 start.node() i=3 i=2 N16 i=1 N12 N21 N8 N14 N14 N14 N21 Successor() Successor()
Simple Lookup lookup(k54) N1 N56 k54 N8 N51 N14 Circular ID Space N48 N21 N42 N38 N32
Scalable Lookup N1 N56 k54 N8 +1 N51 +2 +32 +8 +4 k10 +16 N14 N48 N21 N42 k24 k38 N38 k30 N32
Chord : Scalable LookupFind (K54) lookup(k54) N1 N56 k54 N8 +1 N51 +2 +32 +8 +4 +16 N14 N48 N21 N42 N38 N32
Lookup(K54) :N8 // ask node n to find the successor of id n.find_successor(id) if (id belongs to (n, successor]) // k54 belongs to (N8.N14) return successor; else n0 = closest preceding node(id); return n0.find_successor(id); // search the local table for the highest predecessor of id n.closest_preceding_node(id) for i = m downto 1 // i =6 if (finger[i] belongs to (n, id)) // finger[6] =42 belongs to (N8.K54) return finger[i]; return n;
Chord : Scalable LookupFind (K54) lookup(k54) N1 N56 k54 N8 N51 N14 N48 N21 N42 N38 N32
Lookup(K54) :N42 // ask node n to find the successor of id n.find_successor(id) if (id belongs to (n, successor]) // k54 belongs to (N42.N48) return successor; else n0 = closest preceding node(id); return n0.find_successor(id); // search the local table for the highest predecessor of id n.closest_preceding_node(id) for i = m downto 1 // i =4 if (finger[i] belongs to (n, id)) // finger[4] =51 belongs to (N42.K54) return finger[i]; return n;
Chord : Scalable LookupFind (K54) lookup(k54) N1 N56 k54 N8 N51 N14 N48 N21 N42 N38 N32
Lookup(K54) :N51 // ask node n to find the successor of id n.find_successor(id) if (id belongs to (n, successor]) // k54 belongs to (N51.N56) return successor; // return N56 else n0 = closest preceding node(id); return n0.find_successor(id); // search the local table for the highest predecessor of id n.closest_preceding_node(id) for i = m downto 1 if (finger[i] belongs to (n, id)) return finger[i]; return n;
IP Hash NoID • Data Hash DataID • Search Data Hash Key • DataID Hash Key • Search Data(Key) NoID DataID(Key) DataIP
A’s NoID=212 • 如果A有檔案”寶貝.mp3”經過hashing =88555 • B’s NoID=234 • 如果B有檔案”屋頂.mp3”經過hashing = 45651 • C’s NoID=555 • 如果A有檔案”麵包.mp3”經過hashing =14212 • D’s NoID=651 • 如果A有檔案”籃子.mp3”經過hashing = 66234 • 當搜尋者輸入欲搜尋的檔案,經過hash除以1000產生餘數, • 而餘數就是KEY值 • 假設A要搜尋籃子這首歌,經過hash得到KEY值234,所以尋找K234 • 而KEY234是歸B管,所以當A路由到B的時候,B會跟A說,檔案在D那 • 所以A就跑過去D那詢問,給不給下
Conclusion • Chord protocol solves it in a efficient decentralized manner • Routing information: O(log N) nodes • Lookup: O(log N) nodes • Update: O(log2 N) messages