Chord
Base Chord Protocol:
Specifies:
- How to find the location of keys
- How new nodes join the system
- How to recover from the failure of nodes
Overview:
Chord provides fast distributed computation of a hash function mapping keys to the nodes that are responsible for them.
Uses consistent hashing:
- Balances load - all. nodes receive roughly the same number of keys
- When a Nth node joins or leaves the network only a keys are moved
A Chord node needs only a small amount of routing information about other nodes. Because this information is distributed a node resolve the has function by communicating with a few other nodes.
Consistent Hashing:
The consistent hash function assigns each node and key an m-bit identifier using a base hash function such as SHA-1
A nodes identifier is obtained by hashing its IPAddress A keys identifier is obtained by hashing the key itself
the identifier length m must be long enough to make the probability of two nodes or keys having the same identifier negligible.
- Identifiers are ordered in an identifier circle modulo
- Key is assigned to the first node whose identifier is equal to or follows the identifier of in the identifier space
- This node is called the successor node denoted
To maintain consistent hashing mapping when a node joins the network, certain keys previously assigned to ’s successors now become assigned to
When node leaves the network, all of its assigned node are reassigned to its successor
Scalable Key Location:
Each node need only be aware of its successor node on the circle. Queries for a given identifier can be passed around the circle via these successor pointers until they first encounter a node that succeeds the identifier; this is the node the query maps to.
This resolution scheme is inefficient: it may require traversing all nodes to find the appropriate mapping.
Chord maintains additional routing information to accelerate this process
- let be the number of bits in the key/node identifiers. Each node, , maintains a routing table with (at most) entries, called the finger table.
- The th entry in the table at node contains the identity of the first node, , that succeeds by at least on the identifier circle, i.e., , where (and all arithmetic is ).
- Finger table contains both the identifier and the IPAddress of the relevant node.
If node contacts a node such that falls between and , find_predecessor is done and returns . Otherwise node asks , for the node knows about that most closely precedes . Thus the algorithm always makes progress towards the predecessor of .
Node Joins:
In a dynamic network, nodes can join (and leave) at any time.
The main challenge in implementing these operations is preserving the ability to locate every key in the network. To achieve this goal, Chord needs to preserve two invariants:
- Each nodes successor is correctly maintained
- For every key , node is responsible for
To preserve the invariant stated above, Chord must perform three tasks when a node joins the network:
- Initialise the predecessor and finger table of new node
- Update the finger table and predecessors of the existing nodes
- Notify the higher layer software so that it can transfer state associated with keys that node is now responsible for
