Patterns

Index the blobs: Dropbox

Dropbox put a sharded MySQL Block Index in front of Magic Pocket's immutable blocks, so a read was one hash lookup and one block fetch.

In 2016 Dropbox moved its file data off S3 into Magic Pocket, its own multi-exabyte store. A file is cut into blocks of up to 4 MB, each block is hashed with SHA-256, and the hash goes into a sharded MySQL Block Index. A read looks up the hash and fetches the block.

The system#

Blocks are packed into 1 GB buckets and written to volumes across machines, in replicated or erasure-coded form, in three US zones. The Block Index is a sharded MySQL cluster behind an RPC layer, and it decides which volumes hold a block. The Watcher samples 1% of written blocks and fetches them after a minute, an hour, a day, a week, and a month. The metadata scanner walks the index at about a million blocks a second.

The board#

Drag to pan. Hold Ctrl or Cmd and scroll to zoom.

At 3.00k Users the Simulation solves this Design to Apdex 1.00, p99 476 ms, 0.0% errors and $25/s Burn, of which $0.03/s is egress. The board is the block-and-index split at game scale. Magic Pocket’s erasure coding and three zones are not on it. The caption is Quorum's result, not the company's numbers.
WhereSettingValueWhy
App ServerInstance sizelargeLarge, because the app hashes each block and looks up the index.
App ServerCopies3Three copies stand for the API tier.
Object StorageStorage classstandardThe block store keeps the immutable blocks.
Object StorageLifecycle (days)30Older blocks move to a cheaper class after a month.
DatabaseShards4The Block Index is a sharded MySQL cluster. Four is the board’s widest, and it stands for the fleet.
DatabaseShard keyhashA block is keyed by its SHA-256 hash, which spreads blocks evenly.
DatabaseEnginemysqlMySQL, the engine of the Block Index.
DatabaseInstance sizemediumMedium for each index shard, so a busy shard shows.

Research this Design needs: Object storage, Object storage, Sharding, Caching.

The Object Storage is the block store: immutable blocks, keyed by their hash. The Database is the Block Index, four shards on a hash key. The App Server hashes the block, writes it to storage, and writes its hash and location to the index.

Why it works#

The blocks are immutable, so the index only appends and never updates a row. The index is tiny next to the bytes, so a sharded MySQL cluster can hold it while the blocks live on cheap disks. A read is one hash lookup and one fetch. Object storage and lifecycle rules and shard the database are the two halves.

Where the game stops#

The game's Object Storage is a managed service, not Magic Pocket's own hardware. The board cannot show 4 MB blocks, 1 GB buckets, erasure coding, or the three zones. It shows the split: a hash index in front of an immutable block store. The caption is Quorum's result, not Dropbox's exabytes.

Sources#