Designing Dropbox / Cloud File Storage and Sync
Difficulty: Advanced Topics: Chunking, Deduplication, Delta Sync, Conflict Resolution, Object Storage, Metadata Service Asked at: Google, Amazon, Microsoft, Dropbox, PhonePe, Flipkart · Prerequisites: Object Storage, Consistent Hashing, and Message Queues
1. Understanding the Problem
A cloud file storage service lets users upload files, sync them across devices, share them with others, and access version history. The hard engineering problems: syncing a 4GB video edit without re-uploading the entire file (delta sync), handling two people editing the same file offline simultaneously (conflict resolution), and storing petabytes of files cost-efficiently while keeping metadata lookups fast.
Real examples: Dropbox, Google Drive, OneDrive, iCloud Drive, Box.
2. Naive First Cut
flowchart LR
CLIENT["Desktop Client"]
API["API Server"]
STORE[("Single File Server<br/>stores full files")]
CLIENT -->|"Upload entire file"| API
API --> STORE
User uploads the entire file to a server; server stores it as-is on disk. On change, re-upload the whole file.
Why this breaks:
- Re-uploading a 2GB file because one byte changed wastes bandwidth and takes minutes
- No deduplication - 100 users with the same PDF = 100 copies stored
- Single file server has finite disk; can’t scale to petabytes
- No versioning - overwriting loses history
- No sync - other devices don’t know a file changed until they poll
- Concurrent edits from two devices silently overwrite each other (last-write-wins data loss)
💡 Last-write-wins means whichever write arrives second simply replaces the first, with no record that anything was lost. For a file-sync product that is not a tradeoff, it is the bug report. Learn more →
The rest of the doc evolves this into a chunked, content-addressed, event-driven sync system.
💡 Content-addressed means the storage key is a fingerprint of the bytes themselves rather than a name you choose, so identical content lands on the same key no matter who uploaded it. That one property is where deduplication and delta sync both come from.
3. Prior Art We’re Drawing From
- Dropbox Block-Level Sync - Files are split into 4MB chunks, each identified by SHA-256 hash. Only changed chunks are uploaded/downloaded. This single optimization reduced Dropbox’s bandwidth usage by 60%+ for typical edit patterns. (Dropbox Tech Blog)
💡 SHA-256 (Secure Hash Algorithm, 256-bit output) turns any block of bytes into a 32-byte fingerprint. The same content always produces the same fingerprint and different content essentially never collides, which is what makes the fingerprint usable as the storage key. - Google Drive Conflict Resolution - Uses operational-transform-style conflict detection: when two clients edit the same file offline, the second to sync gets a “conflict copy” rather than silent overwrite. User explicitly resolves. (Google Workspace Blog)
💡 Operational transform is the family of algorithms that rewrites one edit so it still makes sense after another edit it did not see - the machinery behind real-time collaborative documents. This design deliberately does not attempt it, and falls back to a conflict copy instead. - Rsync Rolling Checksum - The rsync algorithm uses a rolling hash (Adler-32) to detect which blocks of a file have changed without comparing the entire file byte-by-byte. Dropbox’s delta sync is conceptually derived from this. (Rsync Technical Report)
💡 A rolling hash can be updated one byte at a time as a window slides along the file, so testing every possible boundary is cheap instead of requiring a fresh hash at each offset. - Content-Addressable Storage (CAS) - Git, IPFS, and Dropbox all use content-addressed storage (hash of content = storage key). This gives deduplication for free — identical blocks map to the same key regardless of which user uploaded them.
💡 IPFS is a peer-to-peer file system that addresses every block by its hash; Git does the same thing for commits and file blobs. Addressing by hash is also how a tree of hashes can prove a whole directory is unchanged by comparing one value. Learn more →
4. Functional Requirements
Core (Top 3)
- Upload and download files - users can store files up to 50GB and retrieve them from any device
- Sync across devices - changes on one device propagate to all other devices within seconds
- Version history - users can view and restore previous versions of any file (last 30 days)
Discussion
Newest first