System design interview guide
Dropbox System Design
Picture one person who keeps a slide deck on two computers: a laptop at the office and a second laptop they carry on the train. One evening they finish a 500 MB version of the deck on the train, but the Wi-Fi drops halfway through sending it, and the office laptop has already saved a different edit of the same file. The part of a product that keeps the same folders and files up to date on every device a person owns is called a file sync service; Dropbox is the best-known example. A good sync service continues the broken upload from where it stopped and keeps both edits. A poor one keeps only the last save, so the train copy replaces the office copy and one person's work is gone for good.

Problem statement
Picture saving a slide deck on a laptop on the train while the same deck also lives on an office laptop. You want both machines, and a phone, to show the same folders and files without emailing copies around. That product job is file sync, the way Dropbox does it.
Large files are sent in pieces, so a dropped connection continues from the pieces that already arrived. Every saved change becomes a numbered version, so the system always knows which version is current. When two devices edit the same file while offline, both edits are kept as separate copies instead of one replacing the other.
Interviewers care that you can explain how a big upload resumes, how another device learns what changed without copying the whole folder, how conflicts keep both edits, how sharing is checked, and how a buggy app release does not corrupt data or flood the servers.
Introduction
The problem: one slide deck, two laptops
Picture a person who works on one slide deck from two places. At the office they use one laptop, and in the evening they open a second laptop on the train home. They want to open the same deck in both places without emailing it to themselves, and they want the deck on their phone when they show it to someone.
Now add the things that go wrong in real life. The deck is large, say 500 MB, and the train Wi-Fi drops halfway through sending it. The person keeps editing anyway, because the train has no signal for the next hour. Meanwhile the office laptop was left on and saved a different edit of the same deck. When the train laptop finally gets a signal, two different versions of one file exist, and each of them was edited in good faith.
The product that keeps this tidy is called a file sync service. It watches a folder on each device, copies changes to a central place, and copies them out again to every other device. It looks like a normal folder to the user. The work happens in the many small decisions about what to send, when a change counts as saved, and what to do when two devices disagree. This page walks through those decisions in the order you would make them in an interview: first what we are solving and why, then what the system must do, then how big it is, and only after that the design.
Why teams bother with file sync
Most people first notice file sync when it saves them from a bad day. A laptop is dropped or stolen, and the work is still there on another device. A phone is replaced, and every file comes back. Behind each of those moments is a reason a company builds this carefully.
Work follows the person. People use a desktop, a laptop and a phone, and they do not want to remember which one holds the latest copy. A folder that is the same everywhere removes that question.
Protection from loss. A file that lives on only one disk is one spilled coffee away from disappearing. A second copy stored somewhere safe is often the real reason people pay for the product.
Sharing without attachments. Sending a 200 MB file by email creates many copies that drift apart. Sharing one folder, or one link, means everyone looks at the same file.
History and undo. People delete the wrong file and overwrite the right one. Being able to open last Tuesday's version, or bring back a deleted file, is something users come to rely on.
Trust. Losing a user's file is the one failure a sync product cannot afford. Every design choice below is shaped by that fear.
What problem are we solving?
A person saves a file on one device. Within a few seconds, every other device that person owns, and every person they shared the file with, should be able to open the same file. If the person has no signal, the save should still work locally and arrive later. That is the whole job, and the question underneath it is this:
“Which version of this file is the real one right now, and where are its bytes?”
Answering that question for hundreds of millions of people, for files from a few kilobytes to many gigabytes, is where the difficulty is. A good result means three things. Nothing a user saved is ever lost, even when two devices edit the same file. Large files survive bad networks. And a person only ever sees what they are allowed to see. We will not guess at a design yet. First we need to be clear about what the system must do, and how well, so that each choice later has a reason behind it.
One boundary so the scope stays clear. Typing in a shared document with several people at once, as in an online document editor, needs a different technique for merging edits as they happen. File sync treats a file as a whole and decides what to do when two whole versions collide. You can mention the document editor as a separate product, but do not turn this interview into that one.
This page is the interview deep dive in the system design interview guides hub. If background work queues are new to you, the message queues fundamentals are worth a skim first.
How to approach
We know the job now: keep one person's folders the same across devices, even when Wi-Fi drops and two laptops disagree. In an interview you still do not start by drawing boxes. You turn the short, vague prompt “Design Dropbox” into a clear contract: what the system does, how well it must do it, how big it is, and what is out of scope. Only then do you size the problem, make the design decisions one at a time, and draw the result. The list below is the order this page follows.
How to design a file sync service in an interview
- Clarify the problem: sync versus live co-editing, how large files get, how fast other devices must see a change, how exact versions must be, whether history and trash are needed, and what happens when two devices disagree.
- Write the functional requirements (what the system does) and the non-functional requirements (how fast, how big, how safe).
- Estimate the size: users, files, bytes, saves per second, and how many devices each save wakes up.
- Make the design decisions in order: where bytes and versions live, how big files are sent, how the server avoids re-receiving bytes it has, when a version becomes current, how other devices find out, what to do on a conflict, how deletes and old versions work, and how sharing is checked.
- Draw the picture those decisions produce, then walk one saved file through it.
- Go deeper where the interviewer pushes: the commit step, conflicts, retries, cleaning up unused bytes, sync storms, and one production failure.
Clarifying questions (say these in the room)
In a real interview the prompt is only a few words. Before you design anything, ask questions until the problem is clear. Each answer below changes the design, which is why it is worth asking.
You: “Are we building file sync like Dropbox, where each file is saved as a whole, or real-time co-editing like Google Docs, where several people type in the same document at once?”
Interviewer: “File sync is enough; mention co-editing only as out of scope.”
That answer keeps you on whole-file versions, change lists and conflict copies, and away from the more complicated techniques used to merge keystrokes. You can write “whole-file versions, not live cursors” on the board so the boundary is visible.
You: “How large can files be, and do uploads need to resume after the network drops?”
Interviewer: “Assume multi-gigabyte files and unreliable networks.”
Now sending a file in parts is a requirement and not a nice extra. One failed connection must not restart a huge upload from zero.
You: “Roughly how many users and files are we talking about, and how quickly should another device see a change?”
Interviewer: “Hundreds of millions of users and billions of files. Most active devices should see a change within a few seconds.”
Those numbers feed the size estimate in a later section. They also tell you early that no single machine can hold the folder tree, and that “a few seconds” rules out checking for changes once an hour.
You: “Does every device have to see exactly the same state at exactly the same moment, or is it fine if a device is a few seconds behind as long as it catches up and never loses a change?”
Interviewer: “A few seconds behind is fine. Losing or silently replacing a change is not.”
This is the exactness question, and the answer is a relief. You do not need every device to agree instantly. You need every device to eventually agree, and you need the system to know precisely which version each change started from.
You: “Do we need version history and a trash folder, or does a delete remove the bytes immediately?”
Interviewer: “Keep version history and trash for a retention window.”
That answer affects clean-up later. A piece of a file cannot be deleted just because the newest version stopped using it, because an older version or the trash may still need it.
You: “When two devices edit the same file, should the server merge the edits, let the last save win, or keep both?”
Interviewer: “Keep both as separate copies for general files. Automatic merging is not required.”
This keeps the system honest. A slide deck or a photo cannot be safely merged by a general storage service, so the product keeps both and lets the person decide.
You: “I want to leave live document editing, a full virus-scanning and data-loss-prevention platform, and building a content delivery network from scratch out of scope so we can focus on sync correctness. Does that match what you want?”
Interviewer: “Yes, focus on sync, storage, sharing, conflicts and scale.”
If the interviewer later asks about hash names, version numbers or how change lists work, you do not need to answer yet. Park those until the design decisions, where each one has a natural place.
Functional requirements
Functional requirements describe what the system does. From the answers above, a file sync service must:
- Save and open files and folders from any of a person's devices. A file saved on one device appears in the same folder on the others. This is the core promise, and everything else supports it.
- Upload large files in a way that survives a bad network. A dropped connection continues from the parts that already arrived. Without this, a multi-gigabyte upload on a train would never finish.
- Tell other devices what changed and let them catch up. A device that was off for a week should be able to ask “what happened since I last looked?” and receive just those changes.
- Keep working offline. A device with no signal still lets the person edit, and it sends the changes when it reconnects.
- Keep both edits when two devices disagree. If two devices edit the same file from the same older copy, neither edit is thrown away.
- Keep version history and let people undo a delete. Older versions and deleted files stay available for a retention window, because people overwrite and delete the wrong things.
- Share a folder or a link, with permissions, and allow revoking. A person can give someone read-only or edit access, and can take it back.
Non-functional requirements
Non-functional requirements describe how well the system must do its job. They are the numbers and promises that shape the design.
- Resumable uploads. A broken upload of a 500 MB deck continues from the part that already arrived. Re-sending hundreds of megabytes after every drop would make the product unusable on mobile networks.
- Freshness. Most active devices see a saved change within a few seconds. Slower than that and people start emailing files again.
- Durability. A finished file stays stored even if one copy of the bytes is lost. For a sync product, losing a file is worse than being down for a while.
- Correctness. No change is silently replaced. All devices end up showing the same version, even if they arrive there at slightly different times.
- Security. Every open checks who is allowed to see the file, and a revoked person loses access quickly.
- Scale. Hundreds of millions of people, billions of files and exabytes of file bytes. Saving a change is the hot action, and one shared folder waking thousands of devices is the heavy write.
- Efficiency. Do not send or store the same bytes twice when you can avoid it. This saves money, but it also saves the person's battery and mobile data.
- Visibility. The team must be able to tell whether sync is healthy from the user's point of view, not only whether the servers answer.
Out of scope (and why you park these)
Write a short out-of-scope list on the board so the interviewer sees you can bound the problem.
Live collaborative editing. Editing a document cursor by cursor needs merge techniques such as operational transforms or CRDTs (ways to combine many small edits arriving at the same time). Dropbox-style sync can mention this as a separate product, but the main system protects whole-file versions.
A full malware and data-loss-prevention platform. Virus scanning and enterprise controls matter, but they can run in the background after upload or before a shared download. They should not hide the core sync design.
Designing object storage or a content delivery network from scratch. Use a durable object store (a service that keeps large blobs of bytes reliably) and a content delivery network (servers near users that make downloads faster). The interview is about how you name pieces, number versions, check access and sync devices.
Permanent exact history for every byte. Version history and trash are product rules with a retention window. Keeping everything forever changes cost and privacy, so state the retention rule you assume.
That is the requirements stage. If you want to practice it before reading on, try the requirements stage on Practice System Design (about 5–10 minutes), then come back for the sizing and the decisions.
Minute pacing (about 45-60 minutes)
| Minutes | Focus |
|---|---|
| 0-5 | Clarify sync versus co-editing, file size, history, conflict policy; write requirements; agree out of scope |
| 5-12 | Capacity, then the design decisions and the high-level boxes with one saved-file story |
| 12-25 | Upload path: pieces, which pieces are missing, the commit step |
| 25-35 | Sync path: change list and cursor, offline replay, conflict copy |
| 35-45 | Sharing, permissions, delete and trash, cleaning up unused bytes |
| 45-60 | Production stories, failure modes, what you measure, and interviewer pushback |
In the room (how you open): “I’d start by agreeing what we are building: whole-file sync like Dropbox, not live co-editing, with files up to many gigabytes on unreliable networks. I’d ask how many users and how fast another device must see a change, whether history and trash are needed, and what the product wants when two devices edit the same file. Then I’ll write the requirements and the out-of-scope list on the board, size the problem, and make the design decisions one at a time, so every box I draw has a reason.”
If you remember one thing: Ask first, write the requirements down, and only then design. Tell one saved-file story before you use any internal names.
Capacity estimation
Once the requirements are clear, the next step is to find out how big the problem is, because the size decides how the data has to be split up. We do this before drawing anything, so we do not design for the wrong scale. All numbers below are rough estimates for the whiteboard; tune them in the room and say that you would confirm them with real traffic.
| Dimension | Rough estimate | What this means for the design |
|---|---|---|
| Users and devices | Hundreds of millions of users, several devices each | Each device needs its own remembered position in the list of changes |
| Files and folders | Billions of entries | The folder tree must be split across many machines, not stored as one global tree |
| Stored bytes | Exabytes | Bytes need cheap, durable storage with lifecycle rules and visible clean-up |
| File size | A few KB for notes to multi-GB for videos | Files must be sent in pieces that can resume and run in parallel |
| Pieces per file (4 MB each, illustrative) | A 500 MB deck is about 125 pieces; a 10 GB file is about 2,560 pieces | The list of pieces for one version is small: 2,560 pieces × 32-byte fingerprints is roughly 80 KB |
| Saves per second (assumption: 100 million daily active users, about 10 saved changes each per day) | About 1 billion saves a day, so roughly 11,600 per second on average and perhaps 35,000–60,000 at peak | The save step must be small and fast, and spread over many machines |
| Sync reads | Each save may wake several devices (say three) | Sync reads can exceed saves, so wake-ups must be cheap |
| One shared folder | Thousands of devices may need the same update | Tell devices something changed; let them fetch the details themselves |
What the numbers imply
- The folder database is the part users feel. If it is slow, files look wrong even when the byte storage is healthy. Metadata operations dominate latency, even though bytes dominate the bill.
- Shard count is part of the answer. If one metadata machine comfortably handles a couple of thousand saves per second (an assumption to confirm with a load test), about 50,000 saves per second at peak needs a few dozen machines at the very least. In practice you split much more finely, because the data size alone needs far more machines than throughput does.
- Metadata adds up too. If each saved version records about 2 KB of information (an estimate, since the list of pieces for a large file is bigger), a billion saves a day is on the order of 2 TB of new metadata a day. That is why retention windows and compaction of old versions are real design inputs.
- Egress and retention dominate cost over time. Sending bytes out to devices, and keeping old versions and shared files alive, cost more every month than the database does.
- Sync traffic can exceed upload traffic. One saved file may wake three or four devices, so the cheapest possible wake-up message matters.
- Do not ask every device to hear the whole folder. A shared folder with thousands of devices must send a tiny hint, not the full list of changes, to each one.
Checkpoint: Which part of this system costs the most money, and which part do users feel first?
If you remember one thing: Metadata sets how fast sync feels, and bytes set how much it costs. Treat them as two different problems from the start.
Design decisions
We now know what the system must do, how well it must do it, and roughly how big it is. Now we choose. Each decision below answers one question that the requirements raised, and each one rules out an easier idea that would not survive those requirements. Read them in order, because every decision builds on the one before it.
Decision 1: Where do the file bytes live, and where do the names and versions live?
The requirements asked for version history, per-folder sharing, undo for deletes, and a way to ask “what changed?”. They also asked for exabytes of storage. The first question is where all of this goes, because the wrong store shape makes every later decision harder.
The simplest idea is to treat the service like a disk in the sky. Store each file as one object in a bulk storage service, with the folder path as its name, such as /team/report.pptx. Saving a file overwrites that object, and opening a file reads it back.
It is easy to explain and it breaks against almost every requirement. Overwriting the object destroys the older version, so history and undo are impossible. Renaming a folder with a thousand files would mean copying every byte to a new name. A bulk storage service has no good way to say “list everything in this folder that Maya may read” or “show me what changed since yesterday”. And two devices saving the same path have no version number to compare, so the later arrival simply wins — which is exactly the train-versus-office data loss from the opening story.
The other easy idea is to put everything, including the bytes, in one database. A database is built for small, precise records, not for exabytes of file content, and it would cost far too much and move far too slowly for multi-gigabyte uploads.
So we split the system in two. One part keeps the folder truth: the tree of folders and files, the numbered versions of each file, who may see what, and a log of changes. This is small, precise information that must be exactly right, and it is called the metadata plane (metadata just means “information about the files, not the file bytes themselves”). The other part is the byte store: a large, cheap, durable storage service that holds the actual content and never changes anything it has stored. This is the blob plane (a blob is just a big chunk of bytes). The rule that follows is simple: metadata decides what exists and which version is current, and the byte store only holds bytes. That split is the backbone every later decision hangs on.
Decision 2: How are large files sent so a dropped connection does not start over?
The requirements said a 500 MB upload should continue after the Wi-Fi drops, and that a small edit should not re-send everything. The question is how a big file travels.
The simplest idea is one upload: the whole file in one request. On a good network it is perfectly fine. On the train it fails at 94 percent and starts again from the first byte. It also wastes effort on small edits, because changing one slide would send the whole 500 MB deck again.
There are two ways out. One is to ask the storage service for a resumable upload, where the server remembers how many bytes arrived and the client continues from there. That helps with dropped connections but still treats the file as one object, so small edits still re-send everything. The other is for the client itself to cut the file into chunks, which are pieces of equal size, say 4 MB each (an illustrative size). Each chunk is sent on its own, can be retried on its own, and several can travel in parallel.
We choose client-side chunks. A broken upload then loses at most the chunk that was in flight, and the client simply sends the chunks that did not arrive. Cutting at fixed sizes is the easiest version to explain. Its weakness is that inserting a few bytes near the start of a file shifts every later cut, so almost every chunk changes. A smarter cutting method, covered under Core design approaches, reduces that. In an interview, fixed-size chunks are fine if time is short.
Decision 3: How does the server know which pieces it already has?
Chunks create a new question. If a file is edited slightly, most of its chunks are the same as before. If two people upload the same video, all of the chunks are the same. We would like to skip sending anything the server already holds, which also helps the requirement about efficiency.
The simplest idea is to ignore the question and upload every chunk every time. It is correct and wasteful: a 10 GB file edited in one spot would send 10 GB again, and a popular file would be stored a thousand times.
The better idea is to name each chunk by what is in it. A hash (also called a fingerprint) is a short fixed-length value computed from the bytes, so that the same bytes always give the same value and different bytes almost never do. For a chunk, the client computes the hash, for example a 32-byte value, and sends the server the ordered list of hashes first. The server answers which of them it does not have yet. Only those are uploaded.
Naming chunks by hash gives several things at once. A half-finished upload becomes easy to resume, because “what is left” is just “which hashes are still missing”. The same chunk is stored once no matter how many files or people use it, which is called deduplication. A stored chunk never changes, because changing the bytes would change the name. And the server can recompute the hash when a chunk arrives to catch corruption.
There is a cost. If the server says “I already have that chunk” to anyone, it reveals that someone has uploaded those exact bytes, which can leak that two customers hold the same file. Many products therefore limit deduplication to one company or one encryption boundary, even though it costs more storage. Decision 7 returns to the other cost, which is knowing when a chunk is truly unused.
Decision 4: When does a new version become the current one?
Now the pieces are travelling. The next question is when the rest of the world should start seeing the new version.
The simplest idea is to update the file in place as pieces land. The phone would then see a file that is half old bytes and half new bytes, and if the laptop crashed midway, the file would stay broken. A lock on the file does not fix this, because the lock holder can disappear.
We need a clear moment where the new version either exists completely or does not exist at all. So we add a commit step. First, the client uploads all the missing chunks. Nothing in the folder changes yet. Then the client sends one small request, the commit, that says: “here is the ordered list of chunk hashes for this file, here is the version I started from, and here is a unique id for this request.” The metadata service checks that every listed chunk is stored, and in one all-or-nothing database step it creates a new version of the file (called a revision, written rev), writes the chunk list (called a manifest), updates the folder tree, and adds an entry to the change log.
That commit is the moment the user's save becomes real. Bytes may arrive before it, and notifications, search indexing and thumbnails may arrive after it, but the truth changes only inside that one step. The unique id in the request is an idempotency key, which lets the server recognize a retried request and return the same answer, so a lost response does not create two versions. Decision 6 explains the “version I started from” part.
Decision 5: How does another device learn what changed?
The laptop has committed a new version. The phone needs to find out, and the requirements said within a few seconds for most active devices, without sending the whole folder.
The simplest idea is for each device to ask every few seconds, “show me the whole folder,” and compare with what it has. With hundreds of millions of devices, that is an enormous number of questions, and for a folder with 100,000 files each answer is huge and mostly unchanged.
The opposite idea is for the server to push every change, in full, to every device. That is fast when one file changes, but a folder where 20,000 files change would send 20,000 messages to every device in it, and a device that was offline would miss them with no way to catch up.
The middle road is a change log, also called a journal. For each folder space (a person's root, or a shared team folder, called a namespace), the server appends one numbered entry for every change: entry 41 “file updated”, entry 42 “file deleted”, and so on. Each device remembers a cursor, which is the number of the last entry it has processed. When something changes, the server sends only a tiny hint (“this namespace changed”) through a live connection or a phone notification. The device then asks, “give me everything after entry 41,” receives a page of changes, applies them in order, and downloads the chunks it is missing.
This design survives every case we cared about. A device that was offline for a week asks the same question and gets a longer list. A retry is safe because asking again from the same cursor gives the same answer. And a huge change arrives in pages, not in one burst. The cost is that the device must be able to ask, which is why the hint is never trusted as the data itself.
Decision 6: What if two devices edit the same file from the same starting point?
This is the situation from the opening story: the train laptop and the office laptop both started from the same version of the deck and both saved. The requirement was that no edit is silently replaced.
The simplest idea is last write wins: whichever save arrives last replaces the other. The trouble is what “last” means. The train laptop might have saved first but connected an hour later, so it arrives last and wipes out the office edit, which was the newer work. Using the time on each device's clock is no better, because clocks drift and people can set them to anything.
Other ideas fail too. A lock that says “only one device may edit” cannot work offline, because a device with no signal cannot ask for the lock. Merging the two files automatically is only possible for formats the system understands, and a slide deck or a photo is not one of them.
The choice is to compare versions, not clocks. Every commit says which version it started from, called the parent revision (parent_rev). The metadata service accepts the commit only if the file's current version is still that parent. If the file has moved on, the service does not replace anything. It returns a conflict, or saves the new bytes as a separate conflict copy next to the original, such as “report (conflicted copy from Swati's Mac)”. Both versions are kept, the user sees both, and the user decides. This is slightly annoying and never loses work, which is the right trade for general files.
Decision 7: How do deletes and old versions work without losing or leaking bytes?
The requirements asked for version history and undo, and the byte store is shared by many files through deduplication. That makes deleting dangerous.
The simplest idea is for a delete to remove the file and its chunks. It fails twice. The user cannot undo the delete or open the older version, and, worse, a chunk may be used by another file or by someone else's copy. Deleting it would break files that were never touched.
So a delete is first just another change. The service records a tombstone, which is a version that means “this file was deleted”. It goes into the change log, so every device removes its local copy. The old versions stay readable for the retention window. The bytes are deleted later by a separate background job called garbage collection, which removes a chunk only when no live version, version history entry, trash item, shared folder or legal hold still points to it. Deleting is cheap and reversible; erasing bytes is slow, careful and visible in a dashboard. The deep dive explains how to make that clean-up safe.
Decision 8: How is sharing checked?
The last requirement is security: every open checks who may see the file, and revoking takes effect quickly.
The simplest idea is to put the chunks behind permanent download links, and give those links to anyone allowed. It is fast, since the byte store serves everything directly. But a link that works forever cannot be revoked, and anyone who copies it can read the file.
Another idea is to make the byte store check permissions on every request. The byte store only knows about chunks, not folders, people or sharing rules, so it cannot answer that question.
So the check happens in the metadata service, which knows the folder tree and the sharing rules. When a person asks to open a file, the service verifies their access, including permissions inherited from the folder above, and only then hands out a signed download link: a link that works only for the exact chunks requested and expires after a few minutes. A share link for a person outside the company is a random token that maps to one resource and one permission rule, checked on every use for expiry, revocation and any password. The cost is that cached permission answers can go stale, so they either live for a very short time or are cleared immediately when someone is removed.
Putting the decisions together
Taken together, the eight decisions are the design. The service keeps two stores: a small, exact one for folders, versions, permissions and a change log, and a large, cheap one for chunks that are named by their hash and never change. A device cuts a file into chunks, learns which ones the server lacks, uploads those, and then sends one small commit that names the version it started from. If that version is still current, a new version and a change-log entry appear in one step. Otherwise both edits are kept as separate copies. Other devices receive a tiny hint, read the change log from their cursor, and download only the chunks they lack. Deletes are tombstones, old versions stay for a retention window, and background clean-up removes unused chunks. Every open checks access first and then issues a short-lived link.
In the room (a fuller opening you can actually say): “I’d keep the folder truth, meaning names, versions, permissions and a change log, in a small, exact metadata store, and the bytes in a separate durable store. The client cuts a file into chunks, names each by its hash, asks which ones the server is missing, uploads those in parallel and can resume, and only then commits one small request with the ordered chunk list and the version it started from. If that version is still current, we create a new version and append a change-log entry in one transaction; if not, we keep both and create a conflict copy, because I never want a silent overwrite. Other devices get a tiny hint, ask for changes after their cursor, and download only the missing chunks. A delete is a tombstone with a retention window, and garbage collection removes a chunk only when nothing references it. Every download goes through a permission check and a short-lived link.”
The next section draws these decisions as one picture and shows who owns what.
High-level architecture
The decisions above were made one at a time. This section puts them on one page as a picture: which boxes exist, who owns what, and how a saved file travels through them. The deeper mechanics come later, so keep this at the level of a map.
The design has two stores and one notification loop. The metadata plane owns namespaces, paths, file ids, revisions, sharing and the change log. The blob plane owns immutable chunks in object storage. The notification loop tells devices that something changed, but a device pulls the actual changes with its cursor.
Who owns what:
- Sync client keeps a local folder mirror, a queue of changes made offline, a cache of chunks, and a
last_seqcursor for each namespace. - Metadata service owns the authoritative folder tree, revisions,
parent_revchecks, tombstones, sharing rules and the change log. - Chunk gateway prepares upload sessions, verifies chunk hashes, skips chunks that already exist, and returns pre-signed upload links.
- Object store keeps immutable chunks, encrypted at rest, copied across storage zones, and served through download paths that allow reading part of a chunk.
- Notification service sends “namespace changed” hints by live connection, long poll or mobile push.
- Background workers create thumbnails, update search, scan for abuse, and garbage-collect chunks that nothing references.
[ Desktop / Mobile client ]
|
| 1) list changes, commit metadata, read ACLs
v
[ API / Metadata service ] -----> [ Metadata DB shards ]
| (namespace, file_id, rev, journal)
|
| 2) prepare missing chunks
v
[ Chunk gateway ] -------------> [ Object storage ]
| (chunks by hash, immutable)
|
+--> [ Notification service ] --> clients pull /changes
|
+--> outbox --> thumbnails / search / virus scan / GC
In the room: Narrate the synchronous path first: chunks upload, metadata commit, change-log row. Then say thumbnails, search and garbage collection trail behind and do not decide whether the user has a new file version.
If you remember one thing: Draw two stores first, then the commit between them. Metadata decides what is current; the byte store only holds chunks.
Core design approaches
Several of the decisions above turned down an easier idea. This section lines the alternatives up side by side, so you can say in one breath why each choice was made and when the other choice would be better.
Whole-file upload vs chunked upload
Whole-file upload is easy to explain but punishes users on bad networks. If a 10 GB upload fails at 9.8 GB, the person starts again from byte zero, and a one-slide edit of a 500 MB deck would re-send the whole deck. Chunked upload splits the file into pieces, verifies each piece by its fingerprint (hash), and resumes from the missing pieces only. It also lets a small edit reuse unchanged chunks that the server already holds. Whole-file upload is still fine for tiny notes, and many systems send very small files in one request while chunking only above a size threshold — say a few megabytes — so the common path stays simple.
Fixed-size chunks vs content-defined chunks
Fixed-size chunks are simple: cut the file every few MB. The weakness is that inserting bytes near the front shifts every following cut, so almost every chunk looks new and deduplication helps less. Content-defined chunking cuts chunks based on the byte pattern itself, so a boundary stays where the content stays, and an insertion changes only the chunks near the edit. In an interview, fixed-size chunks are acceptable if time is short; content-defined chunks are a strong follow-up when the interviewer asks how you send less data on small edits of large files.
Last-write-wins vs conflict copy
Last-write-wins means the latest commit replaces the previous one. It is simple and dangerous for offline sync, because the “latest” device may be the one that woke up last, not the one with the correct work. A conflict copy preserves both versions when the parent revision on the commit no longer matches the current revision. The user sees two files side by side and can merge them by hand. For general file sync — slides, photos, binaries — a conflict copy is safer and easier to defend than pretending the server can merge formats it does not understand.
Push full updates vs notify then pull
Pushing every changed path to every device sounds fast, but it creates storms for large folders and makes retry logic messy: a phone that was offline for a week has no clean way to ask “what did I miss?”. A better default is “notify then pull”: push only a lightweight hint that a folder space (namespace) changed, and let devices call the changes API with a remembered cursor. The cursor makes retries safe and lets the server paginate large change sets so a 20,000-file update arrives in pages instead of one flood.
Data model
The architecture names the boxes, so the next question is what exactly each box stores. The records below make versioning and sync obvious on first glance: a numbered file version (often written rev), the older version a device edited from (parent_rev), and a change-log cursor that remembers how far each device has caught up. If those three ideas are missing from the schema, offline edits will fight each other later.
| Entity | Key fields | Why it exists |
|---|---|---|
namespace | namespace_id, owner or team, root folder | Boundary for sharding, permissions and the change-log sequence |
node | node_id, parent folder, name, type, deleted flag | Represents a file or folder in the tree |
file_version | file_id, rev, parent_rev, chunk manifest, size, author, created_at | Stable history of one saved file state |
chunk | chunk_hash, size, storage key, encryption info, refcount or references | Deduplicated immutable bytes |
journal_entry | seq, namespace, operation, node id, new rev, timestamp | What clients read during sync |
share_acl | resource, grantee, role, inherited or direct, version | Enforces read, write and list access |
device_cursor | device id, namespace, last acknowledged seq | Tracks catch-up and avoids full resync |
commit_request | idempotency key, namespace, resulting rev, created_at | Lets a retried commit return the same answer (kept for a limited time) |
For files, store a manifest rather than a giant pointer to one blob. A manifest is the ordered list of chunk hashes for one revision. For folders, store parent-child relationships and decide whether renames are cheap or listings are cheap. A full path stored on every item makes listing easy but large folder moves expensive, because every descendant changes. Parent pointers make moves easy but need careful paging for huge folders.
Deletes should create tombstone revisions, which are change-log entries saying the file was deleted. A tombstone lets other devices delete the local copy and lets version history or trash keep the old bytes until retention expires.
Detailed design
We now know what is stored, so we can put the pieces in motion. Think of file sync as two connected journeys: one device creates a new version, and every other device catches up without guessing. The first journey is chunk upload plus the metadata commit. The second is change-log sync plus chunk download. The design works because the commit is small and authoritative, while the large bytes travel separately.
When a client saves a file, it does not immediately send one giant object and call the job done. It first scans the local file and splits it into chunks. For each chunk, the client computes a content hash, which is a fingerprint of the bytes. The client sends the list of hashes to the chunk gateway. The server answers which hashes already exist and which ones are missing. Existing chunks do not need to be uploaded again. Missing chunks are uploaded through resumable sessions, often directly to object storage through pre-signed links.
After the chunks are present, the client calls CommitFile with the path, the ordered chunk list, a client-generated idempotency key, and the parent_rev it edited from. The parent_rev is the file revision the client believed was current when the edit started. The metadata service checks the current file revision. If the current revision still matches parent_rev, the service creates a new rev, writes the manifest, updates the tree and appends a change-log entry in one metadata transaction. If the current revision has moved on, the server must not silently replace it. It either returns a conflict response or creates a conflict copy with its own file name and revision.
That commit boundary is the important line. Bytes may upload before the file is visible. A notification may arrive after the file is visible. Search indexing and thumbnails can lag. The user-visible truth changes when the metadata transaction creates the new revision and change-log entry.
Another device catches up from the change log. It keeps a last_seq cursor for each namespace. A live connection, long poll or mobile push only wakes the device and says, “check your cursor.” The client calls GET /changes?cursor=..., receives operations after that sequence number, and applies them in order. For an updated file, it fetches the new manifest, compares chunk hashes with its local cache, downloads missing chunks in parallel, and then swaps the local file in only when it has all the required bytes.
Offline clients follow the same rule, just later. While offline, a device queues local edits with the parent revisions it saw. When it reconnects, it first pulls remote changes so it knows the current server state. Then it replays its local commits. Any commit whose parent revision is stale becomes a conflict instead of a silent overwrite. This is why the conflict rule belongs in the core design and not in a small edge-case footnote.
Sharing is checked on both commit and read. A user with read-only access may download chunks through a short-lived link, but cannot commit a new revision. A user whose access was revoked should fail at the metadata permission check before the system issues fresh download links. Cached permission views are useful, but revoking needs cache clearing or short expiry times, because stale permission answers are security bugs.
- The device splits the file into chunks and computes a hash for each.
- The chunk gateway answers which hashes are missing.
- The device uploads the missing chunks, retrying only the ones that fail.
- The device commits the manifest with its
parent_revand an idempotency key. - The metadata service creates the new revision and change-log entry in one transaction, or reports a conflict.
- Other devices receive a hint, read the change log from their cursor, and download only the chunks they lack.
Save path:
Client → chunks:prepare → upload missing chunks → files:commit(parent_rev)
|
v
journal seq appended
Sync path:
Notify hint → GET /changes?cursor=S → manifests → GET missing chunks
In the room (spoken recap): “A save is chunks first, commit second. The client hashes chunks, uploads missing bytes, then commits a manifest with parent_rev. The metadata service creates one new rev and change-log entry if the parent still matches; otherwise it preserves both versions with a conflict copy. Other devices receive a hint, pull changes by cursor, fetch missing chunks and apply the change log in order. Metadata is the truth; blobs are durable bytes.”
API design: chunks, commits, sync and sharing
Like most products, file sync is mostly API calls between a device and the service, so the API design covers three things: the calls a device makes, what it receives back, and how operators change rules.
The calls a device makes to save a file. There are three steps. The first tells the service which chunks exist, the second sends the missing bytes straight to storage, and the third confirms each chunk.
| Endpoint | Role |
|---|---|
POST /v1/chunks:prepare | Client sends chunk hashes; server returns which are missing and upload links |
PUT {pre_signed_url} | Client uploads one chunk (or one part of a multipart upload) directly to storage |
POST /v1/chunks:complete | Server verifies size and hash and marks the chunk available |
The commit. After the chunks are stored, one small request makes the new version real. The idempotency key lets a retried request return the same result.
POST /v1/files:commit
Idempotency-Key: 9f3...
{
"namespace_id": "ns_123",
"path": "/team/report.pptx",
"parent_rev": "rev_7",
"chunks": ["sha256:a", "sha256:b"],
"client_modified_at": "2026-07-15T08:00:00Z"
}
The calls that keep devices in sync and manage files.
| Endpoint | Role |
|---|---|
GET /v1/changes?namespace_id=...&cursor=... | Paged change-log entries after the cursor |
GET /v1/files/{file_id}/versions | Version history, subject to retention |
POST /v1/shares | Create a shared folder or link with a role policy |
DELETE /v1/files/{file_id} | Create a tombstone revision, not an immediate byte delete |
What the client receives. A successful commit returns the new rev and the change-log number. A failed one returns a status the client can act on:
| Status | Meaning | What the client does |
|---|---|---|
| 409 | parent_rev is stale, so someone else committed first | Pull changes, then keep both versions as a conflict copy |
| 403 | The caller has no permission for this action | Show a permission message; do not retry |
| 404 | The resource does not exist or is not visible to the caller | Treat as missing; hiding existence avoids leaking names |
403 with a quota_exceeded code (some systems use 507) | The account is out of storage space | Ask the person to free space or upgrade |
| 429 | This device or namespace is syncing too aggressively | Wait for Retry-After, with a little random delay, then retry |
A client that gets a 409 must not try again with the same parent_rev, because it would get the same answer. A 5xx or timeout is different: the client retries with the same idempotency key, and the server returns the original result if the first attempt did succeed.
How operators change rules. A small internal admin API lets the team change behavior without redeploying clients. These calls are not for end users.
PUT /v1/admin/retention-policies/{id} # how long versions and trash are kept
POST /v1/admin/devices/{id}:throttle # slow down one noisy device or client version
POST /v1/admin/shares/{id}:revoke # emergency revoke across caches
In the room: “A device calls prepare to learn which chunks are missing, uploads them straight to storage, then calls commit with the manifest, its parent revision and an idempotency key. I return 409 on a stale parent so nothing is silently replaced. Other devices call changes with a cursor. Operators can change retention, throttle a bad client version and revoke shares through a small admin API.”
Deep dive: the questions an interviewer asks next
You have drawn the design and walked a saved file through it. This is the point where a good interviewer starts digging, and the questions usually come in a fairly predictable order, because each answer raises the next one. Read this section as that conversation. Each question is followed by an answer you can give, plus a hint of where the interviewer is likely to go next. When you see the next question coming, say that answer before they ask — that is what “leading the room” looks like.
“You said the commit makes a version current. Who owns that decision, and what happens inside it?”
The metadata service owns it, and nothing else does. It owns the namespace's change-log sequence, the current revision of each file, the permission checks and the append-only change log. The byte store does not decide which version is current. It only stores chunks. Keeping “what changed?” in one place is what lets every device agree.
Inside the commit, the metadata service does these steps in one database transaction on the shard that owns the namespace. It checks the caller may write to this folder. It checks that every chunk in the manifest is stored and complete. It compares the file's current revision with the commit's parent_rev. If they match, it inserts the new file version with its manifest, moves the file's current pointer to it, takes the next sequence number for the namespace, and appends the change-log entry. If the transaction fails at any point, none of it happened.
The tricky case is two commits arriving in the same instant with the same parent_rev. The update that moves the pointer is written as “change the current revision to the new one only if it is still the parent”. The database lets exactly one of the two succeed. The other finds the pointer already moved and is treated as a conflict, so there is no moment where both think they won.
Where it goes next: the interviewer will probably ask why you use version numbers and not the timestamps on the files.
“Why not just compare modified times and keep the newest?”
Because modified time is a weak authority. Devices go offline, clocks drift, and the order in which uploads arrive is not the same as the order in which people did the work. Here is what goes wrong:
9:00 Laptop A edits report.pptx offline from rev=7
9:05 Laptop B edits report.pptx online and commits rev=8
9:30 Laptop A reconnects with an older wall clock
Server sorts by mtime or "last upload wins"
→ one version overwrites the other
→ user loses work with no clear explanation
Laptop B's work is newer in every way that matters, yet A's save arrives later and its clock may even claim an earlier time. Whichever rule you pick based on time, one of them will sometimes overwrite the other, and the user will not know why their work disappeared. Device clocks are fine for showing “modified yesterday” in the interface, but they must never decide which bytes survive.
Where it goes next: “So how does the parent revision fix it? Show me.”
“How does the parent revision catch this? Walk me through it.”
Every commit carries the revision it started from, and the server only trusts that, never a clock.
Laptop B commit: parent_rev=7, current=7 → create rev=8
Laptop A commit: parent_rev=7, current=8 → conflict
Result:
report.pptx (rev=8)
report (conflicted copy).pptx (new rev from Laptop A)
B commits first from revision 7, which is still current, so it becomes revision 8. A commits later from revision 7 too, but the file is now at 8, so A's commit does not match. The server preserves both byte streams. It can return 409 Conflict and let the client create the conflict copy, or the server can create the copy directly. Either way, the user never loses a valid edit because the system preferred the wrong timestamp.

