ARCHIVED from builddistributedsystem.com on 2026-04-28 — URL: https://builddistributedsystem.com/tracks/advanced/tasks/task-10-2-dht
TASK

Implementation

Build Chord DHT: nodes on ring, finger tables for routing. Achieve O(log n) lookups in P2P network.

Sample Test Cases

Hash key to ringTimeout: 5000ms
Input
{"src":"c0","dest":"n1","body":{"type":"init","msg_id":1,"node_id":"n1","node_ids":["n1"]}}
{"src":"c1","dest":"n1","body":{"type":"chord_hash","msg_id":2,"key":"mykey","m":6}}
Expected Output
{"src":"n1","dest":"c0","body":{"type":"init_ok","in_reply_to":1,"msg_id":0}}
{"src":"n1","dest":"c1","body":{"type":"chord_hash_ok","in_reply_to":2,"msg_id":1,"hash":7}}

Hints

Hint 1
Each node has ID on hash ring
Hint 2
Finger table for O(log n) lookup
Hint 3
Handle node join/leave
OVERVIEW

Theoretical Hub

Chord DHT

Chord arranges nodes on hash ring. Finger tables point to nodes 2^i ahead for O(log n) hops. Used in P2P systems and some databases.

Key Concepts

DHTChordfinger table
main.py
python
Build Distributed Hash Table (Chord) - Advanced | Build Distributed Systems