Skip to content
System Design Explorer
Company architectureadvanced

Dropbox System Design

File sync on top of Magic Pocket, an exabyte-scale block store

By Ankur NayakReviewed

How Dropbox syncs files across hundreds of millions of devices: the desktop sync engine (rewritten in Rust as Nucleus) splits files into blocks of up to 4 MB, compresses them and uploads them to Magic Pocket, Dropbox's own storage system, which keys blocks by SHA-256 hash, indexes them in sharded MySQL and stores them in ~50 PB cells across zones.

Open in Studio· edit a copy
Users
Hundreds of millions of devices
Storage
Exabytes; hundreds of billions of files (2020)
Block size
Up to 4 MB
Cell size
~50 PB raw
Per storage host
1.4 PB
Annual durability
> 99.9999999999%
Dropbox system design architecture diagramComponents: Desktop Client (Nucleus (Rust)), Another Device, Sync API Servers, FileJournal, MP Frontends (Magic Pocket), Block Index (Sharded MySQL), Storage Cell, Remote Zone. Connections: Desktop Client to Sync API Servers (commit + blocks); Sync API Servers to FileJournal (new revision); Sync API Servers to MP Frontends (put / get blocks); MP Frontends to Block Index (hash → cell, bucket); MP Frontends to Storage Cell (blocks); Storage Cell to Remote Zone (within 1 s); Sync API Servers to Another Device (changes).Desktop ClientNucleus (Rust)Another DeviceClientSync API ServersAPI gatewayFileJournalSQL databaseMP FrontendsMagic PocketBlock IndexSharded MySQLStorage CellObject storageRemote ZoneObject storage

Requirements

Functional

  • Keep a folder in sync across all of a user's devices
  • Upload and download changed files efficiently
  • Handle moves, renames and shared folders correctly
  • Keep a history of file revisions

Non-functional

  • Never lose a file: durability over twelve nines
  • Store exabytes cost-effectively on Dropbox's own hardware
  • Sync quickly, sending as little data as possible
  • A client that is correct under every ordering of events

In depth

Two halves: the sync engine and the storage

Dropbox's job sounds simple: keep a folder identical across every device a person owns, and never lose a file. Behind it are two large systems Dropbox has written about publicly. Magic Pocket is the in-house storage system that holds file contents, described in 2016 and extended with new hardware in 2018. Nucleus is the desktop sync engine, rewritten from scratch and shipped in 2020. In 2020 Dropbox described its scale as hundreds of billions of files, trillions of file revisions and exabytes of customer data across hundreds of millions of devices.

Files as blocks

Magic Pocket stores file contents as blocks of up to 4 MB. Blocks are compressed and encrypted, and once written they never change. Each block is named by the SHA-256 hash of its content. Separately, a system called FileJournal records every alteration to files: which blocks make up each revision.

This split is the heart of the design. File metadata (names, folders, revisions) is small and changes constantly; file contents are large and immutable. Storing contents as content-addressed blocks means a block's name proves its integrity, and caching and replication never have to deal with updates.

Uploading less: Broccoli

Syncing faster often means sending less. Dropbox's 2020 Broccoli post describes compressing blocks on the client with a modified Brotli encoder before uploading. Blocks are still identified by the hash of their uncompressed content, because client machines rarely have error-correcting memory and corruption during compression must be detectable. The result was about 30% less data on the wire and median latencies down by more than 30%.

Magic Pocket

Inside Magic Pocket, per the 2016 post:

  • Frontends accept storage requests from outside the system: the gateway to Magic Pocket.
  • The Block Index is a giant sharded MySQL cluster, fronted by an RPC service, mapping each block's hash to the cell and bucket that hold it, plus a checksum. See database sharding.
  • Cells are self-contained storage clusters of about 50 PB of raw data. Blocks are aggregated into 1 GB buckets; a bucket is replicated onto a volume, a set of storage machines.
  • Each cell has a Replication Table mapping buckets to volumes and machines, a single Master that coordinates background work but stays off the data path, and Volume Managers, the heavy lifters that move and repair data.
  • Storage machines, OSDs, are boxes full of disks. By 2018 a chassis held about 100 drives; with 14 TB SMR drives, that was 1.4 PB per host, and Dropbox reported being the first major tech company to adopt SMR drives.