Figure: Wall clocks lose user work. Parent revisions preserve both versions and make the conflict visible.
Where it goes next: “What if the commit actually worked but the phone never heard back?”
“The commit succeeded, but the phone lost signal before the answer came back. What happens when it retries?”
This is where the idempotency key earns its place, and the failure without it is subtle. The phone sends its commit from revision 7. The server creates revision 8 and replies, but the reply is lost. The phone, not knowing, sends the same commit again, still saying its parent is revision 7. The file is now at revision 8 because of the phone's own first commit, so without extra protection the server would see a stale parent and create a conflict copy of the phone's own work.
The fix is to store the idempotency key together with the result of the first attempt, for a limited time, say a day. When the retry arrives with the same key, the server skips the comparison and returns the original answer: revision 8. The phone learns its save worked, and there is no duplicate and no false conflict. The rule to say aloud is that retried commits are safe because the key remembers what happened the first time.
Where it goes next: the interviewer may now ask about the chunks that were uploaded but never committed, and about deleting bytes safely.
“How do deduplication and garbage collection stay correct?”
Deduplication saves money only if the reference tracking is right. A chunk may be used by the current version, an older version, a deleted file still in trash, a shared folder, or a legal hold. Garbage collection runs after metadata commits. It reads the authoritative references and deletes only chunks that nothing can reach any more, after the retention window. If you use reference counts, update them in the same transaction as the version commit, or use a periodic sweep that recomputes what is reachable and tolerates being run twice.
The race to name is between clean-up and an upload in progress. A device asks “do you have this chunk?”, the server says yes, so the device skips uploading it. Before the device commits, garbage collection decides the chunk is unused and deletes it. The commit would then point at a chunk that no longer exists. Three habits close this gap. An upload session pins the chunks it was told already exist, for a time limit longer than any real upload. Garbage collection only removes chunks that are both unreferenced and older than a grace period that exceeds that time limit. And the commit checks, inside its transaction, that every chunk in the manifest still exists. Chunks uploaded for a commit that never came are the same case: they become orphans, and the sweep removes them after the grace period.
Where it goes next: “Can a client lie about a chunk, and what about privacy?”
“What if a client claims to have a chunk it never uploaded?”
Two different things can go wrong, and both come from trusting a hash someone else sent. First, a client might upload bytes that do not match the hash it announced. The chunk gateway recomputes the size and hash when the chunk is completed and rejects a mismatch, because a corrupted chunk would poison every file version that points at it.
Second, if the server answers “I already have that chunk” to anyone who sends the hash, a person who knows a hash can pretend to own the file. They would never upload bytes, yet the commit would give them a version containing the real content. The usual answers are to make the client prove it has the bytes (for example by returning a fingerprint of a random part of the chunk that the server picks), or to limit deduplication to one tenant or encryption boundary. Both cost something: proof adds a round trip, and tenant-scoped deduplication stores more copies. Say which one you would pick and why.
Where it goes next: the interviewer may now move from correctness to what happens when a lot of devices wake at once.
“A shared folder changes 20,000 files and thousands of devices are watching it. What stops a storm?”
The change log keeps the wake-ups small. The server does not push 20,000 payloads to every device. It sends one “namespace changed” hint, and each device pages through the change log from its cursor at its own pace. When many devices fall behind, they back off with a random delay so they do not all return in the same second. Devices that are very slow simply read longer pages later.
The same idea protects against bad clients. If a buggy release keeps committing changes that did not change anything, such as rewriting the same folder timestamp, every no-op creates a change-log entry and wakes other devices. So the server detects identical commits and does not log them, tracks sync operations per device and per client version, and uses a circuit breaker that slows or pauses a noisy device before it floods the metadata store.
Where it goes next: “And what breaks first in the metadata store itself?”
“What breaks first inside the metadata store at full scale?”
The place to look is the sequence number. Every commit in a namespace takes the next number, which means commits in one namespace line up one behind another on its shard. For a person's private folder that is no problem. For a huge shared company folder with thousands of active people, that single line can become the limit while the rest of the cluster looks idle. This is reasoning from the design, so say it as a risk to measure.
The ways to ease it are to split a very large namespace into smaller ones along natural boundaries such as top-level shared folders, to hand out sequence numbers in small batches, and to rate-limit or throttle devices that commit too often. Note the cost: splitting a namespace makes a move between the pieces into a more careful two-step action. Cross-namespace moves are rare, so accept that cost.
Say it in the interview: “The conflict detector is not time; it is parent_rev against the current rev. If they differ, I keep both versions. The commit is one transaction in the shard that owns the namespace, a stored idempotency key makes retries safe, and chunks are only deleted after nothing references them and a grace period has passed.”
Larger-scale and failure follow-ups are covered in Scaling the system and Failure handling. Latency and lag measurements belong in Observability and Bottlenecks and tradeoffs.
If you remember one thing: The deep dive is a conversation. Time-based overwrites are the red flag, parent_rev plus an idempotency key is the fix, and each answer is something you could have said before they asked.
Key challenges
The deep dive walked through commit, conflicts, retries, clean-up and storms. What makes the real system hard is applying those rules under messy traffic, and six hard parts show up again and again. Name them early in the interview, because each one is a place the interviewer is likely to push.
| Challenge | What users see if it goes wrong | What to say in the interview |
|---|---|---|
| Large upload resume | A 10 GB upload restarts from zero | Chunk by hash, upload missing pieces, commit the manifest after chunks exist |
| Offline conflict | Someone's edits disappear | Use parent_rev; create a conflict copy instead of a silent overwrite |
| Change fan-out | Devices spin and folders never settle | Notify with hints; clients pull paged change-log entries |
| Sharing revoke | An ex-user still downloads a file | Check the ACL on metadata reads; clear permission caches and expire signed links |
| Delete and version history | Storage grows after users delete files | Tombstones, retention windows and clean-up metrics |
| Dedup privacy | An upload can reveal who has the same file | Limit dedup by tenant or encryption domain when privacy requires it |
The hard parts are not exotic algorithms. They are the everyday rules that prevent data loss: parent revisions, durable manifests, permission checks and observable garbage collection.
If you remember one thing: Conflicts and revokes are design requirements, not production surprises.
Scaling the system
Those hard parts get worse as usage grows, so the next question is what happens when the number of people and files multiplies. You do not have to wait for the interviewer to ask. Right after you finish the design, say the scaling story yourself, then be ready for the follow-ups.
What you can say upfront: “I’d split the folder-truth database by namespace — a person's root or a team's root — because almost every save, list and change-log read stays inside one namespace. That keeps the commit and its sequence number on one shard, which is what makes parent-revision checks and conflict detection understandable. Chunk upload scales by adding more gateways that keep no important state, because each piece is named by its hash and written straight to object storage. Very large shared folders need paged listings and coalesced ‘namespace changed’ hints so thousands of devices are not woken with full payloads. Across regions I would keep one authoritative metadata region per namespace so revision order stays clear, while file bytes can be copied asynchronously for durability and faster downloads.”
That one paragraph answers most of what follows. Here are the follow-ups, in the order they usually come.
Interviewer: “Usage doubles next year. What do you change?”
You: “The stateless parts first: chunk gateways and API servers, which I add behind load balancers. The byte store scales separately because chunks are immutable and addressed by hash. Then I check the metadata shards for commit latency, size and the busiest namespaces, and split finer only where the numbers say so.”
Interviewer: “How do you shard the metadata?”
You: “By namespace, usually a user root or a team root. Most file operations happen inside one namespace, so a commit and its change-log number stay on one shard. Moving something between namespaces is rare, so I implement it as a copy plus a delete, or as a careful two-step action, instead of making the common path distributed.”
Interviewer: “One company folder has thousands of people editing at once. What happens?”
You: “That is the case plain sharding does not solve. Every commit takes the next sequence number in that namespace, so they queue on one shard. I would split the namespace along its top-level shared folders, give very large tenants more capacity, batch sequence numbers, and throttle devices that commit too often. The cost is that moves between the pieces get more careful.”
Interviewer: “How do you list a folder with millions of children?”
You: “With paged listings and stable cursors, so the client asks for the next page after the last item it saw, and a change in the middle does not shift later pages. I would never return a whole huge folder in one response.”
Interviewer: “How do chunk uploads scale, and what must the gateway still check?”
You: “Gateways are stateless because the chunk name is its hash and the bytes go straight to object storage. They still verify the size and hash when a chunk is completed, because a corrupted chunk would poison every file version that points at it.”
Interviewer: “What about more than one region?”
You: “Blob copies can be asynchronous for durability and locality. Metadata for one namespace should usually have one primary region at a time, so revision order and conflict detection stay understandable. If a team spans continents, downloads can be served from regional reads, while commits for that namespace go to the authoritative region. The alternative is several writers per namespace with a much more complicated conflict story, and I would only choose it if the interviewer wants that cost.”
If you remember one thing: Metadata scales by namespace; bytes scale by hash; hot shared folders need splitting and coalesced hints.
Failure handling
Scaling answers “what if there is more of everything”. This section answers “what if something breaks”. Again, say it first. Failures here come from flaky networks, half-finished uploads, retries and stale permissions, and what impresses an interviewer is that the answer was decided before the failure happened.
What you can say upfront: “Every failure decision is made before the failure happens. Nothing becomes the current version unless the folder-truth commit made it so. If chunks upload but the commit never arrives, they are orphans that clean-up removes after a grace period. If the commit succeeds but the reply is lost, the idempotency key makes the retry return the same revision instead of inventing a false conflict. If a metadata shard is down, commits for that shard fail closed — we would rather pause sync than invent a version — and cached reads are labeled as possibly out of date. If the wake-up notification fails, devices still catch up from the change log later. Offline edits that disagree become conflict copies. Permission caches live only a short time, and a revoke clears them so an old signed link cannot outlive access.”
The follow-ups are about the details of those decisions.
Interviewer: “An upload fails halfway. What does the user see and what is left behind?”
You: “The user sees ‘paused’ or ‘retrying’. The client asks
prepareagain, learns which chunks are still missing and sends only those. The chunks that did arrive are harmless: they are unreferenced until a commit lists them, and clean-up removes them after the grace period if the commit never comes.”
Interviewer: “The commit timed out. How does the client know whether the save worked?”
You: “It retries with the same idempotency key. If the first attempt succeeded, the server returns the same revision. If it did not, the server processes it now. Either way there is exactly one new version and no false conflict against itself.”
Interviewer: “A device edits offline for hours. What happens when it reconnects?”
You: “It first pulls remote changes to learn the current state, then replays its local commits with the parent revisions it had. Any commit with a stale parent becomes a conflict copy, with clear wording in the app, and both versions are preserved.”
Interviewer: “A metadata shard goes down. What do you do?”
You: “Commits for namespaces on that shard fail closed, because inventing a current version would break correctness. Cached reads can still work if they are clearly labeled as possibly out of date. Users see slower or paused sync, which is degraded service and not data loss. Bytes already in the store stay safe, and devices catch up from the change log when the shard is back.”
Interviewer: “The object store is slow. What breaks?”
You: “Downloads lag even though the folder listing looks right, so the file shows as syncing. Clients retry range downloads, mark the file as still syncing, and never replace a good local copy with a half-finished one.”
Interviewer: “A person is removed from a shared folder, but their cached link still works. Why?”
You: “Their signed link outlived the permission change. I keep links short-lived, clear permission caches when access is revoked, and for sensitive folders route downloads through a token check that can fail closed, instead of relying on long-lived storage links.”
| Scenario | What the user sees | What to build |
|---|---|---|
| Chunk upload fails halfway | Upload says paused or retrying | Resumable sessions, missing-hash check, incomplete-upload expiry |
| Commit times out after success | Client is unsure whether the save worked | Idempotency key on commit; replay returns the same revision |
| Client edits offline for hours | Conflict copy on reconnect | parent_rev check, clear local wording, preserve both versions |
| Metadata shard down | Folder state cannot be trusted | Fail closed for commits; allow cached reads only with an out-of-date label |
| Object store slow | Downloads lag but the file is listed | Retry range downloads, mark the file as syncing, do not corrupt the local cache |
| ACL cache stale | A revoked user can still access data | Short expiry, explicit clearing, signed-link expiry |
The safe rule is: do not invent a current version unless metadata committed it. If chunks uploaded but the commit failed, the chunks are orphan candidates. If metadata committed but the notification failed, clients catch up from the change log later.
If you remember one thing: Fail closed on commits, keep reads honest about being stale, and let the change log repair missed notifications.
Observability (what you measure)
Failure handling decided what to do when something breaks. Observability is how you notice the break before support tickets pile up. A green upload success rate alone will lie, because uploads can succeed while devices never catch up. Measure the path from the local save to every active device finishing the sync.
| Signal | Why it matters |
|---|---|
| Commit p99 by metadata shard (how long the slowest 1 in 100 commits take) | User-visible save latency and hot namespace pressure |
| Change-log lag per namespace | Devices are falling behind even when APIs return 200 |
| Conflict rate by client version | Finds bad offline replay or clock bugs |
| Chunk dedup hit rate | Shows whether chunking is saving storage as expected |
| Orphan chunks and garbage-collection backlog | Prevents storage bills from growing after deletes |
| Permission denials and revoke propagation time | Confirms revoked shares actually stop access |
| Sync operations per device per minute | Detects client loops and battery-draining releases |
Alert on metadata commit latency, change-log lag and unusual conflict spikes. A silent rise in conflict copies after a client release is as important as a 5xx spike, because it may mean the app is replaying old parent revisions.
Security and abuse
The metrics above tell you when sync is sick. Security is the other half of trust: a sync service holds people's private files, and some callers will try to read what they should not. Every folder operation and every chunk upload or download must prove who is calling. The folder-truth service (metadata) checks permission before it hands out a download link. Those storage links should expire after a few minutes and cover only the exact pieces the caller may read.
Sharing rules need the same care. A person can inherit access from a parent folder, a public link can expire or require a password, and a revoke must stop new downloads quickly. Treat file names and paths as sensitive too. Even if the file bytes are encrypted, a path like /Legal/Acquisition.xlsx can leak private information in logs, so keep raw paths out of everyday logging or store them only in an access-controlled audit trail.
Abuse controls sit on top of that: rate limits on public links, malware scanning before a file is shared widely, detection of mass downloads, and audit records when an enterprise admin opens a file. Cross-user deduplication (storing one copy of identical bytes for many customers) has a privacy cost, because the system can infer that two accounts uploaded the same content. Prefer dedup inside one company or one encryption boundary when isolation matters.
Cost awareness
Security protects trust; cost is what the same design charges every month. Interviewers like to hear that you noticed the bill. The biggest cost is usually not the small folder database. It is storing the file bytes, sending them out to devices (egress), keeping old versions and trash for a retention window, and re-downloading the same pieces during a sync storm. Deduplicating identical chunks reduces storage, but only if reference tracking is correct — otherwise you keep bytes forever. Version history and trash are real product features with real storage invoices attached.
A content delivery network (servers near users that speed up downloads) and regional copies of bytes lower wait time for shared downloads, but they can raise the cost of sending bytes out and of keeping extra copies. Search indexing, thumbnails and malware scans should run in the background and be prioritized, because doing all of them for every intermediate save of a frequently edited file wastes compute. The cheapest sync wake-up is still a tiny hint plus a cursor pull, not pushing the whole folder state to every device.
Green Dashboard. Angry Users. The Production Mindset System Design Interviews Expect.
Cost and security describe the steady state. This section is about what happens on a bad day, told as short stories from the people who carry the pager (the on-call engineers). Production sync failures often look like “sync is stuck” and not “the server is down.” Users care whether the right file version appears on the right device, so on-call must look beyond HTTP 200 and follow the change log, the device cursor and the chunk manifest.
Four nightmares that look fine on a dashboard:
| What the dashboard shows | What is actually happening |
|---|---|
| Every metadata call returns 200 and the load is survivable | A buggy client release is writing no-op changes and the fleet is flooding itself |
| Every upload succeeded | An old device overwrote newer work because nothing compared versions |
| Storage cost keeps rising after a big delete | Chunks are still referenced by trash, versions and holds, and clean-up is behind |
| Revoke calls all succeeded | A signed link outlived the permission change in another region |
Scene 1: The sync storm after a client release
The moment: A company ships a new desktop version of its sync app to everyone on a Tuesday morning. Within hours, support tickets say laptops are hot, fans are loud, and “syncing 12 files” never finishes. Metadata calls return 200, and global traffic looks high but survivable.
The trap: One client bug keeps writing no-op changes, such as rewriting the same folder timestamp. Every no-op creates a change-log entry. Other devices wake, pull changes, and sometimes write their own harmless-looking updates. The system is available, but the client fleet is flooding the metadata store with its own traffic.
What to build: Track sync operations per device and per client version, not only per account. Add server-side no-op detection so identical commits do not create change-log entries. Use circuit breakers that slow or pause a noisy client version. Give clients Retry-After and exponential backoff when the change-log lag grows.
bad client release
→ no-op commits
→ journal grows
→ devices wake and pull
→ more commits / battery drain
Scene 2: Conflict overwrite turns into data loss
The moment: A consultant lands after a long flight, opens their travel laptop, and an hour later tells support that yesterday's presentation — the one they finished at the office — is gone from the folder. Support pulls the logs and sees something confusing: both the office laptop and the travel laptop uploaded successfully, and every save returned 200.
The trap: The system treated “latest upload to arrive” as the winner. The travel laptop still held an older copy from before the flight, reconnected last, and replaced the office laptop's newer work. Nothing compared the version each device started from, so the product had no way to notice the overwrite was unsafe. From the dashboard's point of view the save path was healthy; from the user's point of view a day's work vanished with no conflict file left behind.
What to build: Require every commit to name the parent revision it edited from. When that parent no longer matches the current revision, return 409 or create a conflict copy next to the original so both byte streams survive. Alert on conflict rate by client version and by folder space, because a buggy release that drops parent revisions will look like “successful uploads” while it quietly destroys work. Add a support view that shows both surviving versions and when each was created, so the first ticket is not a forensic project.
Scene 3: Deleted files keep billing storage
The moment: A company deletes a large old project folder to cut its storage bill and waits for usage to fall. A month later the invoice is still climbing, and the legal team asks why deleted contracts still show up in internal storage reports even though people can no longer open the folder in the app.
The trap: File pieces are shared. The same chunk can still be needed by an older version, by trash, by another shared folder, or by a legal hold. The delete only wrote a tombstone (a “this file was removed” change), which is the right first step, but it did not erase every reference. Garbage collection would have cleaned the unreachable bytes eventually, yet nobody measured how old the clean-up backlog was, so finance and legal argued from guesses.
What to build: Break stored bytes down by the reason they are still kept: current version, version history, trash, legal hold, shared link, and orphan waiting for clean-up. Alert when the oldest unreferenced chunk waiting for deletion exceeds the grace period you promised. Give enterprise admins a retention report that matches those buckets, so a cost conversation and a compliance conversation use the same numbers. Keep the grace period longer than any in-flight upload, so clean-up never races a commit that still needs a chunk.
Scene 4: Share revoke is slow in one region
The moment: An employee leaves a company. An administrator removes them from a shared folder that holds contracts, and the admin console shows the revoke succeeded. A few minutes later, security notices the former employee can still download files from a link they saved earlier — and the download is served from another region.
The trap: The folder-truth service revoked access correctly, but the download path still accepted a signed link that outlived the permission change. Either the link lived for hours instead of minutes, or a permission cache in the other region was not cleared, so the chunk store kept serving bytes to someone who should have been locked out. Availability looked fine; the failure was a security race across regions.
What to build: Keep signed download links short-lived (minutes, not hours), and when a folder is sensitive, bind the link to a permission version so an old link fails after revoke. Clear permission caches in every region as part of the revoke path, and measure revoke propagation time the way you measure sync lag. For the highest-sensitivity folders, route downloads through a token check that can fail closed instead of relying on long-lived storage URLs.
In the interview: Pick one scene and tell it as a user story: sync loop, conflict overwrite, clean-up backlog or slow revoke. Name the metric that exposes it and the containment lever you would ship.
Bottlenecks and tradeoffs
Those stories all trace back to a small number of choices where you cannot have both things you want. Interviewers listen for whether you can name the tension, say what breaks, and pick a side on purpose. Here are the four that matter most for file sync.
Metadata consistency vs blob scale
The byte store can scale widely because chunks never change. The metadata store cannot be hand-wavy, because it decides the current revision, permissions and change-log order. If metadata is out of date in the wrong place, users see wrong folders or stale revokes.
Dedup savings vs privacy
Global dedup can save a lot of storage when many users upload the same file. It can also reveal that a user has a known file if the system exposes timing or “already uploaded” behavior. Tenant-scoped dedup and encryption-domain boundaries cost more storage but reduce privacy risk.
Conflict safety vs user convenience
Conflict copies annoy users because they must merge by hand. Silent overwrite is worse because it loses work. For general files, preserve both and let product-specific editors offer smarter merging later.
Fast sync vs battery and backend cost
Asking for changes every few seconds feels fresh but drains batteries and metadata capacity. Push hints plus a cursor pull are cheaper, but clients need backoff and random delay so a large folder update does not wake every device at once.
If you remember one thing: Metadata is the part that must be exactly right; spend your precision there and let bytes be cheap and immutable.
Interview tips
You now have a full design and the tradeoffs behind it, so the last thing to practice is defending it when the interviewer pushes back. These five are the pushes that come up most after you finish the design.
Store each file by its path in object storage — you lose the version story
In the room
You might say: “To keep this simple, I would store each file under its folder path as one object in cloud storage, and every save would replace that object.”
Interview Push: “A user edits the same file offline on two laptops. Which object wins, and how do you avoid losing work?”
Land here: A path is not a version history. Keep a durable record for each file with a stable file id, a numbered revision, the parent revision the editor started from, and an ordered list of chunk fingerprints (the manifest). A commit succeeds only when that parent still matches the current revision. If it does not, keep both versions as a conflict copy instead of choosing a winner. The object store only holds immutable chunks; the folder-truth service decides which manifest is current. That split is what makes history, undo and offline conflict possible.
Compare modified times — clocks are not a sync protocol
In the room
You might say: “Each device looks at the modified time on its local files, uploads whichever copy looks newest, and that becomes the shared truth.”
Interview Push: “What if one laptop has the wrong clock, or reconnects hours later?”
Land here: Device clocks are fine for showing “modified yesterday” in the UI, but they must not decide which bytes survive. Clocks drift, people set them wrongly, and the order uploads arrive is not the order people did the work. The server's change-log order tells devices what changed, and the parent revision on each commit tells whether the edit was based on the current file. Sorting by local modified time can overwrite newer office work with an older offline copy that simply arrived last. Use server-issued revisions for correctness.
Push the whole folder to every device — storms follow
In the room
You might say: “When a file changes, the server pushes the full update — path, bytes, everything — to every device that cares about that folder.”
Interview Push: “A shared folder with 100,000 files changes permissions. Do all phones receive the full tree?”
Land here: Push should only be a wake-up hint that says “this folder space changed.” Each device then pulls a paged change log from the cursor it remembers and applies entries in order. That makes a retry safe (same cursor, same answer), lets a slow phone catch up gradually, and stops a large folder update from turning into a notification storm that drains batteries and floods the metadata service.
Hash every chunk globally — dedup is not free once privacy matters
In the room
You might say: “We fingerprint every chunk and store identical chunks once for the whole product, across all customers, to save storage.”
Interview Push: “Can that reveal that two customers uploaded the same sensitive file?”
Land here: Yes. If the server answers “I already have that fingerprint” to anyone, or if operators can see shared chunk references, the system can leak that two accounts hold the same content. Many products therefore limit deduplication to one company (tenant) or one encryption key space, or they encrypt on the client so identical plaintext becomes different ciphertext. Say the cost out loud: more storage in return for stronger isolation. If clients may claim a chunk they never uploaded, also require a short proof that they actually hold the bytes.
A delete removes the chunks — but they are shared
In the room
You might say: “When a user deletes a file, we delete its chunks from storage right away so the bill drops immediately.”
Interview Push: “What about version history, trash, shared folders and legal holds?”
Land here: A user-facing delete first writes a tombstone revision and appends the change log so every device removes its local copy. The physical chunks stay until nothing still needs them: no live version, no history entry inside the retention window, no trash item, no share, and no legal hold. Add a grace period longer than any real upload so garbage collection cannot race a commit that was told a chunk already existed. Clean-up runs in the background and must be visible through backlog age, or storage bills and compliance reports will disagree for months.
Red flags to avoid without correcting yourself: “Last write wins for all conflicts,” “sync by modified time,” “push full folders,” “delete chunks immediately,” “share links never need re-check after revoke.”
After each push, close with one real part of the design you would build, such as a parent-revision check, a stored idempotency key or a reference-checked sweep, not “we will scale it later.”
What should stick
After working through the requirements, the decisions and the depth sections, you should be able to explain:
- Two stores — metadata owns the folder tree, revisions, permissions and change log; blob storage owns immutable chunks named by their hash.
- Chunks before commit — upload missing hashes first, then commit one version manifest in a single step.
- Change log beats push payloads — notifications wake devices; cursors pull the authoritative change list.
parent_revprotects work — stale offline commits become conflicts instead of overwrites, and an idempotency key makes retried commits safe.- Deletes need retention and clean-up — tombstones sync first; physical chunk deletion waits for references to disappear and for a grace period.
Tell it in the room: “The client chunks and hashes the file, uploads missing chunks, then commits a manifest with parent_rev and an idempotency key. Metadata creates a new rev and change-log entry. Other devices get a hint, pull changes by cursor, and download missing chunks. If the parent revision is stale, I preserve both versions with a conflict copy.”
Quick check before a mock: (1) What makes a new version current? (2) Why not compare modified times? (3) Why delete chunks only after a grace period? → (1) the metadata commit (2) clocks drift and arrival order is not the order of work (3) an upload in progress may still point at a chunk that looks unused.
Practice next: Open Design Dropbox on Practice System Design and run a timed attempt using clarifying questions and one saved-file story, without peeking until you have a draft on the board.
Key Takeaways
- Keep the folder truth (tree, versions, permissions, change log) in a small exact metadata store, and the bytes in a separate immutable chunk store.
- Send large files as hashed chunks, ask which are missing, and upload only those so a dropped connection continues where it stopped.
- A new version becomes real only at the metadata commit, which lists the ordered chunks, the parent revision and an idempotency key.
- Compare
parent_revagainst the currentrev, never clocks; on a mismatch keep both versions as a conflict copy. - Notify devices with a tiny hint and let them pull a paged change log from their cursor, so retries are safe and storms stay small.
- Deletes are tombstones; delete chunks only when nothing references them and an upload grace period has passed.
- Check permissions in metadata before issuing short-lived download links, and clear caches when access is revoked.
- Watch change-log lag, conflict rate by client version, garbage-collection backlog and sync operations per device, not only HTTP errors.
Related Topics
- System design interview guides - Hub of whiteboard walkthroughs
- Notification Service System Design - Waking clients without pushing full state
- Distributed Cache System Design - Metadata caching, invalidation, and hot keys
- Message Queues - Async thumbnails, search indexing, scanning, and clean-up
- URL Shortener on Practice System Design - Token design patterns that apply to secure share links
Quick revision notes
The problem in your own words. A file sync service keeps a person's files the same on every device they own. The hard parts are sending big files over bad networks, knowing which version is current, and never losing an edit when two devices disagree.
The design in one breath. A device cuts a file into hashed chunks, asks which ones the server lacks, uploads those, and then sends one small commit with the ordered chunk list, the version it started from and an idempotency key. The metadata service creates one new revision and one change-log entry in a single transaction, or reports a conflict. Other devices get a hint, read the change log from their cursor and download only the chunks they lack.
The choices you must be able to defend. Two stores, with metadata deciding what is current. Fixed-size chunks first, content-defined chunks as a follow-up. Parent revisions and conflict copies instead of clocks and last-write-wins. Tombstones and a retention window instead of immediate deletes. Short-lived signed links after a metadata permission check.
The numbers worth remembering. A 500 MB file in 4 MB chunks is about 125 pieces, and a 10 GB file is about 2,560 pieces with a manifest of roughly 80 KB. About a billion saves a day is roughly 11,600 per second on average under the assumptions above, and tens of thousands at peak. All of these are estimates to confirm with a load test.
The mistakes that cost points. Treating a path as a version, comparing modified times, pushing full folders, deleting chunks the moment a file is deleted, skipping the idempotency key on commit, and letting a signed link outlive a revoke.
Frequently asked follow-ups
- How do you upload and resume a large file?
- How does another device know what changed?
- How do conflicts work when two devices edit offline?
- How do chunk deduplication and garbage collection stay correct?
- How are share links and folder permissions enforced?
Deep-dive questions and strong answer outlines
Walk through uploading a 10 GB file on flaky Wi-Fi.
The client splits the file into chunks, computes a hash for each chunk, asks the server which chunks already exist, uploads only missing chunks through resumable sessions, and then commits a manifest that lists the chunk hashes in order. The commit is the moment a new file revision appears in metadata; partial chunks are cleaned up later if no commit references them.
How does sync work on a second device?
Each client keeps a namespace cursor. A push, long poll, or periodic check only says something changed. The client calls a changes endpoint with its cursor, receives journal entries such as file updated or deleted, then fetches chunk lists and downloads only missing chunks. The metadata journal is the source of truth for what changed.
What happens when two devices edit the same file offline?
Each commit includes the parent revision the client edited from. If the current server revision no longer matches that parent, the server does not silently replace the newer file. It returns a conflict or saves a conflict copy, such as report (conflicted copy from Swati's Mac). The product may later offer merge tools, but the system design must first preserve both byte streams.
How does deduplication save storage without losing data?
Chunks are named by content hash and stored immutably. File versions reference chunk hashes, and metadata tracks references so garbage collection deletes a chunk only after no live version, trash entry, share, or retention hold points to it. Cross-user dedup can leak information, so many products limit dedup to a tenant or encrypted key space.
How do share links stay secure?
A share link maps a token to a resource and permission policy. The read path checks token validity, expiry, revocation, ACL inheritance, and sometimes password or domain restrictions before issuing download URLs. Cached permissions need short TTLs or invalidation so revoke takes effect quickly.
AI feedback on your design
After a practice session, InterviewCrafted summarizes strengths, gaps, and interviewer-style expectations—similar to a written debrief. See a static example report, then practice this problem to get feedback on your own answer.
FAQs
Q: Is Dropbox the same as Google Docs live collaboration?
A: No. Dropbox-style sync usually works at the file or block level and resolves concurrent edits with revisions and conflict copies. Live document editing uses operational transforms, CRDTs, or another real-time merge model. You can mention that as a separate product surface, but do not turn the Dropbox interview into a Google Docs design unless the interviewer asks.
Q: Why not store each file as one object?
A: One object per file is simple, but it makes resume and small edits expensive. With chunks, a broken 10 GB upload can resume from the missing pieces, and a small edit may upload only changed chunks. The metadata commit still presents one file to the user; chunks are an internal storage shape.
Q: What does version history change?
A: Version history means old manifests remain reachable for some retention window. Deletes become tombstone revisions first, not immediate blob deletion. Garbage collection must respect trash, legal holds, shared folders, and version-retention settings before removing chunks.
Q: Can the server dedupe encrypted files?
A: It depends on the encryption model. If clients encrypt with unique keys before upload, the same plaintext file produces different ciphertext chunks, so cross-user dedup does not work. Server-side encryption after hashing allows dedup, but gives the server more knowledge. Say the privacy and cost tradeoff out loud.
Q: Does push notification contain the full change?
A: Usually no. Push only wakes the client or says a namespace changed. The client then pulls the authoritative change list using its cursor. Pushing full folder trees to every device creates sync storms and makes retries harder.
Practice interactively
Open the practice session to use the canvas and stages, then review AI feedback.