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
- Client calculates file hash (e.g., SHA-256)
- Checks server for existing file (deduplication)
- Uploads to object storage (S3/MinIO)
- 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.
