Swiftorial Logo
Home
Swift Lessons
AI Tools
Learn More
Career
Resources

System Design FAQ: Top Questions

7. How would you design a File Storage System (like Dropbox)?

A File Storage System allows users to upload, retrieve, and synchronize files across devices while ensuring durability, security, and efficient version management. Examples include Dropbox, Google Drive, and Box.

๐Ÿ“‹ Functional Requirements

  • Upload/download files
  • File versioning
  • Sharing and permissions
  • Cross-device sync

๐Ÿ“ฆ Non-Functional Requirements

  • High durability (99.999999999%)
  • Efficient metadata and large file handling
  • Scalability and fault tolerance

๐Ÿ—๏ธ Architecture Overview

  • Frontend: File UI + Sync client
  • API Gateway: Auth, routing, metadata access
  • Metadata Service: Stores file paths, versions, ownership
  • Storage Layer: S3 or object store for file blobs
  • Database: PostgreSQL or Cassandra for metadata

๐Ÿ“ File Metadata Table


CREATE TABLE files (
    id UUID PRIMARY KEY,
    user_id UUID,
    filename TEXT,
    version INT,
    path TEXT,
    size BIGINT,
    blob_key TEXT,
    created_at TIMESTAMP DEFAULT now()
);
        

๐Ÿ“ค Upload Flow

  1. Client calculates file hash (e.g., SHA-256)
  2. Checks server for existing file (deduplication)
  3. Uploads to object storage (S3/MinIO)
  4. Stores metadata in DB

๐Ÿ” Signed Upload URLs (AWS S3)


import boto3

s3 = boto3.client('s3')
url = s3.generate_presigned_url(
    'put_object',
    Params={'Bucket': 'myapp-bucket', 'Key': 'user123/file.txt'},
    ExpiresIn=3600
)
print(url)
        

๐Ÿงฌ Chunked Upload Strategy

  • Split large files into parts (e.g., 5 MB)
  • Upload each chunk in parallel
  • Use checksum to verify and reassemble

๐Ÿ”„ Sync Design

  • Client watches file system for changes (e.g., inotify)
  • Syncs diffs to backend
  • Version conflict resolution at server

โ˜๏ธ Example S3 Bucket Policy for Read/Write


{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": "*",
      "Action": [
        "s3:GetObject",
        "s3:PutObject"
      ],
      "Resource": "arn:aws:s3:::myapp-bucket/*"
    }
  ]
}
        

๐Ÿงช Observability

  • Track API usage and upload success/failure
  • Use Prometheus to monitor file queue lag and sync latency
  • Set up alerts for upload spikes and storage thresholds

๐Ÿ“Œ Final Insight

A file storage system needs to separate file content (blobs) from metadata, support versioning, and efficiently scale reads/writes. Using signed URLs, chunking, and object storage systems enables safe, durable file management across millions of users.