Lec14 Dhts
Lec14 Dhts
http://www.cs.princeton.edu/courses/archive/spr13/cos461/
Scalable algorithms for discovery
• If many nodes are available to
origin server
cache, which one should file be
assigned to?
Partitioning Problem
• Consider problem of data partition:
– Given document X, choose one of k servers to use
Consistent Hashing
insert(key 1,value)
lookup(key 1)
key1=value
Consistent Hashing
Consistent Hashing
0
• Construction 14
– Assign n hash buckets to random points
on mod 2k circle; hash key size = k 12 Bucket 4
• If a node fails: 8
• Routing correctness:
– Each node knows successor and
predecessor on ring
• Routing efficiency:
– Each node knows O(log n) well-
distributed neighbors
14
Routing Tables
Routing
For i in 1...log n:
finger[i] = successor ( (my.id + 2i ) mod 2160 )
17
• Monitor:
– If doesn’t respond for some time, find new
Storage models
• Store only on key’s immediate successor
– Churn, routing issues, packet loss make lookup
failure more likely
• Store on k successors
– When nodes detect succ/pred fail, re-replicate
– Use erasure coding: can recover with j-out-of-k
“chunks” of file, each chunk smaller than full replica
• Cache along reverse lookup path
– Provided data is immutable
– …and performing recursive responses
22
Summary
• Peer-to-peer systems
– Unstructured systems (next Monday)
• Finding hay, performing keyword search
– Structured systems (DHTs)
• Finding needles, exact match
• Distributed hash tables
– Based around consistent hashing with views of O(log n)
– Chord, Pastry, CAN, Koorde, Kademlia, Tapestry, Viceroy, …
• Lots of systems issues
– Heterogeneity, storage models, locality, churn management,
underlay issues, …
– DHTs deployed in wild: Vuze (Kademlia) has 1M+ active users