39. Design File Storage and Sync (Google Drive / Dropbox)
1
The interview prompt2
39.1 What do you ask first?3
39.2 How big is this, really?4
39.3 What are the doors?5
39.4 What do we store?6
39.5 What does the whole system look like?7
39.6 How does chunking work?8
39.7 How does de-duplication work?9
39.8 How do sync and conflicts work?10
39.9 How is the metadata database designed?11
39.10 How do presigned uploads work?12
39.11 What would you say in the last five minutes?13
Score yourself14
Variations to practise15
Sources16
Code lab39. Design File Storage and Sync (Google Drive / Dropbox)
39.1 What do you ask first?
3 min read+10 XP
Step 1: Requirements (5 minutes)
| Letter | Candidate asks | Interviewer answers |
|---|---|---|
| Scope | "Upload, download, sync across devices? Sharing? Version history? Real-time co-editing like Google Docs? Max file size?" | "Upload, download, sync, sharing with other users, 30 days of version history. No co-editing. Files up to 50 GB." |
| Count | "How many users, how much data each?" | "100 million users, about 20 GB each on average." |
| Access pattern | "How much changes a day?" | "A typical user changes a couple of files a day, around 1 MB each, but some upload big videos." |
| Latency | "How soon must a change appear on other devices?" | "Within seconds to a minute." |
| Exactness | "Can we ever lose a file or silently overwrite an edit?" | "Never." |
Agreed requirements:
- Functional (verbs): upload and download files; sync changes to all of a user's devices; share files and folders; keep version history; resume interrupted transfers.
- Non-functional (adjectives): durable (never lose data; Chapter 11's eleven nines), consistent metadata (no silent overwrites), efficient (upload only what changed, store duplicates once), fast sync (seconds to a minute), scalable to exabytes, secure (access control on every byte).
Interviewer pushback:
- "Why does 'never silently overwrite' matter so much?" → Two devices editing the same file offline is normal (a laptop on a flight, a phone in a tunnel). The system must detect it and keep both, not let the last upload win quietly (39.8).
Memory code: "Ask about size, sync speed, sharing, history, and what happens when two devices disagree."