Skip to main content
BLUEPRINT #02Media & Streaming

Design Google Drive File Sync & Storage

Target AWS Architecture:DynamoDBS3ElastiCacheSQS
10-Stage Structure:1. Requirements→2. Sizing→3. Topology→4. Data Model→5. AWS Topology→6. Deep-Dive→7. Failures→8. SRE Playbooks

1. Problem Statement & Scope

System Mission

Design an enterprise-grade, cross-platform cloud file storage and multi-device synchronization engine capable of managing billions of files, supporting content-defined chunking (), block-level differential synchronization (delta sync), global data deduplication, real-time cross-device mutation push, and ACID-compliant directory namespace management.

Interactive Architecture Diagram
Synthesizing vector architecture diagram...

Functional Requirements

  1. Hierarchical File Management: Support nested folder hierarchies, renaming, moving, and soft/hard deletions (Trash).
  2. Block-Level Differential Delta Sync: Split files into content-defined chunks (4Β MB4\text{ MB} average), compute cryptographic hashes (SHA-256), and transfer only modified blocks over the network.
  3. Global Content Addressable Storage (CAS) Deduplication: Deduplicate identical blocks across all files and users globally to minimize raw storage footprint.
  4. Real-Time Multi-Device Fanout: Instantly notify all connected devices (desktop, mobile, web) when files are modified, added, or deleted.
  5. Revision History & Conflict Resolution: Maintain granular 30-day revision history with automatic creation of "Conflicted Copies" during concurrent offline edits.

Non-Functional Requirements (SLAs/SLOs)

  • High Availability: 99.999%99.999\% uptime for file read/write APIs (<5.26Β minutes< 5.26\text{ minutes} downtime/year).
  • Data Durability: 11 9s (99.999999999%99.999999999\%) durability via multi-AZ storage.
  • Sync Propagation Latency: Delta sync notification delivered to online peer devices in <500Β ms< 500\text{ ms} globally (P95P95).
  • Network Bandwidth Optimization: Delta sync must achieve β‰₯90%\ge 90\% bandwidth savings on incremental edits of large documents.
  • Client Resource Footprint: Local client RAM <150Β MB< 150\text{ MB}, background CPU <1%< 1\% when idle.

Out-of-Scope

  • Collaborative real-time rich-text co-authoring engines (OT / CRDT character-by-character live document typing as in Google Docs; covered in collaborative editing blueprints).
  • Server-side full-content Optical Character Recognition (OCR) and deep AI semantic video indexing.

2. Capacity & Scale Estimation

Traffic & Scale Assumptions

  • Total Registered Users: 500Β Million500\text{ Million} users.
  • Daily Active Users (DAU): 100Β Million100\text{ Million} active users.
  • Active Connected Devices: Average 2.5Β devices/DAUβ€…β€ŠβŸΉβ€…β€Š250Β MillionΒ ConcurrentΒ [WebSocket](/components/18-websocket-sse-and-long-polling)Β Connections2.5\text{ devices/DAU} \implies \mathbf{250\text{ Million Concurrent [WebSocket](/components/18-websocket-sse-and-long-polling) Connections}}.
  • Daily File Modifications / Sync Commits: Average 10Β syncΒ events/user/dayβ€…β€ŠβŸΉβ€…β€Š1Β BillionΒ syncΒ commits/day10\text{ sync events/user/day} \implies 1\text{ Billion sync commits/day}. AverageΒ SyncΒ CommitΒ QPS=109Β commits86,400Β sβ‰ˆ11,574Β QPSΒ (Peak:Β 35,000Β QPS)\text{Average Sync Commit QPS} = \frac{10^9 \text{ commits}}{86,400 \text{ s}} \approx 11,574 \text{ QPS (Peak: } 35,000\text{ QPS)}

Storage & Delta Bandwidth Math

  • Average File Size: 5Β MB5\text{ MB}. Total user storage quota average =15Β GB= 15\text{ GB}. TotalΒ RawΒ UserΒ DataΒ Stored=500Γ—106Γ—15Β GB=7,500Β PB=7.5Β Exabytes\text{Total Raw User Data Stored} = 500 \times 10^6 \times 15\text{ GB} = 7,500\text{ PB} = \mathbf{7.5\text{ Exabytes}}
  • Deduplication Ratio: Content-defined chunking yields an estimated 3.5Γ—3.5\times storage reduction via cross-user block deduplication. ActualΒ S3Β PhysicalΒ Storageβ‰ˆ7.5Β EB3.5β‰ˆ2.14Β Exabytes\text{Actual S3 Physical Storage} \approx \frac{7.5\text{ EB}}{3.5} \approx \mathbf{2.14\text{ Exabytes}}
  • Delta Sync Network Bandwidth Savings:
    • Without Delta Sync (Full file upload): 109Β editsΓ—5Β MB=5Β PB/dayβ‰ˆ463Β GbpsΒ Bandwidth10^9 \text{ edits} \times 5\text{ MB} = 5\text{ PB/day} \approx \mathbf{463\text{ Gbps Bandwidth}}.
    • With Block-Level Delta Sync: Only 1 modified 4Β MB4\text{ MB} chunk uploaded per commit: 109Γ—4Β MB=4Β PB/day10^9 \times 4\text{ MB} = 4\text{ PB/day}.
    • For small edits (100Β KB100\text{ KB} diff inside a 100Β MB100\text{ MB} file), delta sync reduces network payload from 100Β MBβ†’4Β MB100\text{ MB} \to 4\text{ MB} (96%96\% reduction).

