Skip to content
All problems

Design a file sync service (Dropbox-style)

breadth · 45 min · senior/staff

Setting

You're building the sync engine behind a cloud storage product: a user edits files in a local folder on multiple devices, and every device should converge to the same contents without the user thinking about it.

The ask

Design the system that detects a local file change, uploads it efficiently, and propagates it to the user's other devices — including handling two devices editing the same file while offline.

Constraints & scale

  • ~500M files synced across ~100M devices; average file is small, but some files are multi-GB
  • Only the changed portion of a large file should be re-uploaded/re-downloaded on an edit, not the whole file
  • A device that's been offline for weeks must catch up correctly without re-downloading everything from scratch
  • Two devices editing the same file while both offline is a real case — the system must not silently lose either version
  • Sync should feel near-instant for small edits on a good connection, and must not saturate a slow connection so badly the device becomes unusable

What a strong answer covers

Requirements → estimates → chunking/diffing approach → data model (file versions, device state) → high-level diagram (client watcher, sync protocol, storage) → 1–2 deep dives → trade-offs. Likely probes: block-level diffing for large files, conflict detection and resolution, and how a long-offline device resyncs efficiently.

A 45-minute plan

  1. 0-5 min · Requirements
  2. 5-10 min · Estimates/API
  3. 10-25 min · High-level
  4. 25-40 min · Deep dive
  5. 40-45 min · Wrap

What to cover, in order

  1. Requirements
  2. Estimates
  3. Chunking/diffing approach
  4. Data model (file versions, device state)
  5. High-level diagram (client watcher, sync protocol, storage)
  6. 1–2 deep dives
  7. Trade-offs

Where the follow-up questions go

Pick one of these for your deep dive before the interviewer picks for you.

  • Block-level diffing for large files
  • Conflict detection and resolution
  • How a long-offline device resyncs efficiently

Key trade-offs

Decisions a strong answer weighs, and what pushes each one either way.

  • Fixed-size or content-defined chunks. Fixed blocks are trivial to compute and index, but inserting a byte near the start shifts every later block, so the whole tail looks changed. Content-defined chunking picks boundaries from the data, so an edit changes only nearby chunks, at the cost of more CPU on the client and variable chunk sizes.
  • Chunk size. Small chunks give finer deltas and better dedup but more metadata and more requests. Large chunks reduce overhead and re-upload more per edit. Average files here are small, so a single size for everything wastes effort on one end or the other.
  • Poll or push for changes. Polling the server on a timer is simple and burns requests across 100M devices. A long-lived notification channel tells devices when to fetch, which is cheaper at scale but needs reconnect and missed-event handling. Either way, the notification should carry a hint and not the data.
  • Conflict policy. Keeping both versions and surfacing a conflicted copy never loses data and sometimes annoys users. Automatic merge works for some formats and cannot be correct for binaries. Last writer wins is the simplest and loses work whenever two offline edits meet.
  • Global dedup or per-user. Deduplicating chunks across all users saves a lot of storage, but lets someone probe whether a file already exists, and complicates deletion and encryption. Per-user dedup is safer and saves less.

Common mistakes

What goes wrong most often on this problem, and why it hurts.

  • Uploading the whole file on every change. A multi-gigabyte file with a one-line edit then costs gigabytes of bandwidth, and sync feels broken on slow links.
  • Identifying changes by modification time alone. Clocks differ between devices, and tools rewrite timestamps without changing content. Content hashes are the source of truth, with timestamps as a cheap first filter.
  • Walking the full tree to find what changed. A device that comes back after weeks cannot afford to compare everything. It needs a server-side change sequence it can ask for "everything since" a token.
  • Metadata and file bytes in one system. The directory tree needs transactions and fast listing, while blobs need cheap bulk storage. Mixing them gives you the worse properties of both.
  • No resumable or throttled transfers. Large uploads over flaky or slow links must resume where they stopped and must leave bandwidth for the rest of the device.

Graded on

Requirements & scoping · Estimation · API & data model · High-level architecture · Deep dive · Scalability & performance · Reliability & consistency · Trade-offs · Operability · Communication & drive

Ready to run this one for real?

Try this problem free

Your first session is free. Sign in, and you land on this brief, ready to start.