Skip to main content
← PROBLEMS / SYSTEM-DESIGN
An end-to-end domain learning journey

Design a Cloud File Storage &
Cross-Device Sync System (Dropbox Scale).

Design a Dropbox-scale cloud storage and cross-device sync system supporting multi-gigabyte delta uploads, hierarchical folder metadata, and instant multi-device change notifications.
Start the journey7 stages· Last modified Nov 24, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

To bound blast radius during partial cluster failures, split the Control/Metadata plane (sharded MySQL + cursor-based delta sync) from the Data/Block plane (CDC chunks in S3), connected by a Long-Poll/WebSocket Notification Service.

TL;DR30-second simplified summary
▾

Clients debounce local file events, upload missing CDC blocks to S3, and commit manifests to namespace-sharded MySQL. Thin Redis Pub/Sub wakeups trigger /delta?cursor= pulls, while adjacency-list parent pointers make folder moves O(1).

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
Content-Defined Chunking (CDC) & Cross-Device Delta Sync
Content-Defined Chunking uses a rolling hash (Rabin fingerprint) to slice files at content-dependent boundaries so byte insertions only invalidate the modified chunk instead of shifting every downstream block.
Full walkthrough · 7 stages
01
foundation

Decoupling the Block Plane from the Metadata Plane.

Why this matters: Separate heavy binary chunk transfers from low-latency transactional folder tree updates.

Routing 100 MB file uploads through the same servers that serve folder listings exhausts database connections and API worker memory.

Splitting into a stateless Block Service (backed by S3) and a Metadata Service (backed by sharded MySQL) allows independent scaling of bandwidth vs.

FOUNDATION

Block vs. Metadata Plane Split

Sync ClientclientBlock Service -> S3storageMetadata -> MySQLstorageStorecommits ordered hash manifest

1.Durability Order: Always persist chunks to S3 BEFORE committing the metadata manifest.

2.Independent Scale: S3 handles exabytes of blobs while MySQL stores kilobyte manifests.

Separating binary chunk storage from relational metadata lets each tier scale independently.

02
foundation

Client File Watcher, Debouncing & Local SQLite Index.

Why this matters: Coalesce rapid editor autosaves and ignore temporary lockfiles before triggering network sync.

Think of Client File Watcher, Debouncing & Local SQLite Index as the intuition layer for Design a Cloud File Storage & Cross-Device Sync System (Dropbox Scale): Coalesce rapid editor autosaves and ignore temporary lockfiles before triggering network sync.

IDEs and Office apps write temporary .tmp files and emit dozens of inotify/FSEvents callbacks per second. The Desktop Sync Client buffers events in a 500ms debounce window, compares mtime + size + hash against its local SQLite state, and only runs CDC when a file stabilizes.

FOUNDATION

Debounced Client Sync Engine

OS File Watcheringress500ms DebouncercomputeLocal SQLitestorageStorechecks against local state

1.Debounce Window: Waiting 500ms avoids uploading half-written files during saves.

2.Local Truth: SQLite remembers the last synced `rev` for offline diffing.

Client-side debouncing and local SQLite state prevent wasted uploads on noisy editor saves.

Engineering Decision Framework
Problem
How to implement Design a Cloud File Storage & Cross-Device Sync System (Dropbox Scale) without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
To bound blast radius during partial cluster failures, split the Control/Metadata plane (sharded MySQL + cursor-based delta sync) from the Data/Block plane (CDC chunks in S3), connected by a Long-Poll/WebSocket Notification Service.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Design a Cloud File Storage & Cross-Device Sync System (Dropbox Scale) experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
intermediate

Sharding Metadata by Namespace & Journaled Sync Cursors.

Why this matters: Support shared folders and O(delta) reconnect catch-up using namespace-sharded journal logs.

Sharding metadata by user_id breaks when two users share a folder—a rename by Alice must appear in Bob's sync stream.

Instead, each root or shared folder is a namespace_id (sharded by namespace_id).

INTERMEDIATE

Namespace Journal & Cursor Sync

Namespace ShardstorageJournal Log (seq_id)storage/delta?cursor=seq_…outputStorestreams changes after cursor

1.Shared Folders: Sharding by `namespace_id` keeps shared folder state on one shard.

2.Offline Catch-Up: Reconnecting devices fetch only changes since their saved `cursor`.

Namespace-sharded journals give every device an exact, resumable `cursor` for delta sync.

04
intermediate

Low-Overhead Change Notifications (Long-Poll / WebSockets).

