System DesignSep 27, 2026⏱️ 3 min read
Design Google Drive: Block Chunking, Delta Sync, Deduplication & Conflict Resolution

Design Google Drive: Block Chunking, Delta Sync, Deduplication & Conflict Resolution

Why Naive Full-File Uploads Fail Cloud Sync

If a user edits two slides inside a 500 MB presentation, uploading the entire 500 MB file on every save wastes massive bandwidth, drains laptop batteries, and floods storage servers.
Cloud sync engines like Google Drive and Dropbox treat files as ordered collections of immutable content-addressed blocks.
Google Drive Cloud Sync Architecture

Google Drive Cloud Sync Architecture


1. Client-Side Block Chunking, Compression & Delta Sync

Before touching the network, the desktop client splits files cleanly:
  1. Chunking (4 MB Blocks): Split the file into ~4 MB chunks (or use Rabin fingerprinting / content-defined chunking so insertions at the start of a file don't invalidate all later chunks).
  2. Cryptographic Fingerprinting: Compute a SHA-256 hash per block.
  3. Compression: Compress blocks with Zstd or Gzip before transit (text/docs shrink 60%+; skip already-compressed .jpg/.mp4).
  4. Delta Sync: Client sends block hashes to the API server; only chunks whose hashes don't already exist in S3 are uploaded!

Global Deduplication Savings

If two users upload the exact same PDF manual or OS ISO, their SHA-256 block hashes collide intentionally—the Metadata DB points both files to the same encrypted S3 blocks (zero duplicate storage cost).

2. Two Separate Control Planes: Block Servers vs. Metadata DB

Desktop Client ──(HTTPS Chunks)──► Block Servers ──► S3 Object Storage (Multi-Region)
       │
       └──(ACID Commits + Sync)──► Metadata API ──► Relational Metadata DB + Cache
                                        │
                                        └──► Notification Service (Long Polling)

Why Metadata Requires Strong ACID Consistency

Unlike video blobs, file directory trees (workspace -> folder -> file_version -> [block_hash_1, block_hash_2]) cannot tolerate stale phantom reads when multiple devices edit concurrently. Use a sharded ACID relational database (MySQL/PostgreSQL) storing:
  • workspaces, files, file_versions (ordered list of block IDs), and devices.

3. Handling Concurrent Edits & Conflicts

Suppose Alice and Bob edit notes.txt offline on an airplane and both reconnect:
  • Device A commits version = 5 (succeeds via optimistic version check WHERE latest_version = 4).
  • Device B attempts to commit version = 5 based on version = 4 → Optimistic Lock Failure.
  • Instead of silently overwriting Alice's work, Device B preserves both versions: saving Bob's copy as notes (Conflict Copy - Bob).txt or prompting a manual merge.

4. Real-Time Sync Without Polling Storms

Use HTTP Long Polling (rather than always-open WebSockets across 100M mostly-idle sync clients) for the Notification Service: clients hold an open poll that returns immediately when another device commits a new version, then sync down only the changed block hashes.

Share this article

Comments