Google Drive
Problem Statement
Design a Google Drive–like cloud-based file storage and synchronization system that allows users to upload, store, share, and access files (documents, images, videos, etc.) from any device securely and efficiently.
The system must support real-time file collaboration, versioning, access control, syncing across devices, and scalable storage management with high availability and durability.
🎯 Objective
Build a scalable, distributed, and fault-tolerant file storage service that:
✅ Functional Requirements
1. User Management
2. File Management
3. Folder & Hierarchy Management
4. Sharing & Permissions
5. Synchronization
6. Collaboration
7. Search & Metadata
8. Storage Management
9. Version Control
10. Notifications
⚙️ Non-Functional Requirements
| Attribute | Requirement |
| ----------------- | ------------------------------------------------------- |
| **Scalability** | Handle millions of users and billions of files |
| **Availability** | 99.99% uptime |
| **Durability** | 11 nines (99.999999999%) for file storage |
| **Consistency** | Strong consistency for metadata, eventual for file sync |
| **Latency** | Upload/download latency < 1s for small files |
| **Security** | End-to-end encryption, role-based access control |
| **Reliability** | Automatic recovery and replication |
| **Observability** | Metrics for sync success, latency, storage health |
🧩 Core Components
| Component | Responsibility |
| --------------------------- | ---------------------------------------------------------------- |
| **API Gateway** | Entry point for clients (upload, download, share) |
| **Authentication Service** | OAuth/JWT-based auth and user sessions |
| **Metadata Service** | Manages file/folder metadata, hierarchy, and permissions |
| **Storage Service** | Stores actual file chunks in distributed storage (e.g., S3, GFS) |
| **Upload/Download Service** | Handles chunked uploads, resumable transfers |
| **Sync Service** | Manages background syncing and conflict resolution |
| **Search Indexer** | Builds search index for metadata and content |
| **Notification Service** | Pushes changes to clients in real time |
| **Versioning Service** | Tracks and stores file revisions |
| **Access Control Service** | Validates sharing permissions for each request |
| **Audit & Logging Service** | Tracks all file operations for compliance |
🧱 High-Level Architecture
1
2 +------------------------+
3 | Client Devices |
4 | (Web, Mobile, Desktop) |
5 +-----------+------------+
6 |
7 v
8 +---------+---------+
9 | API Gateway |
10 +---------+----------+
11 |
12 +-------------------------------------------------+
13 | Backend |
14 |-------------------------------------------------|
15 | |
16 | +---------------+ +----------------------+ |
17 | | Auth Service | | Metadata Service | |
18 | +---------------+ +----------------------+ |
19 | | | |
20 | v v |
21 | +---------------+ +----------------------+ |
22 | | Access Control| | Versioning Service | |
23 | +---------------+ +----------------------+ |
24 | | | |
25 | v v |
26 | +---------------+ +----------------------+ |
27 | | Sync Service | | Search Indexer | |
28 | +---------------+ +----------------------+ |
29 | | | |
30 | +---------------+ +----------------------+ |
31 | | Notification | | Storage Service | |
32 | | Service | | (Object Store / GFS) | |
33 | +---------------+ +----------------------+ |
34 +-------------------------------------------------+
35 |
36 v
37 +--------------------------+
38 | Distributed Object Store |
39 | (S3 / GFS / HDFS) |
40 +--------------------------+🧾 Data Model (Simplified)
File Metadata Table
| Field | Description |
| ---------------- | ------------------------- |
| file_id | Unique file identifier |
| user_id | Owner of the file |
| name | File name |
| parent_folder_id | Folder reference |
| size | File size |
| version | Current version number |
| is_deleted | Boolean flag |
| permissions | Access control list (ACL) |
| created_at | Timestamp |
| updated_at | Timestamp |
File Chunk Table
| Field | Description |
| --------------- | ------------------------ |
| chunk_id | Unique chunk ID |
| file_id | Reference to file |
| storage_path | Location in object store |
| checksum | Integrity hash |
| sequence_number | Order of chunk |
| size | Size of chunk |
Version Table
| Field | Description |
| ------------ | ---------------------------- |
| file_id | File/folder reference |
| user_id | User with access |
| access_level | VIEWER / EDITOR / OWNER |
| shared_via | Direct link / explicit share |
| expires_at | Optional expiry timestamp |
⚡ Scalability & Performance Considerations
| Challenge | Solution |
| -------------------------------- | ------------------------------------------------- |
| Large file uploads | Multipart uploads with parallel chunking |
| Hot files accessed by many users | CDN caching and read replicas |
| Metadata scale | Sharded metadata DB (based on user_id or file_id) |
| Sync conflicts | Versioning and last-writer-wins merge |
| Search performance | Use Elasticsearch for metadata and content |
| Storage cost | Deduplication and compression |
| Data durability | Triple replication across regions |
🔐 Security & Compliance
🧠 Tech Stack (Example)
LayerTechnology
Frontend Clients
React (Web), Kotlin/Swift (Mobile)
Backend Framework
Java Spring Boot / Go / Node.js
Database (Metadata)
PostgreSQL / CockroachDB / Spanner
Storage Layer
AWS S3 / GCP Storage / HDFS
Search
Elasticsearch / OpenSearch
Queue
Kafka / RabbitMQ
Cache
Redis
Monitoring
Prometheus + Grafana
Auth
OAuth2.0 / Keycloak / Firebase Auth
🚨 Failure & Recovery
FailureMitigation
Node failure
Replicated data and auto-failover
Metadata DB corruption
Daily backups and multi-region replication
File upload interruption
Resumable uploads with chunk checksum validation
File conflict
Version creation and user conflict resolution
Data loss
Replication + periodic integrity checks
💡 Possible Extensions
✅ End Goal
Design a highly available, secure, and distributed file storage system (like Google Drive) that enables uploading, sharing, syncing, and collaborating on files with versioning, access control, and durability guarantees across billions of files and users.