Design a File & Photo Upload Service (like Google Drive)
Problem Statement
Design a highly scalable, reliable, and secure file upload and storage service (similar to Google Drive or Dropbox) that allows users to upload, store, view, share, and manage files and photos from multiple devices.
The system should support large file uploads, automatic resumptions, versioning, and preview capabilities (especially for images, videos, and documents).
🎯 Objective
Build a distributed system that can:
✅ Functional Requirements
1. User Operations
Upload Files/Photos
View Files
Download Files
Share Files
Search and Filter
Sync
⚙️ Non-Functional Requirements
| Attribute | Goal |
| ------------------- | --------------------------------------------------------- |
| **Scalability** | Handle millions of users and billions of files |
| **Durability** | Ensure zero data loss (≥99.999999999% durability like S3) |
| **Availability** | ≥99.99% uptime |
| **Latency** | Upload < 5s/GB (chunked), metadata queries < 100ms |
| **Security** | Data encryption (at rest and in transit) |
| **Reliability** | Resume failed uploads, detect corruption |
| **Cost Efficiency** | Optimize storage tiering and CDN usage |
🧩 Core Components
| Component | Responsibility |
| ----------------------------- | ------------------------------------------------------------ |
| **Upload API Service** | Handles user uploads, chunking, and validation. |
| **File Storage Service** | Stores actual file blobs (S3 or distributed file system). |
| **Metadata Service** | Manages file info (owner, type, size, version, permissions). |
| **User Service** | Handles user authentication & authorization. |
| **Sharing Service** | Generates and validates shared links. |
| **Thumbnail/Preview Service** | Generates previews for photos/docs. |
| **Sync Service** | Syncs changes across devices. |
| **Notification Service** | Alerts users on upload completion, sharing, or updates. |
| **CDN Layer** | Serves frequently accessed files and thumbnails globally. |
🧱 High-Level Architecture
1
2 +-------------------------+
3 | Client App |
4 | (Web / Mobile / Desktop)|
5 +-----------+-------------+
6 |
7 v
8 +----------+-----------+
9 | API Gateway |
10 +----------+-----------+
11 |
12 +-----------------------------------------+
13 | |
14 v v
15+--------+ +--------------+
16| Upload | | Metadata |
17| Service|<-----> Object Storage ---->| Service |
18+--------+ +--------------+
19 | |
20 | v
21 | +---------------+
22 | | DB (SQL/NoSQL)|
23 | +---------------+
24 |
25 +--> Chunk Processor
26 | + Deduplication
27 | + Virus Scan
28 |
29 v
30+------------------+
31| Thumbnail Service|
32+------------------+
33 |
34 v
35 +--------------+
36 | CDN Layer |
37 +--------------+
38 |
39 v
40 +------------------+
41 | End Users / APIs |
42 +------------------+⚡ Key Flows
1. File Upload Flow
2. File Download Flow
3. File Sharing Flow
🧾 Data Model (Simplified)
| Field | Description |
| ------------ | ------------------------- |
| file_id | Unique ID (UUID) |
| user_id | Owner of the file |
| file_name | Original name |
| file_type | MIME type |
| file_size | In bytes |
| storage_path | Location in object store |
| checksum | SHA256 for integrity |
| version | For version history |
| created_at | Upload timestamp |
| shared_with | List of users/permissions |
🔒 Security Considerations
🧠 Scalability Considerations
| Challenge | Solution |
| ----------------------- | ---------------------------------------------------- |
| **Large file uploads** | Chunked upload + resumable sessions |
| **Hot files (popular)** | Serve via CDN edge cache |
| **Metadata scaling** | Shard metadata DB by user or file ID |
| **Storage growth** | Use tiered storage (hot/cold/archive) |
| **Concurrency** | Use message queues for async processing (Kafka, SQS) |
| **Fault tolerance** | Replicate data across regions |
| **Sync across devices** | Use event-driven updates via WebSockets |
📊 Observability and Monitoring
🧩 Possible Extensions
✅ End Goal
Design a Google Drive–like upload and storage platform that can: