"Design Dropbox" is a file storage question that is secretly a synchronization question. Storing a file is solved: put the bytes in object storage. The hard part is that the same folder lives on a laptop, a phone and a server, all three can change it at any time, any of them can be offline for a week, and files can be gigabytes.
The interviewer is listening for three ideas. Split files into chunks so that a small edit costs a small upload. Address chunks by their content hash so identical data is stored once. And treat metadata and file data as different problems with different consistency needs, so you can answer, precisely, what happens when two devices edit the same file at the same moment.
The storage layer comes from the distributed file systems lesson, and the blob layer is what design an object store builds. This page designs the sync system that sits on top of them.
Clarify the requirements
Functional requirements:
- Upload files and folders from any device, and download them.
- Sync: a change on one device appears on the user's other devices automatically, and works offline (changes sync when back online).
- Share a folder with other users, with view or edit permission.
- Keep version history (restore a file as it was last week) and recover deleted files.
- Large files, up to tens of gigabytes, with resumable transfers.
Out of scope, said aloud: real-time collaborative editing inside documents (that is design Google Docs), file previews, search inside files, and admin and audit tools.
Non-functional requirements:
- Durable. A file we acknowledged is never lost. Eleven nines of object durability, with replicas in more than one zone.
- Bandwidth-efficient. Editing a few bytes of a large file must not re-upload the file. Identical content is not uploaded or stored twice.
- Consistent metadata. Every device agrees about what the folder contains. No two devices see a different "latest version" without it being detected.
- Resumable. Flaky networks and laptops that close their lids must not restart a 10 GB upload.
- Fast notification: other devices learn of a change within a few seconds.
- Private. Files are encrypted at rest and in transit, and deduplication must not leak whether someone else has a file.
Estimate the scale
Assume 50 million daily active users. Each changes or adds 2 files a day, averaging 2 MB. Each user opens, lists or downloads files about 20 times a day. A file version averages 1.5 chunks, and chunks are 4 MB.
Change rate: 50M × 2 = 100 million file changes a day ÷ 86,400 s ≈ 1,157 per second, about 3,500 at peak.
Upload bandwidth: 100M × 2 MB = 200 TB a day, which is 200 TB ÷ 86,400 s ≈ 2.3 GB per second on average (roughly 18 Gbit/s). If dedup and delta sync skip 30% of it, 1.6 GB/s is actually transferred.
Storage growth: 200 TB a day × 365 = 73 PB a year before dedup, about 51 PB if dedup and delta save 30%. Most of it is cold, so old versions move to cheaper storage.
Reads: 50M × 20 = 1 billion operations a day ÷ 86,400 s ≈ 11,600 per second, mostly small metadata calls.
Metadata: 100M versions × 1.5 chunk rows = 150 million chunk records a day (1,740 per second) at about 100 bytes: 15 GB a day, about 5.5 TB a year. It is tiny next to the data, and it needs the strongest consistency.
Connected devices: assume 100 million devices and 20% online at once: 20 million open notification connections. At 100,000 connections per server, that is 200 notification servers.
"The numbers split cleanly: petabytes of cold, immutable chunks that need durability and cost control, and gigabytes a day of metadata that need consistency. Bandwidth is the user-visible cost, so chunking and dedup are not an optimization, they are the design."
The capacity estimator reproduces the 73 PB a year before dedup.
API and data model
POST /v1/files/commit { path, parentRev, chunkHashes[], size, clientMtime }
-> { rev } | 409 { conflict, currentRev }
POST /v1/chunks/missing { hashes[] } -> { missing[] }
PUT /v1/chunks/{hash} <bytes> -> 200 // pre-signed URL to object store
GET /v1/changes?cursor= (long poll) -> { entries[], cursor }
GET /v1/files/{id}/versions -> versions[]namespace (ns_id PK, owner, type) // a user's root or a shared folder
file_entry (ns_id, path) -> file_id, current_rev, deleted, mtime
file_rev (file_id, rev) -> chunk_hashes[], size, author, created_at
chunk (hash PK) -> object_key, size, ref_count
journal (ns_id, seq) -> change record // the change feed, strictly orderedThe non-obvious choice is the journal: a per-namespace, strictly ordered log of changes. A device remembers the last sequence number it has seen and asks for everything after it. That makes sync incremental, resumable and testable.
High-level design
We simulate the core: a gateway, a sync service, the metadata store and the chunk store.
- The sync service commits file revisions to the metadata store, which holds paths, versions and chunk lists.
- Content chunks live in object storage, addressed by hash and uploaded straight from the client.
Describe this diagram
Components
- devices (Client)
- gateway (API gateway)
- sync service (Service)
- file metadata (PostgreSQL)
- chunk store (Object storage (S3))
Connections
- devices sends to gateway
- gateway sends to sync service
- sync service sends to file metadata
- sync service sends to chunk store
Run it, then raise the load or enlarge the chunk size and compare. Metadata calls stay quick and cheap while chunk traffic dominates the bytes. That separation is the design.
The upload path: the client splits the file into chunks and hashes each. It asks the server which hashes are missing, uploads only those, in parallel, to object storage, and then commits the new file revision: a small metadata transaction that references the chunk hashes and bumps the revision.
The download path: the client reads the revision's chunk list, fetches the chunks it does not already have (often from a nearby cache or CDN) and reassembles the file.
The interesting problem: chunking and deduplication
How you cut a file into pieces decides how much you upload.
Approach A: upload the whole file each time
Good: trivial to build.
Bad: change one byte in a 1 GB file and you upload 1 GB again. On a phone, that is a deal-breaker, and at 100 million changes a day it burns the budget.
Approach B: fixed-size chunks with hashes
Cut every file into 4 MB blocks, hash each block, and upload only blocks whose hash the server lacks. A 1 GB file is 256 chunks (1,024 MB ÷ 4 MB).
Good: overwriting bytes in place changes one chunk, so you upload 4 MB instead of 1 GB. Identical blocks across files and users are stored once.
Bad: an insertion shifts everything. Add 10 bytes at the start of the file and every later boundary moves, so all 256 chunks hash differently and you re-upload the entire file.
Approach C: content-defined chunking
Choose chunk boundaries from the data itself with a rolling hash (a Rabin fingerprint): scan the file, and cut wherever the hash of the last few dozen bytes matches a pattern, with a minimum of 1 MB and a maximum of 16 MB around an average near 4 MB. The boundaries follow the content, so an insertion changes the one or two chunks around it and every other chunk keeps its hash. Insert 10 bytes in the middle of the same 1 GB file and you upload perhaps two chunks, about 8 MB.
Diagram, as text
- File on disk leads to Rolling hash finds cut points
- Rolling hash finds cut points leads to Chunk 1: hash a1
- Rolling hash finds cut points leads to Chunk 2: hash b7
- Rolling hash finds cut points leads to Chunk 3: hash c4
- Chunk 1: hash a1 leads to Server has it?
- Chunk 2: hash b7 leads to Server has it?
- Chunk 3: hash c4 leads to Server has it?
- Server has it? leads to Upload chunk (no)
- Server has it? leads to Skip (yes)
- Upload chunk leads to Commit revision with chunk list
- Skip leads to Commit revision with chunk list
This is the answer to aim for, and the vocabulary matters: content-defined chunking for boundaries that survive edits, and a content-addressed store where a chunk's id is its hash, so the same bytes are stored once, forever, and a chunk is immutable. Immutability makes caching, replication and garbage collection simple.
The dedup caution. If the server says "I already have chunk X, skip it," an attacker can upload hashes and learn whether someone else has a given file. That is a privacy leak. Mitigations: dedupe within an account or organization only, or require the client to prove it holds the data (for example by answering a challenge over random byte ranges of the chunk) before honoring a skip.
The second decision: sync, conflicts and consistency
Two kinds of data, two kinds of consistency.
Chunks are immutable and addressed by hash, so there is nothing to conflict. Eventual consistency in the object store is fine, and the order of upload does not matter.
Metadata is where agreement lives, and it needs transactions. Keep it in a relational store sharded by namespace, since one folder's operations should be atomic and a transaction rarely spans namespaces. The commit uses optimistic concurrency: the client says "I am replacing revision 17" (parentRev). If the current revision is still 17, the server writes revision 18 and a journal entry in one transaction. If it is no longer 17, someone else got there first, and the server returns a conflict. The lesson on consistency patterns is the background.
Resolving a conflict. Binary files cannot be merged. Do not guess and do not silently overwrite: keep both. The loser's content is saved as a sibling, report (Maya's conflicted copy 2026-12-02).docx, and both devices see both. The user reconciles. For text, a three-way merge is possible, but Dropbox-style systems generally choose the safe route.
Notifying devices. A change does not push the data, only a hint. The device holds a long-poll or WebSocket connection and the server sends "namespace N has changes after cursor C". The device then calls GET /changes?cursor=C and downloads what it needs. The tiny push makes 20 million idle connections cheap, and a missed notification is harmless, because the next poll or reconnect asks for changes since the saved cursor anyway.
Offline. The device keeps a local database of the last known state and a queue of local changes. On reconnect it fetches the journal since its cursor, detects local changes that touched the same file (conflict), commits the rest and uploads missing chunks. Moves and renames are tracked by file id, not by path, so a rename on one device and an edit on another merge cleanly.
Bottlenecks and failures
A hot shared folder. A folder shared by 100,000 people puts 100,000 devices on one journal. Writes to it serialize on one namespace shard. Cap sharing size, or split very large shared spaces into sub-namespaces, and fan out notifications through the notification tier, not the metadata database.
A huge file upload dies halfway. Because chunks are independent and the commit is separate, a restart re-asks "which hashes are missing?" and continues. Nothing is lost, and nothing is visible to other devices until the commit.
Orphaned chunks. Chunks uploaded for a commit that never arrives are garbage. The sweeper removes any chunk unreferenced for, say, seven days.
Metadata database failure. Syncing pauses for the affected shards, because commits cannot happen, but data in object storage is safe and downloads of known files from cache or replicas continue. Replicate the metadata synchronously across zones, since it is small and must not lose a commit.
Object storage failure. Chunks are replicated or erasure-coded across zones. A chunk with a missing replica is repaired in the background, and reads fall back to a healthy copy.
Thundering reconnects. After an outage, 20 million devices reconnect at once. Use jittered reconnect delays and per-device rate limits, so recovery does not become a second outage.
Malware and abuse. Shared links can spread malware and illegal content. Scan on upload in the background, and rate-limit public downloads per link.
Trade-offs to name aloud
- Content-defined chunks over fixed: more CPU on the client and a slightly larger metadata footprint, for far less upload after edits.
- Global dedup against privacy: saves storage, and leaks existence unless you scope it or add proof of possession.
- Optimistic commits: no locks and simple clients, and conflicts need a human-friendly resolution.
- Keep both on conflict: never loses data, at the cost of clutter.
- Hints, not data, in notifications: cheap fan-out, at the cost of an extra round trip to fetch the change.
What interviewers listen for
- A working answer: chunk files, store chunks in an object store, keep metadata in a database and notify other clients of changes.
- A strong answer: hashes chunks for dedup and resumable upload, separates immutable blob storage from transactional metadata, commits with a parent revision and returns conflicts.
- A standout answer: uses content-defined chunking and explains why fixed chunks fail on insertion, raises the dedup side channel, keeps a per-namespace journal with cursors, keeps both versions on conflict and tracks renames by id.
Check your understanding
Common mistakes
Uploading whole files. It is the first thing any real client avoids. Chunk, hash and send only what is missing.
One database for bytes and metadata. Chunks are petabytes of immutable blobs, and metadata is small, transactional data. Different stores, different guarantees.
Fixed-size chunks only. They fail on insertions at the front of a file. Mention content-defined chunking.
Last write wins. It silently destroys someone's work. Detect conflicts with a parent revision and keep both versions.
Pushing data in the notification. It does not scale to millions of devices. Push a hint, then pull from the journal.
Cross-user dedup with no thought for privacy. It leaks whether a file exists on the service. Scope it or require proof of possession.
Practice
A user renames a folder containing 10,000 files on one laptop while their phone edits one file inside it. Walk through what each device and the server do, and what the user ends up with.
Write your own answer first, on paper or in a note. Then compare.
Show a hint
Think about whether the sync system tracks files by path or by id, and how the journal orders the two changes.
Show a strong answer
Track files by id, not path. The metadata stores each file under a stable file_id with its current path. A folder rename is a metadata change on the folder (and the paths beneath it derive from it), not 10,000 file rewrites.
The journal orders both changes. Suppose the rename commits first as journal entry 501, and the phone's edit to file F (parent revision 7) commits as entry 502. The edit refers to F by id and to revision 7, which is still current, so it succeeds.
Devices converge. The laptop sees entry 502 and updates F's content in its new folder location. The phone sees entry 501 and moves its local folder. Both end with the renamed folder holding the edited file.
The failure case. If the phone had deleted the folder instead, the server compares each change against the current state and treats the later one as a conflict for the user to resolve, with deleted items recoverable from version history.
The pattern worth keeping: identify things by stable ids and make every change an ordered journal entry against a known revision, so concurrent operations compose instead of colliding.
A customer says 'I deleted a 40 GB folder and I want it back, but it was three weeks ago.' What did your design have to do in advance to make that possible, and what does restoring cost?
Write your own answer first, on paper or in a note. Then compare.
Show a hint
Separate removing metadata from removing data, and think about retention and the garbage collector.
Show a strong answer
Deletion is a metadata operation. Deleting marks the file entries deleted and writes journal entries. The revisions and their chunk lists remain, and the chunks stay referenced, so nothing in object storage is removed.
Retention window. Keep deleted files and old revisions for a defined period (say 30 days on a basic plan, longer on a paid one). The garbage collector only removes chunks no revision references, and revisions older than the retention window are the only ones that stop counting.
Three weeks ago is inside 30 days, so the revisions exist. Restore by writing new revisions that point at the old chunk lists. No data is copied: 40 GB at 4 MB chunks is about 10,240 chunk references, a small metadata transaction.
If it were beyond retention, the chunks may already be swept, which is why the policy must be stated plainly in the product and legal terms.
The cost. Retaining versions is storage you pay for, so tier old versions to cold storage and apply the dedup savings. It is the main reason version history is limited by plan.
The pattern worth keeping: make deletion a reversible metadata change, and let a delayed garbage collector be the only thing that destroys data.
Key takeaways
- Dropbox is a sync problem. Storing bytes is easy, and agreeing across devices is the work.
- Chunk files and address chunks by hash. That gives dedup, delta sync and resumable uploads together.
- Content-defined chunking survives insertions that break fixed-size chunks.
- Split blobs from metadata. Immutable chunks are eventually consistent, and metadata commits are transactional with a parent revision.
- Resolve conflicts by keeping both, and track files by id so renames compose.
- Notify with hints and sync from a journal cursor. It is cheap, reliable and resumable.
Further reading
- Andrew Tridgell and Paul Mackerras, "The rsync algorithm" (Australian National University technical report, 1996): rolling checksums for transferring only what changed.
- Athicha Muthitacharoen, Benjie Chen and David Mazieres, "A Low-bandwidth Network File System" (SOSP, 2001): content-defined chunking for efficient file transfer.
- Michael O. Rabin, "Fingerprinting by Random Polynomials" (Harvard University technical report TR-15-81, 1981): the rolling fingerprint behind content-defined boundaries.
- Danny Harnik, Benny Pinkas and Alexandra Shulman-Peleg, "Side Channels in Cloud Services: Deduplication in Cloud Storage" (IEEE Security & Privacy, 2010): how cross-user deduplication leaks information.