Part IV — Peer-to-Peer & Decentralized Data · Chapter 3

Distributed hash tables: Chord

Hook

Consistent hashing tells you which node owns a key. But on a ring of a million nodes, how does the node you happen to be standing on actually find that owner — without asking all million of them, one by one?

Intuition
key@5·5A2B6C9D13
key@5 → owner B, resolved in 0 hops

Click through the three lookups. Some resolve in 0 hops — node A already knows the answer from its own successor pointer. Others take 1 or 2 jumps. Nobody ever walks the ring node by node; each hop leaps as far around the ring as it can without overshooting.

Formalize

Every node keeps a finger table: mm pointers, where finger ii points to the successor of a position exponentially further around the ring than finger i1i-1.

fingeri(n)=successor(n+2i),i=0,1,,m1\text{finger}_i(n) = \text{successor}(n + 2^i), \qquad i = 0, 1, \dots, m-1

A lookup for key kk starting at node nn jumps to the furthest finger that still lies strictly between nn and kk — never past it — repeating until kk falls inside the current node's own successor arc, at which point that successor is the owner.

  • mm — bits in the address space; 44 here, so 1616 ring positions and 44 fingers per node.
  • fingeri(n)\text{finger}_i(n) — node nn's ii-th finger: the successor of n+2in + 2^i.
  • successor(x)\text{successor}(x) — the same clockwise-successor rule as consistent hashing: the first node at or after position xx.
  1. Fingers double in reach
    • Finger 00 reaches 11 step ahead
    • Finger 11 reaches 22 steps ahead
    • Finger 22 reaches 44 steps ahead

    And so on — each finger roughly doubles how far around the ring it can see.

  2. At most m hops

    Because each hop at least halves the remaining clockwise distance to the target, no lookup on an mm-bit ring ever takes more than mm hops — O(logN)O(\log N) instead of walking every node.

Play
key@10·10A2B6C9D13
owner D, 2 hops — path A → B → C → D

Start from any of the 4 nodes and drag the target key all the way around the ring. Watch the path column: it never lists more than a couple of intermediate nodes, no matter how far the key sits from the start — each hop is a big leap, not a small step.

Worked example

Ring size 1616 (m=4m=4); nodes A@2, B@6, C@9, D@13 — the same ring the consistent-hashing chapter used:

  1. Node A's finger table
    • finger0(2)=successor(2+20)=successor(3)=6\text{finger}_0(2)=\text{successor}(2+2^0)=\text{successor}(3)=6
    • finger1(2)=successor(2+21)=successor(4)=6\text{finger}_1(2)=\text{successor}(2+2^1)=\text{successor}(4)=6
    • finger2(2)=successor(2+22)=successor(6)=6\text{finger}_2(2)=\text{successor}(2+2^2)=\text{successor}(6)=6
    • finger3(2)=successor(2+23)=successor(10)=13\text{finger}_3(2)=\text{successor}(2+2^3)=\text{successor}(10)=13

    So A's fingers are [6,6,6,13][6, 6, 6, 13].

  2. Lookup key@5 from A — 0 hops

    Key position 55 falls in (2,6](2, 6] — exactly the arc A's own finger 00 already covers. A answers immediately: owner is B (pos 6), no other node contacted.

  3. Lookup key@12 from A — 2 hops
    1. 1212 is past B's arc, so A jumps to its furthest finger that doesn't overshoot: 66 (node B)
    2. B's fingers are [9,9,13,2][9, 9, 13, 2]; 1212 is still past B's own successor (99), so B jumps to its furthest qualifying finger, 99 (node C)
    3. C's fingers are [13,13,13,2][13, 13, 13, 2]; now 1212 falls in (9,13](9, 13], C's own successor arc — so C answers directly: owner is D (pos 13)

    Path: A → B → C, 2 hops.

Checkpoint

Slide the target key so that a lookup starting at node A takes exactly 2 hops to resolve.

key@0·0A2B6C9D13
owner A, resolved in 1 hop
Drag the slider to pick a target key
Summary
fingeri(n)=successor(n+2i),hopsm=log2(ring size)\text{finger}_i(n) = \text{successor}(n + 2^i), \qquad \text{hops} \le m = \log_2(\text{ring size})

Chord layers a routing structure on top of the exact same ring consistent hashing already gave every node: instead of blindly asking neighbor after neighbor, each hop uses a finger table to leap as far as possible without passing the target, resolving any lookup in at most log2N\log_2 N hops. The next chapter looks at Kademlia, which routes with the same "jump toward the target" spirit but replaces the ring and its clockwise successor with a different distance metric entirely: XOR.