IT PAPER DEEP-READ · PAPER 57

Chord (Distributed Hash Table / DHT)

Stoica, Morris, Karger, Kaashoek, Balakrishnan · MIT · SIGCOMM 2001

中文 →

What did this paper do?

In 2001, a team at MIT introduced Chord to answer the most brutal question in any P2P (peer-to-peer — no central server, everyone equal) system: with millions of computers switching on and off at random, who actually holds the file I want? Chord's answer is startlingly elegant — no central directory of any kind, yet any machine can figure out "who is responsible for this thing" in just a few steps. Today BitTorrent's decentralized network, Amazon's distributed databases, and blockchain peer discovery all rest on this idea.

The old world's two clumsy tricks

Back then there were only two ways to find a file, both bad. One was the Napster way: run a central server that tracks "who has what" — fast to search, but shut that machine down and the whole network dies (and it was in fact sued into shutdown). The other was the Gnutella way: no center, so just ask everyone — shout "who has this file?" to all your neighbors, who shout to theirs, and so on. With many peers the network fills up with this shouting: slow, and no guarantee you ever reach the answer. Fear the single point of failure, or drown in the crowd — there had to be a third road.

The idea: arrange everyone in a circle

Chord's idea is remarkably clean. Picture a circular street whose house numbers run from 0 up to something enormous and then wrap back to 0. Every computer takes a spot on the circle by its number; every file also gets a number and lands somewhere on the circle. There is exactly one rule: a file is kept by the first computer you meet walking clockwise from its spot. So "who is responsible for this file" needs no asking — compute the number, walk clockwise to the nearest neighbor, done.

How do you find it in a few steps? A "doubling address book"

A circle alone isn't fast enough: if you only know the very next neighbor, reaching a file across the circle means passing it one seat at a time — far too slow. Chord's trick is to give each computer a special address book holding the neighbors that sit 1 step, 2 steps, 4, 8, 16… (each time doubling) away around the circle. To find something, you jump to whichever of those neighbors is closest to the target without overshooting — and every jump cuts the remaining distance to the target roughly in half, like a number-guessing game that always guesses the middle, or flipping to the middle of a dictionary. The upshot: even with a million machines, only about twenty hops to arrive — and each machine needs to remember only about twenty neighbors, not everyone.

Nobody in charge, and it still heals itself

The worst part of P2P is the churn: machines join and leave constantly. Chord doesn't "freeze the whole network and re-sort." Instead each machine periodically asks its clockwise neighbor "who's just ahead of you?" — and if a newcomer has slipped in between, quietly fixes its pointer. Who comes and goes only touches the little stretch of the circle around them; everyone else carries on. The network has no command center, yet keeps patching itself into a working map. One honest cost: during violent turmoil (masses joining and leaving at once), pointers may lag and a lookup can briefly fail or miss — and Chord only does exact lookups by name, not fuzzy search like a search engine.

Remember it in one line

Place every machine and every file by number onto one big ring; a file belongs to "the nearest machine clockwise." Give each machine a "1, 2, 4, 8… doubling" address book, and each lookup halves the distance — so with no central server, a million machines are still reached in about twenty hops, and anyone joining or leaving disturbs only a small local stretch. This "consistent hashing on a ring" is now the bedrock of countless decentralized systems.

Want the ring diagram, the finger table, and why it's O(log N)? → Switch to the deep read