Design a File Downloader
Design a file download library that apps embed, such as a game launcher, a desktop installer or a dataset tool, together with the backend that serves the files. The app asks the library to fetch a file; the library shows progress, survives a dropped connection, a closed laptop or a reboot, and resumes where it stopped. When it reports done, the file on disk must be exactly the file the publisher released.
The service delivers 50 million downloads a day. Files average 2 GB and reach 100 GB, and on release day 1 million downloads run at the same time, about 25 Tbit/s. The hard part is not the request rate but the bytes and the network: home Wi-Fi and phones drop connections all the time, a restart from zero on a 50 GB file is a lost evening, millions of clients retrying at once can knock over the servers they are retrying against, and a single flipped bit makes a game crash or an installer unsafe.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1What kind of files?
- 2How big?
- 3How many downloads?
- 4Must a download survive the app closing or the device rebooting?
- 5Who may download a file?
- 6Which platforms?
- 7Do we control the client?
- 8Do we need delta patches or peer-to-peer?
How to spend the 45 minutes
- 5minPart 1: Requirements and scope
- 5minPart 2: Estimates
- 5minPart 3: API and manifest
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Library internals, retries and trade-offs