Kademlia, Chord, and Pastry: Understanding Distributed Hash Table Algorithms

Luis Soares
4 min readApr 28, 2023

Distributed Hash Tables (DHTs) are a class of decentralized distributed systems that provide a lookup service similar to hash tables, in which key-value pairs can be inserted, deleted, and retrieved.

DHTs are the foundation of many large-scale peer-to-peer (P2P) networks and are used in applications such as file-sharing systems, content distribution networks, and domain name systems.

Three of the most popular and widely studied DHT algorithms are Kademlia, Chord, and Pastry.

This article will comprehensively explain each, detailing their inner workings, advantages, and drawbacks.

Let's dive right in!

Kademlia

Kademlia was a P2P DHT protocol Petar Maymounkov and David Mazières proposed in 2002. It is based on the XOR metric, enabling it to achieve low-latency routing, logarithmic state, and lookup complexity.

Kademlia's main features are:

a. NodeID and Key Space: Kademlia represents nodes and keys with unique, fixed-length identifiers (NodeIDs and KeyIDs) in a binary space. The XOR distance between NodeIDs is used as a proximity metric.

b. Routing Table: Each node maintains a routing table consisting of k-buckets…

--

--

Luis Soares

Lead Software Engineer | Blockchain & ZKP Protocol Engineer | 🦀 Rust | Web3 | Solidity | Golang | Cryptography | Author