System Design Problems
Design Google Drive
Google Drive enables users to store files in the cloud, sync across devices, and share with collaborators. The system must handle file uploads (up to 5 TB), real-time sync, conflict resolution when multiple users edit simultaneously, and efficient delta sync for large files.
- File Sync â Changes propagate across devices within seconds
- Conflict Resolution â Handle concurrent edits gracefully
- Sharing â Granular permissions (view, comment, edit) per file/folder
The fundamental challenge is synchronization: when two users edit the same file simultaneously, the system must resolve conflicts without losing data.
Requirements
Functional Requirements
- Upload and download files (up to 5 TB)
- Real-time sync across multiple devices
- File versioning and history
- Conflict resolution for concurrent edits
- Sharing with permissions (view, comment, edit)
- Folder hierarchy and organization
- Offline editing with sync on reconnect
Non-Functional Requirements
- Latency: Sync changes within 5 seconds
- Durability: 99.999999999% (11 nines)
- Availability: 99.99%
- Scale: 1 billion files, 500M active users
- Bandwidth: Efficient delta sync for large files
Back-of-the-Envelope Estimation
High-Level Architecture
Detailed Design
File Chunking and Block Storage
Delta Sync
Conflict Resolution
For binary files (PDF, images):
- User A edits file offline
- User B edits file online
- User A reconnects and syncs
- System detects conflict (version mismatch)
- Creates "conflict copy" for User A
- User B's version becomes the current version
- User manually merges if needed
File Versioning
File versions:
v1: block_1, block_2, block_3 (created 2026-06-18)
v2: block_1, block_4, block_3 (created 2026-06-19, block_2 changed to block_4)
v3: block_5, block_4, block_3 (created 2026-06-20, block_1 changed to block_5)
Sharing and Permissions
File ACL:
{
"file_id": "file_123",
"owner": "user_a@example.com",
"permissions": [
{ "user": "user_b@example.com", "role": "editor" },
{ "user": "user_c@example.com", "role": "viewer" },
{ "group": "team@example.com", "role": "commenter" }
]
}
Practice Exercises
-
Design: How would you implement real-time collaborative editing for Google Docs (not just binary files)? Design the Operational Transformation system.
-
Scale: If 500M users each have 10 GB of files with a deduplication ratio of 3x, estimate the total storage and the block storage architecture.
-
Sync: Design a delta sync algorithm that efficiently computes the diff between two versions of a 10 GB video file.
-
Offline: How would you handle offline editing where the user edits a file on two devices without internet? Design the conflict detection and resolution strategy.
What to Learn Next
-> Design Google Docs Real-time collaborative editing with OT/CRDT.
-> Design Object Storage Block storage and deduplication at scale.
-> Data Replication Replicating file data across data centers.
-> Design Chat System Real-time sync with WebSocket and conflict resolution.
-> Caching Strategies Caching frequently accessed files at the edge.
-> Security Patterns File encryption and access control.