Professional Documents
Culture Documents
Distributed Computing: Lecture 2: Decentralized Organization
Distributed Computing: Lecture 2: Decentralized Organization
Distributed Computing: Lecture 2: Decentralized Organization
The mapping of data items onto nodes in CAN. Splitting a region when a node joins
Unstructured Peer-to-Peer Architectures
Many unstructured P2P systems attempt to maintain a random
graph.
Basic principle:
Each node is required to contact a randomly selected other
node:
•Let each peer maintain a partial view of the network,
consisting of c other nodes
• Each node P periodically selects a node Q from its partial view
•P and Q exchange information and exchange members
from their respective partial views
Examples:
-Peers maintaining an index
(for search)
-Peers monitoring the state
of the network
-Peers being able to setup
connections
A hierarchical organization of nodes into a
superpeer network.
DHT: Distributed Hash Tables
• Principles
• Chord DHT
• Logical ring
• Finger table
• Lookup
• Examples
• (Reading: Section 5.2.3 of the textbook)
Chord an Example of DHT
10/71
1
How to Construct a DHT (Chord)?
• Use a logical name space, called the identifier space, consisting of identifiers
{0,1,2,…, N-1}
15 0 1
• Identifier space is a logical ring modulo N.
14
2
13 3
12 4
11 5
10 6
9 7
8
1
How to Construct a DHT (Chord)?
• Use a logical name space, called the identifier space, consisting of identifiers
{0,1,2,…, N-1}
15 0 1
• Identifier space is a logical ring modulo N.
14
• Every node picks a random identifier 2
though Hash H.
13 3
• Example:
Space N=16 {0,…,15} 12
Five nodes a, b, c, d, e 4
H(a) = 6
H(b) = 5 11 5
H(c) = 0
H(d) = 11
H(e) = 2 10 6
9 7
8
2
Successor ...
13 3
12 4
11 5
10 6
9 7
8
2
Successor ...
10 6
9 7
8
2
Connect the Nodes
12 4
11 5
10 6
9 7
8
3
Where to Store Data?
11 5
Hag
10 os
6
9 7
8
3
Where to Store Data?
H(''Challa'') = 2
H(''Hagos'') = 9 13 3
H(''Obang'') = 14
H(''Tizita'') = 4 12
Almaz Tizita
Hag
10 os
6
9 7
8
3
Where to Store Data?
14 Almaz
2
H(''Almaz'') = 12 Challa
H(''Challa'') = 2
H(''Hagos'') = 9 13 3
H(''Obang'') = 14
H(''Tizita'') = 4 12 4
Tizita
10 6
9 7
8
Lookup?
20/71
Lookup?
• To lookup a key k
Calculate H(k)
Follow succ pointers until item k is get(Hag
found 15 0 1 os)
Obang
14 Almaz
2
Challa
13 3
12 4
Tizita
Hag
11 os 5
10 6
9 7
8
Lookup?
• To lookup a key k
Calculate H(k)
Follow succ pointers until item k is get(Hag
found 15 0 1 os)
• Example Obang
Traverse nodes: 13
• 2, 5, 6, 11 (BINGO) 3
Return ''Jinka'' to initiator
12 4
Tizita
9 7
8
Lookup?
// ask node n to find the successor of id
procedure n.findSuccessor(id) {
if (predecessor nil and id (predecessor, n]) then return n
else if (id (n, successor]) then
return successor
else // forward the query around the circle
return successor.findSuccessor(id)
}
• (a, b] the segment of the ring moving clockwise from but not including a until and including b.
• n.foo(.) denotes an RPC of foo(.) to node n.
• n.bar denotes and RPC to fetch the value of the variable bar in node n.
Put and Get
procedure n.get(id) {
s = findSuccessor(id)
return s.retrieve(id)
}
24/73
How can we improve this?
25/71
Cost of Lookup Operations
14 Almaz
2
Challa
13 3
12 4
Tizita
Hag
11 os 5
10 6
9 7
8
Speeding up Lookups
• Finger/routing table:
Point to succ(n+1)
Point to succ(n+2)
Point to succ(n+4) 15 0 1
Point to succ(n+8) 14
… 2
Point to succ(n+2 )
M1
13 3
• Distance always halved to the
destination. 12 4
11 5
10 6
9 7
8
Speeding up Lookups
• Example: Log2(1000000)≈20 11 5
10 6
9 7
8
DHT Lookup
// ask node n to find the successor of id
procedure n.findSuccessor(id) {
if (predecessor nil and id (predecessor, n]) then return n
else if (id (n, successor]) then
return successor
else // forward the query around the circle
return successor.findSuccessor(id)
}
DHT Lookup
// ask node n to find the successor of id
procedure n.findSuccessor(id) {
if (predecessor nil and id (predecessor, n]) then return n
else if (id (n, successor]) then
return successor
else // forward the query around the circle
return successor.findSuccessor(id)
}
closestPrecedingNode(id)
DHT Lookup
// ask node n to find the successor of id
procedure n.findSuccessor(id) {
if (predecessor nil and id (predecessor, n]) then return n
else if (id (n, successor]) then
return successor
else { // forward the query around the circle
m := closestPrecedingNode(id)
return m.findSuccessor(id)
}
}
// search locally for the highest predecessor of id
procedure closestPrecedingNode(id) {
for i = m downto 1 do {
if (finger[i] (n, id)) then
return finger[i]
}
return n
}
Distributed Hash Tables
Example
Resolving key 26 from node 1, and key 12 from node 28 in a Chord system.
Example: Chord DHT
Chord finger tables
Chord lookup examples
o IF key > all FT entries:
a) If no wrapping in Finger table, send to FT[-1]
7 1 2 [2,3) 3
3 [3,5) 3
5 [5,1) 06
finger table keys
start int. succ. 6 2
7 [7,0) 0
0 [0,2) 0 finger table keys
2 [2,6) 3
5 3 start int. succ. 2
4 [4,5) 06
4 5 [5,7) 06
7 [7,3) 0
Node Departures – with Finger Tables
7 1 2 [2,3) 3
3 [3,5) 3
5 [5,1) 06
finger table keys
start int. succ. 6 6 2
7 [7,0) 0
0 [0,2) 0 finger table keys
2 [2,6) 3
5 3 start int. succ. 2
4 [4,5) 6
4 5 [5,7) 6
7 [7,3) 00
37
Chord lookup example