Data is also erasure-coded for efficiency; see erasure coding.

Zones

Magic Pocket runs in western, central and eastern US zones. Every block is stored independently in at least two zones and written to a remote zone within one second of being uploaded locally. That gives protection against losing a whole data centre, not just disks. In 2018 Dropbox reported annual durability of over 99.9999999999% and availability over 99.99%.

When a storage machine fails, repair begins once an OSD has been offline for 15 minutes, rebuilding its data onto healthy machines from the surviving copies.

Nucleus: rewriting the sync engine

The client side has its own hard problems. Dropbox's original engine, "Sync Engine Classic", had a data model designed for a simpler world without sharing. Files lacked stable identifiers that survived moves, and a move was represented as a delete at the old location plus an add at the new one. Those choices caused bugs that only showed up at scale and made incremental fixes impossible.

Over four years Dropbox wrote Nucleus, in Rust. Shared folders and files now have globally unique identifiers. The sync protocol guarantees the server and client have the same view of the remote filesystem before considering a change. And almost all of Nucleus runs on a single "control" thread that is entirely deterministic given its inputs, which makes it testable: Dropbox fuzzes it with pseudorandom simulations, running millions of scenarios every day, and any failure can be reproduced from its random seed.

The upload and download paths

Putting it together: when you save a file, Nucleus notices the change, splits the file into blocks, compresses them and uploads any blocks needed. Magic Pocket writes them into a cell, records them in the Block Index and replicates them to another zone within a second. FileJournal records the new revision. Your other devices learn about the new revision and download the blocks they need. Dropbox's posts don't describe the API servers in between, so the diagram marks that tier as inferred.

The trade-offs

Dropbox chose to build storage itself, gaining control over hardware, cost and durability at the price of an enormous engineering and operations investment. Content-addressed, immutable blocks make replication, caching and integrity simple, at the cost of garbage-collecting blocks nothing references anymore. Self-contained cells limit the blast radius of failures but need a global index to find blocks. And rewriting the sync engine took four years and a careful migration, in exchange for a data model and test setup that make correctness tractable.

Compare with Amazon S3, another erasure-coded object store, and GitHub, which replicates repositories instead of blocks.

What to take into an interview

  • Separate file metadata (journal of revisions) from file contents (immutable blocks)
  • Name blocks by their hash; upload compressed blocks, verify against the uncompressed hash
  • Index blocks globally; store them in self-contained cells
  • Replicate across zones quickly, and wait a little before repairing failed machines
  • Give files stable identifiers so moves and sharing are first-class
  • Make the sync client deterministic so randomized testing can find rare bugs

Components

Desktop Client

Nucleus (Rust)

Client. The sync engine, rewritten in Rust as Nucleus and shipped in 2020. Almost all of its logic runs on one deterministic 'control' thread, which makes it testable with millions of randomized scenarios a day.

Another Device

Client. The same user's laptop or phone, which must receive the change.

Sync API Servers

inferred

API gateway. Receive metadata changes and block uploads from clients. Dropbox's posts don't describe this tier in detail.

FileJournal

SQL database. Records every alteration to files: the metadata that says which blocks make up each revision of each file.

MP Frontends

Magic Pocket

API gateway. The gateway into Magic Pocket: accept storage requests from outside the system and look up or record where blocks live.

Block Index

Sharded MySQL

SQL database. A giant sharded MySQL cluster, fronted by an RPC service layer, mapping each block's hash to its cell, bucket and checksum.

Building block: Database Sharding

Storage Cell

Object storage. A self-contained storage cluster of about 50 PB raw. Blocks are aggregated into 1 GB buckets, which are replicated or erasure-coded onto storage machines.

Why: Self-contained cells limit the blast radius of failures and let capacity grow cell by cell.

Building block: Object Storage, Erasure Coding

Master

Coordination. One per cell: coordinates background operations such as repair and garbage collection, off the data path.

Replication Table

SQL database. Maps each logical bucket to the volume and storage machines (OSDs) that hold it.

Volume Managers

Worker. The heavy lifters: move, repair and erasure-code volumes by reading and writing large amounts of data.

OSDs

