A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Distributed Hash Tables and DHT

Graduate Depth 88 in the knowledge graph ☐ I know this ☆ Set as goal
2topics build on this
477prerequisites beneath it
See this on the map →
Consistent HashingHash Tables→→Bloom Filters in Distributed SystemsData Sharding and Partitioning Strategies
dht peer-to-peer distributed-storage

Core Idea

Distributed hash tables (DHTs) extend hash tables across many machines using consistent hashing: keys hash to positions on a ring, each node stores a range, and lookups route toward the responsible node. DHTs enable decentralized storage (Chord, Kademlia) with logarithmic lookup time and automatic load balancing as nodes join and leave.

Explainer

You already understand hash tables — mapping keys to array positions for O(1) lookup — and consistent hashing — distributing keys around a ring so that adding or removing nodes only redistributes a fraction of keys. A distributed hash table combines these ideas into a fully decentralized storage system: data is spread across many machines, any machine can look up any key, and no central coordinator is needed. The core insight is that consistent hashing gives you a natural ownership model — each node is responsible for the keys that fall in its range on the hash ring — and the remaining problem is routing: how does a node that receives a query find the node that owns the key?

The naive approach is for every node to maintain a complete membership list and route directly, but that requires O(n) state per node and doesn't scale. Chord, one of the foundational DHT designs, solves this with a finger table: each node maintains pointers to O(log n) other nodes spaced at exponentially increasing distances around the ring. To look up a key, a node forwards the request to the closest predecessor of the key in its finger table, which does the same, and so on. Each hop cuts the remaining distance roughly in half, producing O(log n) hops to reach any key — similar to binary search. With 1,000 nodes, a lookup takes about 10 hops; with 1,000,000 nodes, about 20.

Kademlia, used in BitTorrent and IPFS, takes a different approach using XOR distance: the distance between two node IDs is their bitwise XOR, which forms a valid metric (symmetric, satisfies the triangle inequality). Each node maintains k-buckets — lists of known nodes at each XOR distance range. Lookups are iterative: the querying node contacts the α closest nodes it knows, asks them for nodes closer to the target, and repeats until it converges. Kademlia's advantage is that every lookup naturally refreshes routing information, and its XOR metric means the routing table fills unevenly — many entries for nearby nodes, few for distant ones — which is exactly the distribution you want for efficient routing.

When nodes join or leave, the DHT must rebalance. A joining node picks a random ID, looks up its position on the ring, and takes responsibility for the keys in its range — the predecessor transfers those keys. When a node fails, its keys become temporarily unavailable unless the system maintains replicas on successor nodes (most production DHTs replicate each key to k successors). The combination of consistent hashing for assignment, logarithmic routing for lookup, and replication for fault tolerance gives DHTs their characteristic properties: decentralized, scalable, and self-healing. These properties made DHTs the backbone of peer-to-peer file sharing and continue to underpin modern decentralized storage systems.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Conditional Statements → Defining and Calling Functions → Functions: Decomposing Problems → Function Parameters and Argument Passing → Return Values → Variable Scope → Introduction to Classes → Objects and Instances → Methods and Attributes → Algorithm Design Basics → Tree Structure and Node Properties → Binary Trees → Binary Tree Properties: Height, Balance, Completeness → Amortized Analysis → Hash Tables → Consistent Hashing → Distributed Hash Tables and DHT

Longest path: 89 steps · 477 total prerequisite topics

Prerequisites (2)

Leads To (2)