System Design File Storage and Sync: Interview Talk Track
"Design a cloud file storage and sync service" asks you to build something most people use every day: upload a file on one device, see it on another, share it with a teammate. It's a rich prompt because it combines large binary data, metadata consistency, synchronization across devices, and conflict handling.
This system design file storage interview guide gives you a talk track for a 45-minute round. Use it as a skeleton, and let the interviewer choose where to go deep.
1. Clarify requirements (about 5 minutes)
Functional:
- Upload, download, and delete files and folders.
- Sync changes automatically across a user's devices.
- Share files or folders with other users, with view or edit permissions.
- Keep a version history so users can restore older versions.
Non-functional:
- Scale: how many users, and what's the typical and maximum file size?
- Durability: losing user files is unacceptable, so durability matters more than almost anything else.
- Consistency: users expect to see their own changes immediately; other devices can catch up within seconds.
- Bandwidth efficiency: re-uploading an entire large file after a tiny edit is wasteful.
State assumptions out loud: "I'll assume hundreds of millions of users, files from a few kilobytes to several gigabytes, read-heavy access, and very high durability requirements."
2. Key idea: separate metadata from content
Say this early, because the rest of the design builds on it:
- Metadata service: file names, folder hierarchy, owners, permissions, versions, and the list of chunks that make up each file version. Stored in a database with strong consistency.
- Blob storage: the actual file bytes, stored as chunks in a durable object store.
Metadata is small and queried often. Content is huge and mostly immutable. They have different scaling and consistency needs, so they should live in different systems.
3. Chunking
Split each file into chunks, for example a few megabytes each, and identify each chunk by a hash of its content.
Benefits:
- Resumable uploads: if the connection drops, only missing chunks are re-sent.
- Delta sync: after an edit, only changed chunks are uploaded.
- Deduplication: identical chunks, whether within one user's files or across users, are stored once.
- Parallelism: chunks upload and download concurrently.
A file version becomes an ordered list of chunk hashes. Mention that fixed-size chunks are simple, while content-defined chunking handles insertions in the middle of a file better, at some cost in complexity.
4. Upload flow
- The client splits the file into chunks and computes hashes.
- It asks the metadata service which chunks are already stored.
- It uploads only the missing chunks to blob storage, ideally using short-lived pre-signed URLs so bytes skip the application servers.
- It commits a new file version to the metadata service: file ID, parent folder, chunk list, and the version it was based on.
- The metadata service records the version and publishes a change event.
The commit in step 4 is what makes the new version visible, so a half-finished upload never appears as a corrupted file.
5. Sync across devices
Each client needs to learn about changes quickly.
- Change log: the metadata service keeps an ordered, per-user (or per-namespace) log of changes with a cursor.
- Notifications: clients hold a long-lived connection, such as long polling or WebSockets, to a notification service that says "something changed."
- Pull changes: the client then asks for all changes since its last cursor and downloads any new chunks.
This "notify, then pull from a cursor" approach is robust: if a notification is lost, the next poll still catches up.
6. Conflicts
Two devices edit the same file while one is offline. What happens?
- Each commit includes the base version it was edited from.
- If the base version is no longer current, the metadata service rejects the commit as a conflict.
- The simplest user-friendly policy: keep both, saving the second as a "conflicted copy" and letting the user resolve it.
Mention that real-time collaborative editing of documents is a different problem with different techniques, and that you're designing file-level sync. That scoping shows judgment.
7. Sharing and permissions
- Store access control entries in the metadata database: which user or group has which role on which file or folder.
- Permissions inherit down folder trees, with explicit overrides.
- Every download and upload request checks permissions in the metadata service before issuing a pre-signed URL.
- Shared links can be modeled as tokens with a scope and an expiry.
8. Scaling
- Metadata: shard by user or namespace ID so each user's tree and change log live together. Cache hot metadata, like folder listings, with careful invalidation.
- Blob storage: the object store scales horizontally; chunks are immutable, which makes caching and replication simple.
- Downloads: popular shared files can be served through a CDN.
- Notification service: scales horizontally; connections are distributed across many servers.
9. Durability and failure handling
- Replicate chunks across multiple availability zones, or use erasure coding to reduce storage cost while keeping high durability.
- Verify chunk hashes on upload and periodically in the background to catch corruption.
- Garbage collection: chunks referenced by no file version (after version-history retention ends) can be deleted, but carefully. Use reference counting or mark-and-sweep with a grace period, because deleting a chunk still in use is unrecoverable.
- If the metadata commit fails after chunks are uploaded, the orphaned chunks are harmless and will be cleaned up later.
10. Wrap-up
Summarize: metadata separated from content, content-addressed chunks for dedup and delta sync, a commit step for atomic versions, a change log with notifications for sync, conflict copies for concurrent edits, and replication plus careful garbage collection for durability. Offer extensions: search across files, thumbnail previews, or storage quotas.
Practice the talk track out loud
This design has many moving parts, so structure is everything. Rehearse the outline with a timer and practice switching gears when the interviewer asks you to go deep on chunking or conflicts. Luna Interview gives you a structured place to practice that kind of spoken walkthrough and stay calm under follow-up questions.
Talk track checklist
- [ ] Requirements and scale assumptions stated
- [ ] Metadata separated from blob storage
- [ ] Chunking with content hashes explained
- [ ] Upload flow with an atomic commit step
- [ ] Sync via change log and notifications
- [ ] Conflict policy described
- [ ] Permissions and sharing covered
- [ ] Durability and safe garbage collection discussed
Rehearse with an AI interview copilot, then browse commonly reported interview questions.