Object storage. Object Storage Devices: storage machines full of disks. In 2018 a chassis held about 100 drives, 1.4 PB with 14 TB SMR disks.

Remote Zone

Object storage. Magic Pocket runs in western, central and eastern US zones. Each block is stored in at least two zones and written to a remote zone within one second of upload.

Building block: Replication

Request flows

Save a changed file

  1. Nucleus notices the change, splits the file into blocks of up to 4 MB and compresses them with Broccoli, a modified Brotli.
  2. Blocks are uploaded; each is identified by the SHA-256 hash of its uncompressed content.
  3. Magic Pocket writes each block into a 1 GB bucket in a cell.
  4. The Block Index records which cell and bucket hold the hash.
  5. Within a second, the block is also written to a remote zone.
  6. FileJournal records the new revision as a list of block hashes.
  7. The client marks the file as synced.

The change appears on another device

  1. The user's other device learns there is a new revision.
  2. It requests the blocks it doesn't already have.
  3. Magic Pocket looks up each block's cell and bucket.
  4. Blocks are downloaded and the file is reassembled locally.

Failure scenarios

What if: a storage machine dies?

Data is redundant within the cell and across zones, so reads are served from other copies. If the machine stays offline for 15 minutes, repair rebuilds its data onto healthy machines.

User impact: None.

  • Redundancy within and across zones
  • Automatic repair after 15 minutes

What if: a whole zone is lost?

Every block is stored independently in at least two zones, so a block lost with one zone can still be read from another.

User impact: Possibly slower access while traffic shifts.

  • Multi-zone storage
  • Cross-zone replication within one second

What if: the sync engine mishandles a move?

Sync Engine Classic represented a move as a delete plus an add and lacked stable file identifiers, causing bugs that only showed at scale. Nucleus gives shared files and folders global identifiers and runs deterministic randomized tests to find such bugs before release.

User impact: With the old engine: rare duplicated or misplaced files.

  • Stable identifiers across moves
  • Deterministic single-threaded core
  • Millions of simulated scenarios daily

Trade-offs

Build storage in-house

Store file contents in Magic Pocket, Dropbox's own exabyte-scale block store.

Pros
  • Control over cost, hardware and durability
  • Custom hardware such as high-density SMR servers
Cons
  • A huge engineering and operations investment

Immutable, content-addressed blocks

Store file data as immutable blocks named by their SHA-256 hash.

Pros
  • Blocks never change, so caching and replication are simple
  • Integrity is checkable from the name
Cons
  • Deleting data means garbage-collecting unreferenced blocks

Self-contained cells

Split storage into ~50 PB cells, each with its own Master off the data path.

Pros
  • Failures and bugs stay inside a cell
  • Grow capacity cell by cell
Cons
  • A global Block Index is needed to find which cell holds each block

Rewrite the sync engine

Replace Sync Engine Classic with Nucleus, a Rust engine with a deterministic core.

Pros
  • A data model with stable identifiers
  • Bugs reproducible from a random seed
Cons
  • Four years of work, and a risky migration for hundreds of millions of devices

Frequently asked questions

What is Dropbox Magic Pocket?

Magic Pocket is Dropbox's in-house storage system for file contents. It stores immutable blocks of up to 4 MB keyed by SHA-256 hash, indexes them in a sharded MySQL Block Index, groups them into 1 GB buckets in ~50 PB cells, and keeps every block in at least two US zones.

How does Dropbox sync files?

The desktop sync engine splits files into blocks of up to 4 MB, compresses them and uploads them to Magic Pocket. A metadata system called FileJournal records each file revision. Other devices learn about the change and download the blocks they need.

Why did Dropbox rewrite its sync engine in Rust?

The original engine's data model had problems that only appeared at scale, such as representing moves as a delete plus an add without stable identifiers. Nucleus, shipped in 2020, has a new data model and runs almost all logic on one deterministic thread, so it can be tested with millions of randomized scenarios a day.

How durable is Dropbox storage?

Dropbox reported annual durability of over 99.9999999999% and availability over 99.99% in 2018. Blocks are stored in at least two geographic zones, and data within a cell is replicated or erasure-coded and repaired automatically when a storage machine fails.

Building blocks used

Sources