KatInterview

Build a Cloud File Sync and Storage Platform

System DesignModel answer
HardModel answerSystem Designdistributed-systemsstoragesync

Last updated

Architect a scalable system for storing, synchronizing, and sharing files across devices with versioning, conflict resolution, and offline support.

You're tasked with architecting a cloud-based file storage and synchronization platform similar to modern file-sync services. Users should be able to upload files and folders, keep them synchronized across their devices, collaborate through sharing, and recover previous versions.

Your system must support:

  • Core synchronization: Upload and download files; monitor local filesystem changes; propagate updates to all connected devices
  • Efficient transfers: Handle large files through chunking and resumable transfers; sync only changed portions of files; eliminate duplicate data storage
  • History and recovery: Maintain version history for each file; support restoration of deleted or previous versions
  • Conflict handling: Resolve simultaneous edits from multiple devices, including changes made while offline
  • Offline operation: Allow clients to work disconnected and reconcile changes upon reconnection
  • Collaboration: Enable sharing files and folders with individuals or groups; support public links with permissions and expiration
  • Real-time updates: Notify devices of changes immediately via push mechanisms with appropriate fallbacks
  • Security: Protect data in transit and at rest; compare server-side versus client-side encryption approaches
  • Mobile optimization: Respect battery, bandwidth, and background execution constraints; support selective synchronization
  • Resource management: Track and enforce storage quotas; account for savings from deduplication and compression
  • Data organization: Design schemas for files, chunks, versions, permissions, deletion records, and change tracking
  • Consistency guarantees: Define what users see when reading and writing from different devices simultaneously
  • Operational scale: Plan for hundreds of millions of users; address sharding, hot partitions, monitoring, disaster recovery, and schema evolution

Focus on the fundamental architecture, critical trade-offs, and how components interact. Real-time collaborative document editing is out of scope.

Hints

Hint 1

Separate metadata (filenames, permissions, versions) from content (actual file bytes) into different storage systems

Hint 2

Use content-addressable storage where chunks are identified by their cryptographic hash to enable deduplication

Hint 3

Maintain an append-only change log per user or shared folder to enable efficient synchronization and conflict detection