Design a Peer-to-Peer File Transfer
Design a system that lets people share large files directly with each other, the way BitTorrent does. A publisher turns a file into a small manifest and shares a link. Anyone with the link joins a swarm of peers who hold the same file, downloads pieces of it from many of them at once, and uploads the pieces it already has to others. Our servers help peers find each other; they never carry the file.
There are 10 million peers online at once, spread over 1 million swarms, and the biggest swarm has 200,000 peers. Files average 2 GB and reach 50 GB. The hard parts: peers are untrusted, so every byte must be checked; most of them sit behind home routers that block incoming connections; peers come and go all the time; some take without giving; and a new file starts with one seeder while thousands of people want it at once.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1Do our servers ever send file data?
- 2How big are files?
- 3How many peers and swarms?
- 4Are peers trusted?
- 5Must it work if our trackers are down or blocked?
- 6Are most peers reachable?
- 7Do we need to reward uploaders?
- 8Is anonymity required?
How to spend the 45 minutes
- 5minPart 1: Requirements and scope
- 5minPart 2: Estimates
- 5minPart 3: API and protocol
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Deep dives and trade-offs