3. High-Level Architecture & AWS Component Mapping

Interactive Architecture Diagram
Synthesizing vector architecture diagram...

Component Responsibility Breakdown

ComponentAWS TechnologyOperational Role & Configuration
Sync Control PlaneAmazon ECS FargateValidates commit requests, performs chunk diff calculation against server manifests, issues presigned PUT URLs for missing blocks.
File Tree & Metadata StoreStores file hierarchy, POSIX permissions, version vectors, folder parent-child edges, and block hash list pointers.
Block Hash Registry Fast in-memory + hash set indexing all existing global SHA-256 chunk keys to eliminate redundant HEAD requests.
Content Addressable Storage (CAS)Stores immutable binary chunks addressed by s3://drive-blocks/<sha256_hash>. Zero overwrite; protected by Object Lock.
WebSocket Connection ManagerAPI Gateway WebSocket + Manages 250M persistent WebSocket connection tokens mapping user_id -> connection_id with 10-minute idle pings.
() Streams + Guarantees ordered, durable streaming of file revision events to fanout notification workers.

4. API Interface Design & Wire Protocols

1. Delta Sync Commit & Block Hash Negotiation

http
POST /v1/files/sync/commit HTTP/1.1
Host: api.drive.aws.internal
Authorization: Bearer <jwt_token>
Content-Type: application/json

{
  "file_id": "file_88129384bc",
  "base_version": 14,
  "file_name": "quarterly_financial_model.xlsx",
  "parent_folder_id": "folder_root_001",
  "file_size_bytes": 20971520,
  "chunk_hashes": [
    "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2",
    "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e",
    "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8",
    "4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a"
  ]
}

Response: 200 OK (Only Missing Chunks Require Upload)

json
{
  "file_id": "file_88129384bc",
  "new_version": 15,
  "sync_action": "UPLOAD_REQUIRED",
  "missing_chunks": [
    {
      "chunk_hash": "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e",
      "presigned_put_url": "https://s3.us-east-1.amazonaws.com/drive-cas-blocks/a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e?X-Amz-Signature=..."
    }
  ]
}

2. Finalize Commit Once Chunks Uploaded

http
POST /v1/files/sync/finalize HTTP/1.1
Host: api.drive.aws.internal
Authorization: Bearer <jwt_token>
Content-Type: application/json

{
  "file_id": "file_88129384bc",
  "new_version": 15,
  "uploaded_chunk_hashes": [
    "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e"
  ]
}

Response: 200 OK

json
{
  "file_id": "file_88129384bc",
  "status": "COMMITTED",
  "version": 15,
  "updated_at": 1718000500123
}

5. Data Models & Storage Architecture

Interactive Architecture Diagram
Synthesizing vector architecture diagram...

DynamoDB Single-Table Schema (GoogleDriveCoreTable)

() ()AttributesGSI1- / GSI1-
USER#<user_id>FILE#<file_id>name, parent_id, current_ver: 15, is_folder: false, updated_atFOLDER#<parent_id> / NAME#<name>
FILE#<file_id>VER#000015committed_at: 1718000500, size: 20971520, chunk_hashes: [...]β€”
BLOCK#<sha256>METADATAs3_key, size_bytes: 4194304, global_ref_count: 842, created_atβ€”
USER#<user_id>CONN#<conn_id>device_type: "MACOS", connected_at: 1718000000, ttl: 1718086400β€”

Part 2: Production Deep-Dive Locked1 Coin = 24 Hours

Unlock Complete Architecture & Production Runbooks

Your Balance:40 Coins

You have explored the free architectural preview (~42%). Spend 1 Coin to unlock the remaining 6 production deep-dive sections for a full 24 hours.

Sections Included in This 24-Hour Pass:
6. Core Algorithms & Deep-Dive Workflows
7. Architectural Trade-Off Matrix & Primitive Links
8. Critical Failure Modes, Resiliency & Edge Cases
9. Production Pitfalls & Anti-Patterns (The "Top 5 Gotchas")
10. Production Runbook & Observability Guide
11. System Design Interview Rubric & Deep-Dive Strategy
Keeps page unlocked for exactly 24 hoursSpend coins to fund LLM & compute infrastructure