How it works · 36 of 49 Core
What is peer-to-peer architecture?
No centre to fail (BitTorrent)
Peer-to-peer: Peer-to-peer drops the single server: every machine that has a piece of the work passes it on, so each new user brings capacity as well as demand. There is no centre to fail, and none to vouch for what you receive, so every piece is checked on arrival.
Loading the animation…
Say it like this Peer-to-peer drops the single server: every machine that has a piece of the work passes it on, so each new user brings capacity as well as demand, and there is no centre to fail, but also none to vouch for what you receive.
Under the hood — for builders
- Worked example: the village on the card
- One 1 GB file (8,000 megabits). The tower, a server, uploads 100 megabits a second; each home uploads 10. From the tower alone every copy costs 80 s of its outlet, so 1,000 homes wait 80,000 s, about 22 hours. As a swarm, 1,000 homes add 10,000 megabits a second of upload between them: 8,000,000 ÷ 10,100 ≈ 13 minutes is the floor; our run took 15.6.
- The source, in its words
- Cohen, 2003 (BitTorrent's designer): "When a file is made available using HTTP, all upload cost is placed on the hosting machine. With BitTorrent, when multiple people are downloading the same file at the same time, they upload pieces of the file to each other." BEP 3, the protocol: "the downloaders upload to each other, making it possible for the file source to support very large numbers of downloaders".
- Terms
- Peer: a machine that both downloads and uploads. Swarm: all peers sharing one file. Piece: a fixed-size slice, "most commonly 2^18 = 256 K" (BEP 3). Seed: a peer with the whole file. Tracker: a server that only tells peers who else is in the swarm; it carries none of the file.
- Run here: does the swarm slow as it grows?
- Same file and speeds as the worked example; 64 pieces, each home trading with a few neighbours, rarest piece first. Time until the last home is done.
- How a swarm keeps itself going
- Rarest first: "peers generally download pieces which the fewest of their own peers have first", so no piece dies out if the seed leaves. Choking: each peer uploads to those who upload back, "a variant of tit-for-tat", so freeloaders get little. The muddy piece: the .torrent file holds a SHA-1 fingerprint of every piece, and "peers don't report that they have a piece until they've checked the hash" (Cohen).
- Real numbers from the source
- Cohen, 2003: BitTorrent "routinely serves files hundreds of megabytes in size to hundreds of concurrent downloaders"; the largest deployments then "had over a thousand simultaneous downloaders". The tracker, the one small centre left, used "about a thousandth the total amount of bandwidth".
- Measure it
- Time until the last peer finishes · share of bytes uploaded by the origin vs by peers · pieces that failed their hash · peers that leave the moment they finish (churn).
- Watch out
- Home upload is usually far slower than download, so a swarm of phones gives less than a swarm of PCs. Peers come and go: "Peers rarely connect for more than a few hours". Nobody can recall or edit a file once it spreads. Choose it for the same big file to many at once; keep a server for records that must have one true copy (G1).
- Sources
- Bram Cohen, "Incentives Build Robustness in BitTorrent", 22 May 2003 · BitTorrent.org, BEP 3 "The BitTorrent Protocol Specification" · both read in session · swarm simulation, Python, 21 Nov 2026.
What happens in the peer-to-peer animation, step by step?
- One water tower, one outlet: the server. Four houses fill; eight more join and every pipe thins, because they all share the same flow.
- Peer-to-peer cuts the file into pieces. Each house that has a piece opens its own tap to its neighbours, so every new house brings a tap, not just a bucket.
- Your turn: 1,000 houses want the same file by peer-to-peer. How long until the last one has it?
- About 16 minutes, against 22 hours from the tower alone. More houses, more taps: the swarm barely slows as it grows.
- No centre to fail: the tower goes dark and the village still finishes. No centre to vouch either: a muddy piece fails its fingerprint and is poured away. Next: inside one app, MVC.
What everyday example explains peer-to-peer?
A village where every house that gets water opens its own tap to the next. The tower (the server) only has to fill a few; a muddy bucket is tipped out at the door.
Why should a team care about peer-to-peer?
When the same big thing goes to many at once (an update, a video, a model's weights), you choose between paying for one centre's bandwidth and trusting a swarm you can't control, recall or vouch for.