Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 12 Distributed Hash Tables CPE 401/601 Computer Network Systems slides are modified from Jennifer Rexford.

Similar presentations


Presentation on theme: "Lecture 12 Distributed Hash Tables CPE 401/601 Computer Network Systems slides are modified from Jennifer Rexford."— Presentation transcript:

1 Lecture 12 Distributed Hash Tables CPE 401/601 Computer Network Systems slides are modified from Jennifer Rexford

2 Hash Table r Name-value pairs (or key-value pairs) m E.g,. “Mehmet Hadi Gunes” and mgunes@cse.unr.edu m E.g., “http://cse.unr.edu/” and the Web page m E.g., “HitSong.mp3” and “12.78.183.2” r Hash table m Data structure that associates keys with values 2 lookup(key) valuekey value

3 Distributed Hash Table r Hash table spread over many nodes m Distributed over a wide area r Main design goals m Decentralization no central coordinator m Scalability efficient even with large # of nodes m Fault tolerance tolerate nodes joining/leaving 3

4 Distributed Hash Table r Two key design decisions m How do we map names on to nodes? m How do we route a request to that node? 4

5 Hash Functions r Hashing m Transform the key into a number m And use the number to index an array r Example hash function m Hash(x) = x mod 101, mapping to 0, 1, …, 100 r Challenges m What if there are more than 101 nodes? Fewer? m Which nodes correspond to each hash value? m What if nodes come and go over time? 5

6 Consistent Hashing r “view” = subset of hash buckets that are visible m For this conversation, “view” is O(n) neighbors m But don’t need strong consistency on views r Desired features m Balanced: in any one view, load is equal across buckets m Smoothness: little impact on hash bucket contents when buckets are added/removed m Spread: small set of hash buckets that may hold an object regardless of views m Load: across views, # objects assigned to hash bucket is small 6

7 Consistent Hashing 7 0 4 8 12 Bucket 14 Construction – Assign each of C hash buckets to random points on mod 2 n circle; hash key size = n – Map object to random position on circle – Hash of object = closest clockwise bucket Desired features – Balanced: No bucket responsible for large number of objects – Smoothness: Addition of bucket does not cause movement among existing buckets – Spread and load: Small set of buckets that lie near object Similar to that later used in P2P Distributed Hash Tables (DHTs) In DHTs, each node only has partial view of neighbors

8 Consistent Hashing r Large, sparse identifier space (e.g., 128 bits) m Hash a set of keys x uniformly to large id space m Hash nodes to the id space as well 8 01 Hash(name)  object_id Hash(IP_address)  node_id Id space represented as a ring 2 128 -1

9 Where to Store (Key, Value) Pair? r Mapping keys in a load-balanced way m Store the key at one or more nodes m Nodes with identifiers “close” to the key where distance is measured in the id space r Advantages m Even distribution m Few changes as nodes come and go… 9 Hash(name)  object_id Hash(IP_address)  node_id

10 Joins and Leaves of Nodes r Maintain a circularly linked list around the ring m Every node has a predecessor and successor 10 node pred succ

11 Joins and Leaves of Nodes r When an existing node leaves m Node copies its pairs to its predecessor m Predecessor points to node’s successor in the ring r When a node joins m Node does a lookup on its own id m And learns the node responsible for that id m This node becomes the new node’s successor m And the node can learn that node’s predecessor which will become the new node’s predecessor 11

12 Nodes Coming and Going r Small changes when nodes come and go m Only affects mapping of keys mapped to the node that comes or goes 12 Hash(name)  object_id Hash(IP_address)  node_id

13 How to Find the Nearest Node? r Need to find the closest node m To determine who should store (key, value) pair m To direct a future lookup(key) query to the node r Strawman solution: walk through linked list m Circular linked list of nodes in the ring m O(n) lookup time when n nodes in the ring r Alternative solution: m Jump further around ring m “Finger” table of additional overlay links 13

14 Links in the Overlay Topology r Trade-off between # of hops vs. # of neighbors m E.g., log(n) for both, where n is the number of nodes m E.g., such as overlay links 1/2, 1/4 1/8, … around the ring m Each hop traverses at least half of the remaining distance 14 1/2 1/4 1/8


Download ppt "Lecture 12 Distributed Hash Tables CPE 401/601 Computer Network Systems slides are modified from Jennifer Rexford."

Similar presentations


Ads by Google