Why this matters: Wake idle devices within 1 second of a remote edit without constant battery-draining polling.

With 100M connected devices, polling /delta every 5 seconds generates 20M QPS of empty responses.

Instead, clients hold a lightweight Long-Poll or WebSocket connection to a Notification Service.

INTERMEDIATE

Long-Poll Wakeup Pipeline

Metadata ServicecomputeRedis Pub/SubbrokerNotification EdgeoutputStoresignals sibling devices to pull /delta

1.Thin Signal: Notifications only carry `{has_changes: true}`, keeping fan-out tiny.

2.Thundering Herd: Jittered reconnect backoff protects edges after regional restarts.

Thin wakeup signals via Long-Poll/WebSockets eliminate wasteful idle polling.

05
intermediate

Atomic Folder Renames & Cycle-Free Tree Invariants.

Why this matters: Move a folder containing 100,000 files in O(1) without rewriting child rows or creating directory cycles.

Think of Atomic Folder Renames & Cycle-Free Tree Invariants as the intuition layer for Design a Cloud File Storage & Cross-Device Sync System (Dropbox Scale): Move a folder containing 100,000 files in O(1) without rewriting child rows or creating directory cycles.

Storing full paths (/Work/2026/Report.pdf) forces O(N) updates when /Work is renamed to /Archive. Storing (file_id, parent_id, name) in an adjacency list makes folder renames an O(1) single-row UPDATE, while checking ancestor chains in the transaction prevents cyclic moves (A moved inside A/B).

INTERMEDIATE

O(1) Adjacency-List Rename

Move Folder A -> BingressCycle CheckgateO(1) Row UpdatestorageStoreupdates single parent_id

1.O(1) Rename: Moving a 100,000-file directory updates exactly 1 metadata row.

2.Cycle Guard: Ancestor walk inside the transaction prevents orphaned loops.

Adjacency-list parent pointers make massive folder moves O(1) while guarding against cycles.

06
advanced

LAN Sync, Edge Caching & Bandwidth Throttling.

Why this matters: Accelerate office team syncs via peer-to-peer LAN chunk discovery and pre-signed CDN downloads.

Think of LAN Sync, Edge Caching & Bandwidth Throttling as the intuition layer for Design a Cloud File Storage & Cross-Device Sync System (Dropbox Scale): Accelerate office team syncs via peer-to-peer LAN chunk discovery and pre-signed CDN downloads.

When 50 engineers in the same office pull a new 2 GB design asset, downloading 100 GB from S3 wastes WAN bandwidth. Clients broadcast local UDP/mDNS announcements of available chunk_hash blocks on the subnet, fetching verified SHA-256 chunks directly over LAN TLS while falling back to CloudFront/S3 pre-signed URLs.

ADVANCED

LAN Peer-to-Peer Chunk Fetch

Need Chunk h2clientLAN Peer FetchcomputeCloudFront / S3storageStorefalls back on miss/timeout

1.Zero-Trust Verify: Every LAN-fetched block is verified against its expected SHA-256 hash.

2.Office Savings: Reduces corporate WAN egress by up to 80% for shared folders.

SHA-256 verification makes peer-to-peer LAN chunk sharing both fast and tamper-proof.

07
advanced

Point-in-Time Ransomware Rollback & Cold Tiering.

Why this matters: Restore an entire folder tree to a prior timestamp using immutable revision journals.

Think of Point-in-Time Ransomware Rollback & Cold Tiering as the intuition layer for Design a Cloud File Storage & Cross-Device Sync System (Dropbox Scale): Restore an entire folder tree to a prior timestamp using immutable revision journals.

If ransomware encrypts 10,000 synced files, clients upload encrypted chunks as new revisions (rev + 1) while the old CDC chunks remain untouched in S3 during the 30-day retention window. Rolling back simply replays the namespace_journal in reverse to point head_rev back to pre-attack manifests in seconds.

ADVANCED

Instant Snapshot Rollback

Ransomware EventriskImmutable RevisionsstorageMetadata RewindoutputStorerewinds head_rev pointers

1.Zero Copy Restore: Rewinding metadata restores gigabytes without copying S3 objects.

2.Cold Tiering: Chunks older than 90 days transition to S3 Glacier Instant Retrieval.

Immutable chunk manifests turn ransomware recovery into an instant metadata pointer rewind.

Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

Why should cloud file sync metadata be sharded by `namespace_id` (root/shared folder) instead of `user_id`?

Recommended Learning Flow