The interviewer asked me to design Dropbox file sync. I froze for a minute because I jumped into architecture before I nailed requirements.
So I restarted with questions: single user or teams? offline edits? conflict handling? max file size? latency vs battery? Windows/Mac/Linux? end to end encryption? I scoped to: multi-device per user, near-real-time, offline support, conflict resolution, and basic sharing later.
Then I wrote the core objects and APIs. Data model: User, Device, File, FileVersion (content hash, size, chunk list), Folder, Cursor/Checkpoint, and an Event log (append-only). APIs: UploadChunk, CommitFile(version, parentVersion), ListChanges(cursor), Download(version), Ack(cursor). Everything is idempotent with content hashes and request IDs.
Architecture: client watches filesystem, batches changes, chunks large files, uploads to blob storage keyed by hash, then commits metadata to a strongly consistent store. Server writes an event per commit. Clients long-poll or use a push channel to get change events, then pull missing blobs.
Scaling: hot path is metadata and change feed. Partition event logs by user/team, cache cursors, and keep blobs on cheap object storage with CDN for downloads. Dedup by hash saves real money when the same installer shows up on 500 laptops. Background compaction for old versions and tombstones.
Tradeoffs I called out: strong consistency on metadata avoids weird conflicts but costs latency on cross-region; eventual consistency makes sync feel faster but harder to reason about. Chunk size trades memory and upload overhead vs retry cost. Conflict policy can be last-writer-wins (simple, lossy) or keep both versions (messy, safer).
Failure cases: client crashes mid-upload so you need resumable multipart and garbage collection for orphaned chunks; network flaps so commits must be idempotent; clock skew so ordering cannot trust timestamps; two devices edit offline so you fork versions and surface a conflict file; duplicate events so cursor ack must tolerate replays; permissions changes during sync so downloads need auth checks at read time, not just at commit time