Design a File Sync Service (Dropbox / Google Drive)
Keep a user's files in sync across laptops and phones, with efficient uploads and a clear rule for conflicting edits.
Like a shared binder with numbered pages. When you change one page, you send only that page, and every copy of the binder swaps it in.
- Clients
- Your device
- Other device
- Entry
- CDN
- Services
- Sync service
- Notification service
- Data, outside
- Metadata database
- Object storage
1. Requirements and scope
- Upload, download and delete files and folders.
- Sync changes to all of a user's devices, including after being offline.
- Share files and folders with other users.
- Keep version history.
- Durability: never lose a committed file.
- Large uploads survive flaky connections (resumable).
- Small changes reach other devices within seconds.
- Send only what changed.
2. Back-of-the-envelope numbers
3. API
4. Data model and storage
FILE(id, namespace_id, path, latest_version) · VERSION(file_id, version, chunk_hashes[], size, author, created_at) · CHUNK(hash PK, size, refcount) · CHANGE_LOG(namespace_id, seq, file_id, version)
5. The design, in three versions
Version 1: Whole files on one server
Clients upload whole files to an app server that writes them to its disk.
File Sync Service (Dropbox / Google Drive): Version 1: Whole files on one server Version 1 of 3
The picture follows one request through the parts of this version, in order. Under it, switch a part off to see what the request does without it.
One request, step by step
Each numbered arrow is one step. Press "Simulate Request Flow" to follow them one at a time.
- The order of the steps
- A request or its reply
The parts: switch one off
1. Clients
2. Services
3. Data, outside
The steps in words0 of 3 steps shown
Your device to Sync service
The device uploads the whole file.
Sync service to Local disk
The server saves it on its own disk.
Sync service to Your device
The device gets "saved".
Write path, read path and failures
Each path follows one request through the final design (version 3), one hop at a time.
Write pathSave a changed file
- Desktop app
- Metadata API
- Object storage
- Change log
- Notification service
Desktop app to Metadata API
The app cuts the file into chunks, for example 4 MB each, and hashes each one. It asks which hashes the server does not have yet.
Desktop app to Object storage
It uploads only the missing chunks. If the connection drops, it carries on from the next chunk.
Desktop app to Metadata API
It commits the new version: the list of chunks and the version it was edited from.
Metadata API to Change log
If that version is still the latest, the commit is added to the change log with the next number. If not, the server keeps both and saves a conflicted copy.
Change log to Notification service
The notification service tells the user's other devices that something changed.
Read pathAnother device catches up
- Notification service
- Laptop app
- Metadata API
- CDN
Notification service to Laptop app
The laptop keeps a connection open and hears that its place in the change log is out of date.
Laptop app to Metadata API
It asks for every change after its place, and gets each new version with its list of chunks.
Laptop app to CDN
It downloads only the chunks it does not have yet.
CDN to Laptop app
The app rebuilds the file from its chunks and moves its place forward.
What breaks, and what happens then
An upload drops at 90%
- What users see
- The chunks already sent are safe.
- What the design does
- The app sends only the missing chunks, then commits.
Two devices edit the same file while offline
- What users see
- Both commits name the same earlier version.
- What the design does
- The first commit wins. The second becomes a conflicted copy, so neither edit is lost.
The notification service is down
- What users see
- Other devices learn about changes late.
- What the design does
- Devices also ask on a timer. Each one reads the change log from its own place, so a change is late but not missed.
A metadata database shard fails
- What users see
- Users on that shard cannot commit for a short time.
- What the design does
- A replica of the shard is promoted. Chunks keep uploading, and the commit is retried.
6. Deep dives
7. Follow-up questions
- How do you sync a folder shared by 10,000 people? (A change log per shared namespace, fan-out of notifications, and rate limits per folder.)
- How do you delete a user's data for good when chunks are shared? (Reference counts, deleting a chunk when its count reaches zero, or per-user encryption keys that can be destroyed.)
What it costs
Stored bytes are almost the whole bill: 500 PB before duplicate blocks are removed. Storing each block once, and compressing it, saves the most. Download traffic is the second cost.
Another way to design it
You can sync whole files and skip the split into blocks. The client and the server become much simpler. A small change to a large file then uploads the whole file again.
8. How answers are judged
A passing answer at Mid level. A complete design with numbers: about 2,300 file changes a second on average. It splits files into chunks named by content hash, sends only changed chunks, and goes deep on one part, such as chunking or conflicts.
| What is judged | Junior | Mid | Senior | Staff |
|---|---|---|---|---|
| BreadthHow much of the system does the answer cover? | Names the core parts: clients, servers, a database and a cache. | Covers the whole main flow, from the request to the stored data and back. | Builds a complete design without being led through it. | Covers the system, the systems around it and who owns each part. |
| DepthHow far does it go into the hard parts? | Explains what each part does and why it is there. | Goes deep on one part, such as the database or the cache. | Goes deep on the two or three riskiest parts. | Goes deepest where the risk is largest, and explains why the risk is there. |
| DrivingWho leads the conversation? | Follows the interviewer, step by step. | Moves forward alone, with an occasional nudge. | Leads the conversation from start to finish. | Changes the problem when the question asked is not the right one. |
| Trade-offsAre choices compared and justified? | Names more than one option. | Says why one option was picked over another. | Compares options in detail, with what each one costs. | Ties each choice to cost, speed and risk for the business. |
| Unclear questionsWhat happens when the question is vague? | Answers the questions that are asked. | Asks questions to make the problem clear. | Sets the scope and says what is left out. | Questions the assumptions behind the problem itself. |
| ScopeWhat does it consider beyond the normal path? | Covers the normal path, when everything works. | Adds what happens when a part fails. | Adds growth: what breaks at ten times the load, and the fix. | Adds abuse, cost and the daily work of running the system. |
Requirements and scope
Before I design, I want to check the scope. Files sync across a user's devices and can be shared with others. Real-time co-editing, like Google Docs, is a different problem. I will assume it is out of scope, and that a later edit to the same file creates a conflicted copy.
Users edit files on one device and expect every other device to show the same content right away. So I will design live, character-by-character merging, the same way a collaborative editor does.
Shows: Unclear questionsThe difference: The weak answer assumes live co-editing is needed without asking, which is a much harder problem than syncing whole-file versions between devices.
Estimates
10 million daily active users changing about 20 files a day is about 2,300 file changes a second. Total files come to about 500 petabytes before dedup. The metadata a database must index, such as file names and chunk lists, is only about 50 terabytes.
50 million users storing 10 GB each is 500 petabytes, so the database needs to hold about 500 petabytes of rows.
Shows: DepthThe difference: 500 petabytes is the raw file content, which belongs in object storage. The database only holds about 50 TB of metadata, not the files themselves.
Core design
Each file is split into chunks named by a hash of their content, and only chunks the server does not already have are uploaded. A commit lists the chunk hashes for a new version. An edit that changes one paragraph sends only the changed chunks, not the whole file.
When a file changes, the client uploads the whole file again and the server saves it as a new version, alongside the old ones.
Shows: DepthThe difference: Uploading the whole file on every small edit ignores that only a few chunks actually changed. Sending only the changed chunks saves bandwidth and time.
Deep dive
The hard part is two offline devices editing the same file. Each commit carries the version it was edited from. If the file has since moved on, I keep the incoming edit as a conflicted copy instead of overwriting. The user resolves it, and nothing is silently lost.
If two devices both change the same file while offline, I would keep whichever change reaches the server last.
Shows: Trade-offsThe difference: Keeping only the last write silently discards the other device's real edit. Saving a conflicted copy keeps both instead of losing one.
Failures and trade-offs
If a large upload drops partway through a flaky connection, the client does not restart from zero. It asks which chunks the server still needs, by their hashes, and resumes with only those. The hashes already show what has and has not arrived.
If an upload drops partway through, I would have the client start the upload over from the beginning once the connection comes back.
Shows: ScopeThe difference: Restarting a large upload from zero after every drop wastes time and bandwidth on a flaky connection. Resuming from the missing chunks avoids that.
We wrote this guide in our own words, informed by public interview guides such as AlgoMaster and Hello Interview. We are not connected to either site. Interviewers differ. The guide and the example answers show the direction each level takes, not a checklist.
10. Check your design with your own AI
Write your design first. Then copy this prompt into the AI chat you already use, and add your design at the end. It asks for a score in each area, one fix for each, and two follow-up questions.
The site sends nothing anywhere. An AI review can be wrong, so check what it says against sections 8 and 9.
See the prompt
You are a system design interviewer. Review my design for the interview problem below. Problem: Design a File Sync Service (Dropbox / Google Drive) Keep a user's files in sync across laptops and phones, with efficient uploads and a clear rule for conflicting edits. What users must be able to do: - Upload, download and delete files and folders. - Sync changes to all of a user's devices, including after being offline. - Share files and folders with other users. - Keep version history. How well it must work: - Durability: never lose a committed file. - Large uploads survive flaky connections (resumable). - Small changes reach other devices within seconds. - Send only what changed. Numbers to assume: - 50 million users, 10 million daily active; an average user stores 10 GB. - Each active user changes about 20 files a day. Judge my design at the Mid level. A passing answer at this level: A complete design with numbers: about 2,300 file changes a second on average. It splits files into chunks named by content hash, sends only changed chunks, and goes deep on one part, such as chunking or conflicts. For each area below, say whether my design is strong, fine or weak. Give one reason and one fix for each: 1. Requirements and scope 2. Estimates 3. Core design 4. Deep dive 5. Failures and trade-offs Then ask me the two follow-up questions an interviewer would ask next. Do not write a full model answer for me. My design: [Describe your parts, how one request moves through them, and why you chose each one.]