SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 04
Design a Dropbox-style file sync service
A user installs a desktop client, picks a folder, and expects every file in it to appear on their other laptop and phone. They edit files offline on a plane, reconnect, and expect everything to reconcile without losing work.
Requirements
- Sync a folder tree (create, edit, rename, move, delete) across all of a user's devices.
- Upload and download only the parts of a file that changed.
- Keep 30 days of previous versions and deleted files for restore.
- When two devices change the same file concurrently, keep both versions rather than dropping one.
Constraints and assumptions
- 50 million users, 10 million daily active, about 2.5 devices each.
- Average account holds 10 GB in about 5,000 files; single files can be up to 50 GB.
- 100 million file changes a day across the service.
- A change should appear on the user's other online devices within 10 seconds.
- Devices may be offline for weeks and must catch up correctly when they return.
Out of scope for the first sketch
Sharing folders between users · Real-time co-editing inside a document · Previews and full-text search
Draw your design
Rough math and notes
SYSTEM DESIGN SKETCHBOOK / FOLLOW-UPS
Design a Dropbox-style file sync service
Finish your first sketch before answering these. Cross out freely.
- A user edits one paragraph in a 2 GB file. What gets uploaded, and how does the server know what it already has?
- How does an online laptop learn about a change within seconds, and how does a phone that was offline for a week catch up?
- Two laptops edit the same file while offline and then reconnect. What does each user see afterwards?
- A user deletes a 10 GB folder. When is the space actually reclaimed if some of its chunks are shared with other files?
- Should identical chunks be deduplicated across different users? What does that cost you?
Compare afterwards: worked approaches and reading at sketchbook /questions/file-sync/review