Design Google Drive / Dropbox (file storage and sync)
Store files of any size, keep them in sync across every device, share them with fine-grained permissions and never lose a byte. The key ideas: separate metadata from content, split files into hashed blocks, and notify devices of changes instead of having them scan.
Builds on these concepts
In one sentence
Split files into content-addressed blocks in object storage, keep the folder tree, versions and permissions in a strongly consistent metadata store, and notify devices so they fetch only what changed.
A reference design: it covers what an app like this needs and follows how these companies have described their systems publicly, simplified to be learnable.
Requirements
Functional
- Upload and download files of any size
- Folders, rename, move, delete, versions
- Sync across desktop, web and mobile
- Share with view/edit permissions
Non-functional
- Durability: never lose a file (11 nines in object storage)
- Metadata strongly consistent
- Large uploads resumable on bad networks
- Efficient sync: don't re-upload unchanged data
Back-of-the-envelope estimates
| Metric | Estimate |
|---|---|
| Users | 1B with ~15 GB each on average used → ~15 EB (before dedup and compression) |
| Files | ~1,000 per user → 1 trillion metadata rows |
| Uploads | ~2 files per user per day → ~25K file commits/s |
| Sync checks | Hundreds of millions of connected devices waiting for changes |
API and data model
POST /blocks/check { hashes[] } → missing[]
PUT /blocks/:hash (4 MB, resumable)
POST /files/commit { path, blockHashes[], baseVersion } → { version } | conflict
GET /changes?cursor=… → [ change ], newCursor
POST /files/:id/permissions { user, role }
files(id, namespace_id, parent_id, name, version, block_hashes[], deleted)
blocks(hash PK, size, location) permissions(file_id, user_id, role)Architecture
Step by step · Upload a 1 GB file
- 01New file: split into 250 blocks of 4 MB, each hashed
- 02Upload request
- 03Only blocks it doesn't have yet are uploaded (resumable)
- 04Blocks stored by hash
- 05Commit: file = [hash1, hash2, …] version 1
- 06Metadata row saved
- 07Other devices told to fetch changes
- 08File appears everywhere
At this scale · 1M users
Blocks, metadata and sync as separate services
- ▸Files split into ~4 MB blocks identified by their hash: resumable and deduplicated
- ▸A file version is just a list of block hashes
- ▸Sync service tells devices what changed (long polling / WebSocket)
Tap any box to see what it does.
Deep dive: blocks and deduplication
- Resumable: a dropped connection only re-sends the block in progress.
- Delta sync: editing a 1 GB file uploads only the changed blocks.
- Deduplication: blocks are named by their hash (SHA-256). If a thousand users upload the same PDF, it's stored once.
- Immutable content, mutable metadata: blocks never change, so they cache and replicate trivially; all the hard consistency lives in the metadata store.
Sync works with a change log per namespace: each device remembers a cursor, and the notification service tells it when there's something newer, so it never has to scan the whole tree.
How it changes with scale
Step by step · Edit and sync
- 01Edits a slide: 2 of 250 blocks change
- 02Whole file uploaded again
- 03New blocks stored
- 04Polls and downloads the new file
At this scale · 100 users
Files in a bucket, folders in SQL
- ▸Whole files uploaded to object storage
- ▸Folders, files and permissions in PostgreSQL
- ▸Clients poll every minute to see what changed
Tap any box to see what it does.
| Users | What you run | Why it changes |
|---|---|---|
| 100 | App + PostgreSQL + S3, whole-file upload, polling | Simple and correct |
| 10K | Signed URLs + CDN, preview workers, Redis | Traffic must bypass the app; previews are slow |
| 1M | Block, metadata, sync and sharing services; delta sync | Bandwidth and sync latency |
| 100M+ | Metadata sharded by namespace, multi-region blocks, tiered storage, search | Exabytes and trillions of rows |
Key takeaways
- 01Separate metadata (small, consistent) from content (huge, immutable).
- 02Hashed blocks give resumable uploads, delta sync and deduplication.
- 03Devices follow a per-namespace change log and get notified instead of polling.
- 04Shard metadata by user or namespace so moves stay single-shard transactions.
Check your understanding
1 of 3
In a file storage service like Google Drive or Dropbox, why separate metadata from file content?