Dropbox keeps a folder identical on your laptop, your phone and the cloud. You save a 2 GB video on one device and a few seconds later it appears on the others. Under the hood this is two different systems glued together: a small, strongly consistent metadata service that knows what files exist and which version is current, and a huge block store that holds the actual bytes. The interesting questions are how to avoid re-uploading a whole file when one paragraph changes, how to resume a broken upload, how to tell other devices "something changed" within seconds, and how to store hundreds of petabytes without losing a single byte. This lesson walks the full eight-step interview framework.
Detailed Notes
How to use this lesson
Treat this as a 45-minute interview. The numbers are assumptions you state out loud, not facts about any real company. What the interviewer checks is that your estimates drive your design: petabytes of bytes but only terabytes of metadata is the insight that shapes the whole architecture.
Three terms we use throughout. A chunk (also called a block) is a fixed-size piece of a file, 4 MB in our design. A content hash is a fingerprint (for example SHA-256) computed from bytes: identical bytes always give the same hash, and different bytes almost never do. A namespace is a folder tree with its own list of members, for example "Asha's personal folder" or "the Marketing shared folder". We introduce namespaces because sharing and sync both work per namespace.
Step 1: Clarify Requirements
Open with: "Before designing, I'd like to confirm what we sync, how large files can be, and what I can leave out."
Functional requirements
A user can upload and download files of any type, up to 50 GB each.
A desktop or mobile client watches a local folder and automatically syncs changes to the cloud and to all the user's other devices.
A user can share a file or folder with other users (viewer or editor) or through a link.
The system keeps version history and a trash so mistakes can be undone.
When two devices edit the same file at once, no edit is silently lost.
Extended requirements
Mention and ask; do not design unless invited.
Full-text search inside documents and previews/thumbnails.
Real-time co-editing of one document (that is a different system, built with OT or CRDTs).
Selective sync (keep only some folders on a laptop) and offline access.
Team admin features: audit logs, legal hold, remote wipe.
Non-functional requirements
Durability: 99.999999999% (eleven nines). A stored file must essentially never be lost. This is the single most important requirement. It means the chance of losing a given object in a year is about one in a hundred billion.
Availability: 99.99% for metadata and downloads, about 52 minutes of downtime per year.
Sync latency: a change on one device reaches other online devices in under 10 seconds at p99 for small files.
Efficiency: editing a 1 GB file must not upload 1 GB again. Bandwidth is the user's cost and ours.
Consistency: metadata must be strongly consistent (everyone agrees which version is current, no two files with the same name in a folder). Data blocks are immutable, so consistency is trivial for them.
Reliability of transfer: uploads of multi-gigabyte files over bad Wi-Fi must resume, not restart.
Consistency decision. Say early: "File contents never change after they are written (we only add new chunks), so they need no consistency protocol. File metadata (names, folders, current version, permissions) changes constantly and must be strongly consistent." This sentence is the seed of the metadata/block separation in Step 6.
Out of scope
Co-editing, full-text search, media transcoding, billing, enterprise admin tools and end-to-end client-side encryption. We will mention encryption at rest and in transit only.
Interview tip. A common mistake is to design "an upload endpoint that saves a file to S3" and stop. That is a file upload service, not a sync service. The interviewer is waiting to hear about chunking, change detection and notifications.
Step 2: Estimate Scale
Round every number so the arithmetic is easy to do aloud.
Assumptions to state
100 million registered users, of which 20 million are daily active users (DAU).
Each registered user stores about 200 files with an average size of 10 MB, so about 2 GB per user. (Most users store little; a few store a lot. The average hides that.)
Each DAU triggers about 10 file changes per day (create, edit, rename, move, delete). About 20% of changes modify content; the rest only change metadata.
A content change uploads on average 2 MB after we apply chunking, deduplication and delta sync (a changed file is 10 MB, but only a few chunks differ).
Each changed file must reach on average 2 other devices.
A day has about 100,000 seconds.
Files and storage
text
Files = 100M users x 200 files = 20 billion files
Storage = 100M users x 2 GB = 200 PB (1 PB = 1,000,000 GB)
Check = 20B files x 10 MB = 200 PB (consistent)
Dedup = about 30% of chunks are duplicates -> about 140 PB unique
Raw = 140 PB x 1.4 (erasure coding) = about 200 PB on disk
So what: 200 PB cannot live in a database or on a file server. It needs a distributed blob (object) store with cheap disks, and every byte saved by deduplication or smart redundancy is real money. Storage cost is the biggest line on the bill, which is why Step 6 spends so long on dedup and erasure coding.
Sync events per second
text
Changes per day = 20M DAU x 10 = 200M changes/day
Events per sec = 200M / 100,000 = 2,000 per second
Peak (x3) = 6,000 per second
Content uploads = 200M x 20% = 40M/day / 100K = 400 per second (1,200 at peak)
So what: 6,000 metadata writes per second is modest. A sharded database handles it easily. The hard part is not throughput, it is correctness (versions, conflicts) and fan-out (telling the right devices).
Dropbox: Estimate the ScaleEstimation
Request load
100Mregistered users
given
20Mdaily active users
20% of users
200Mchanges per day
× 10 per DAU
2K/ssync events
÷ 100,000 s
6K/speak events
× 3 peak factor
Storage
200 PB
20B files × 10 MB; about 140 PB after dedup
Object store with erasure coding, not a database
Metadata
~23 TB
18 TB versions + 5 TB chunk index
Separate metadata service, sharded by namespace
Bandwidth
0.8 GB/s up
40M uploads/day × 2 MB; 1.6 GB/s down
Delta sync saves 5x; clients hit the block service directly
Key point. Petabytes of data but only terabytes of metadata: split the two, and make bandwidth efficient with delta sync.
Everything derives from 100 million users who each store about 2 GB and make about 10 changes a day when active.
Bandwidth
text
Upload = 40M uploads x 2 MB = 80 TB/day
= 80 TB / 100,000 s = 0.8 GB/s average, about 2.4 GB/s at peak (~19 Gbps)
Download = 0.8 GB/s x 2 devices = 1.6 GB/s average, about 5 GB/s at peak
Without delta sync: 40M x 10 MB = 400 TB/day = 4 GB/s upload (5x worse)
So what: this is the first system in the course where bandwidth is a real constraint. Multi-gigabit traffic needs many block servers, and delta sync cuts upload by 5x. Clients should talk to the block service directly, so bytes never pass through the metadata service.
Metadata size
text
File versions = 20B files x 3 versions = 60B rows x 300 bytes = 18 TB
Chunk index = 50B chunks x 100 bytes = 5 TB
Chunks = 200 PB / 4 MB = 50 billion
Total metadata = about 23 TB (round to 20-25 TB)
So what: 200 PB of data but only about 23 TB of metadata, a ratio of roughly 10,000 to 1. That gap is the reason to separate the metadata service (small, transactional, expensive storage) from the block store (huge, simple, cheap storage). 23 TB still needs sharding.
Notification connections
text
Devices online at peak = 20M DAU x 2 devices x 50% = 20 million open connections
One notification server holds about 50,000 idle connections
Servers = 20M / 50,000 = 400 servers
So what: keeping 20 million connections open is its own service, and idle connections are cheap because they only wake on a change.
Interview tip. State the 10,000 : 1 data-to-metadata ratio explicitly. It is the number that justifies the architecture.
Step 3: Define the APIs
Because file bytes and file metadata are handled by different services, the API has both. All calls use HTTPS and a bearer token.
The client sends only hashes. The server answers with the chunks it does not already have. If the file is a duplicate, missing_chunks is empty and nothing is uploaded at all.
Upload one chunk (block service)
http
PUT /v1/blocks/e03b...77?upload_id=up_55f3
Content-Length: 4194304
(raw bytes)
200 OK once the server has recomputed the hash and it matches. Repeating the call is harmless (idempotent), because the key is the content hash.
Commit the new version (metadata service)
http
POST /v1/files/uploads/up_55f3/commit
201 Created with { "file_id": "f_12", "version": 8 }.
409 Conflict if base_version is no longer the current version (someone else changed the file first). The client then creates a conflicted copy (Step 6).
422 Unprocessable if a referenced chunk is still missing.
507 Insufficient Storage if the user is over quota.
Download
http
GET /v1/files/f_12/content -> 200 with the chunk list and short-lived signed block URLs
GET /v1/blocks/9f2a...c1 -> raw chunk bytes (supports Range)
Sync (change feed)
http
GET /v1/namespaces/ns_981/changes?cursor=4821907&limit=500
{
"changes": [
{ "cursor": 4821908, "op": "update", "file_id": "f_12", "path": "/Projects/report.docx", "version": 8 },
{ "cursor": 4821909, "op": "delete", "file_id": "f_77" }
],
"next_cursor": 4821909,
"has_more": false
}
GET /v1/notifications/poll?cursors=ns_981:4821909,ns_44:900 # long poll, returns when anything changed
Sharing
http
POST /v1/shares { "folder_id": "fo_9", "user": "ben@example.com", "role": "editor" }
How the API shapes the architecture
Three observations. (1) The client does the heavy lifting: it chunks, hashes and decides what to upload, so servers stay simple and cheap. (2) Bytes and metadata take separate paths, so the block service scales on bandwidth and the metadata service scales on transactions. (3) The change feed is cursor based: the client says "give me everything after cursor N". That one idea makes sync reliable even when notifications are lost.
Step 4: Define the Data Model
Start from access patterns:
List a folder and look up a file by path (very frequent).
Commit a new version atomically (6,000 per second at peak).
Read changes after a cursor for one namespace (every sync).
Check which chunks already exist by hash (every upload).
Check permissions for a user and a namespace (every request).
Fields and why each exists
files: one row per file or folder. parent_id builds the tree. current_version points to the version users see. deleted_at marks the trash (soft delete). Partitioned by namespace_id so one folder tree lives together and a commit is a single-shard transaction.
file_versions: one row per version. chunk_hashes is the ordered list of chunk hashes that rebuild the file. base_version records which version the editor started from, which is how conflicts are detected.
chunks: one row per unique chunk. chunk_hash is the primary key. ref_count says how many versions use it, so we know when it is safe to delete. location says where the bytes live.
change_log: an append-only feed per namespace. cursor increases monotonically inside a namespace. Clients resume from their saved cursor.
shares: who may access which namespace and in what role.
upload_sessions: tracks an in-progress upload so it can resume.
Permissions are on namespaces and files, never on chunks.
file_versions.file_idfiles.file_id· many to one
file_versions.chunk_hasheschunks.chunk_hash· many to many
change_log.file_idfiles.file_id· many to one
shares.namespace_idfiles.namespace_id· one to many
Key point. Partition metadata by namespace_id so a version commit is one single-shard transaction.
Files and versions are mutable metadata. Chunks are immutable, content-addressed and shared.
Which database?
Metadata: a sharded relational database (for example MySQL or PostgreSQL shards, as large file-sync systems use). We need real transactions: committing a version must update file_versions, files.current_version, chunks.ref_count and change_log together, or not at all. Partition by namespace_id so that transaction stays on one shard. 23 TB over, say, 100 shards is under 250 GB each, comfortable.
Why not a key-value store for metadata? Folder listings, renames, moves and "unique name in a folder" are relational. Giving that up for scale we do not need (6,000 writes/s) is a bad trade.
Blocks: an object store keyed by hash. Chunks are immutable and read by key. No transactions, no joins, a perfect fit.
Cache (in-memory key-value) for hot metadata: folder listings and permission checks.
Trade-off thinking. Relational metadata gives transactions and simple folder logic but needs sharding by namespace. The cost is that a cross-namespace operation (moving a file between two users' folders) cannot be one local transaction, so we implement it as copy-then-delete with a retry. That is acceptable because it is rare.
Step 5: High-Level Design
The golden rule here is the separation of metadata and blocks.
Metadata Path and Block PathArchitecture
Key point. File bytes never pass through the metadata service. That is why each side scales on its own.
Small transactional metadata and huge immutable blocks are separate services with separate storage.
Components and why each exists
Client (desktop/mobile): watches the folder, splits files into chunks, hashes them, uploads missing chunks, applies remote changes.
API gateway / load balancer: authenticates, rate limits and routes. A load balancer spreads requests across identical servers.
Metadata service: stateless servers in front of the sharded metadata database. Owns names, folders, versions, chunk index, permissions and the change log. Everything that needs strong consistency happens here.
Block service: stateless servers that accept and serve chunk bytes. Verify the hash on write. Never need the metadata database for the data path.
Block storage: durable object storage holding chunks, replicated or erasure coded across zones.
Notification service: holds the open connections and pushes a tiny "something changed in namespace X" message.
Upload With Dedup and CommitRequest flow
ClientMetadataserviceBlock serviceBlock storage1begin(file, chunk hashes)base_version = 72missing: [B']A and C already stored3PUT chunk B'4verify hash, store5200 OK6commit(upload_id)one transaction7201 version 8change event emitted
Key point. Nothing is visible until commit, so readers never see a half-written file.
Only the chunks the server lacks are uploaded. The version appears atomically at commit.
Request flow
Upload.
The client detects a change, splits the file into 4 MB chunks and hashes each.
It sends the hash list to the metadata service, which replies with the chunks it lacks.
The client uploads only those chunks to the block service, in parallel.
The client commits. The metadata service, in one transaction, writes the version, moves current_version, increments reference counts and appends to the change log.
The metadata service emits a change event; the notification service nudges other devices.
Download / sync.
A device receives a nudge, or wakes up and asks for changes after its cursor.
It gets the list of changed files with their new chunk hashes.
It compares with chunks it already has locally and downloads only the new ones.
Step 6: Deep Dive
Interviewers pick the part you are least sure about. Be ready for all of these; spend most time on chunking and sync.
6.1 Chunking: why 4 MB?
Uploading a file as one request is fragile (one dropped connection restarts everything) and wasteful (change one byte, resend everything). Chunking means splitting a file into smaller pieces and handling each independently.
Too small (for example 4 KB): a 10 MB file has 2,500 chunks, which means 2,500 hash lookups, 2,500 metadata rows and per-request overhead that exceeds the data.
Too large (for example 1 GB): a small edit resends a huge block, and resume loses a lot of progress.
4 MB: about 2.5 chunks for an average 10 MB file, parallel uploads work well, a retry costs at most 4 MB, and the chunk index stays at 50 billion rows. Many systems land in the 4 MB range for this reason.
Fixed-size vs content-defined chunking. With fixed boundaries, inserting one byte at the start of a file shifts every later boundary, so every chunk changes. Content-defined chunking uses a rolling hash (a hash computed over a sliding window of bytes) to choose boundaries where the bytes themselves look special, so an insertion only changes the nearby chunks. It is better for text and log files but costs CPU on the client. A good answer: "Start with fixed 4 MB, which is simple and fine for most files, and add content-defined boundaries later if edit patterns justify it."
6.2 Content hashing and deduplication
Each chunk is named by its SHA-256 hash. The chunk table's primary key is that hash, so the same bytes are stored once, no matter how many files, versions or users refer to them. This is content-addressable storage, and the process of skipping already-stored bytes is deduplication (dedup).
Within one file's history: a new version shares unchanged chunks with the old one. That makes versioning almost free.
Across files and users: 100 people saving the same PDF store it once. We assumed about 30% savings overall.
Integrity bonus: the hash doubles as a checksum. If a stored chunk's hash does not match its name, it is corrupt and gets repaired.
Reference counting:ref_count counts how many versions use a chunk. When a version is permanently deleted, its chunks are decremented, and chunks at zero are garbage collected by a background job after a safety delay.
The security catch. Cross-user dedup lets an attacker learn whether someone else has a file: upload a hash, and if the server says "already have it", the file exists. Mitigations: require the client to prove it has the bytes (for example by hashing a server-chosen random sample), and do cross-user dedup only for the data the server can verify. Mentioning this shows depth.
6.3 Delta sync: upload only what changed
Delta sync means transmitting only the changed parts of a file.
Whole-File Upload vs Chunked Delta SyncComparison
Re-upload the file
10 MB sent per edit
1
Detect the file changed
timestamp or size differs
2
Upload the entire file
10 MB over the network
3
Server replaces the old file
history stores a full copy
10 MB for a one-paragraph edit
Restarts from zero on a dropped connection
Each version stores the whole file
Simple, but wastes bandwidth and storage
Chunked delta sync
only changed chunks sent
1
Split into 4 MB chunks and hash
A, B, C
2
Compare with last synced hashes
only B changed to B'
3
Ask server which chunks are missing
answer: B'
4
Upload B' and commit A, B', C
4 MB sent, old versions intact
Sends 4 MB instead of 10 MB (more for big files)
Resumes at chunk level
Versions share unchanged chunks
Client needs chunking and a local hash database
Standard for sync systems; the savings grow with file size
Key point. Chunk hashes turn 'what changed?' into a cheap local comparison.
Editing one paragraph in a 10 MB file: how many bytes cross the network?
Walkthrough. A 10 MB file has chunks A, B, C. The user edits text inside chunk B. The client re-hashes all three chunks locally (cheap, no network). A and C hashes match what the server has; B changed to B'. Only B' (4 MB) goes over the network instead of 10 MB. The new version lists A, B', C. The old version still lists A, B, C, so version history costs only the extra 4 MB.
The client keeps a small local database of each file's last synced chunk hashes, so it can tell what changed without asking the server. For extremely large files with tiny edits, block-level delta (rsync style) can send only changed bytes inside a chunk, but with 4 MB chunks the simpler chunk-level approach is usually enough.
6.4 Resumable uploads and failure during upload
A 20 GB upload takes a long time and will be interrupted. Our protocol is naturally resumable:
upload_sessions records the file, the chunk list and which chunks are confirmed. It lives for 7 days.
Chunk PUTs are idempotent: sending chunk E twice stores it once, because the key is its hash.
To resume, the client repeats the begin call with the same upload_id. The metadata service answers with the current missing_chunks. The client continues from there. Nothing needs to be sent from the beginning.
Nothing is visible until commit. Uploaded chunks sit unreferenced. If the user never commits, a cleanup job deletes unreferenced chunks older than a day. This guarantees a reader never sees a half-written file.
Per-chunk retry uses exponential backoff with jitter (the retry idea from the retries lesson).
6.5 Sync notifications and the change feed
How does device B learn that device A changed a file?
Polling every 5 seconds from 20 million devices means 4 million requests per second, nearly all returning "no news". Wasteful.
Long polling (the client asks, the server holds the request open until there is news or 60 seconds pass) is simple, works through every proxy and firewall, and only moves when something changed.
WebSocket gives a persistent two-way channel with lower per-message overhead, better for mobile when you also push progress. It is harder to load balance and some corporate proxies break it.
Reasonable choice: long polling by default, WebSocket where available, with fallback between them.
Notification Plus Change FeedArchitecture
Notify pathDevice Aedits a fileDevice Bcursor = 4821907Metadataservicecommit + feedChange logappend-onlyEvent channelpub/subNotificationsvc20M connections1 commit2 append3 event4 nudge5 get changes
Key point. Notifications can be lost without harm: devices always catch up from their cursor.
The nudge says 'something changed'. The cursor-based feed says exactly what.
The crucial design: the notification carries no data, only "namespace ns_981 has news." The client then calls the change feed with its saved cursor: give me all changes in this namespace after cursor 4821907. This makes the system robust:
A lost notification is harmless. The device also polls the feed every few minutes and at startup.
A device offline for a week catches up by reading changes after its last cursor, in pages of 500. Cursors are never lost because they are an increasing number in the change_log table.
Ordering is exactly the order of the log inside a namespace, so every device applies changes in the same order.
Fan-out: one change can notify many devices (a shared folder with 1,000 members). The metadata service publishes one event per namespace to a pub/sub channel, and each notification server notifies only the connections subscribed to that namespace.
6.6 Conflict resolution
Two devices edit report.docx offline from version 7. Device A syncs first and creates version 8. Device B commits with base_version: 7.
The metadata service compares base_version with the current version. 7 is not 8, so it returns 409 Conflict. This is optimistic concurrency control: assume no conflict, check at commit time, and reject the loser instead of locking the file.
Device B does not overwrite and does not discard. It saves its content as a new file: "report (Ben's conflicted copy 2026-12-01).docx" and syncs that. The user sees both and merges by hand.
For files we cannot merge (binary, video), this is the only safe answer. Automatic merge belongs to co-editing systems (OT/CRDT), which we put out of scope.
Same-name creates: two devices create notes.txt in the same folder. The unique name constraint makes the second commit fail; it gets renamed with a suffix.
Rename vs edit do not conflict because they touch different fields of one file ID, which is another reason files have IDs separate from paths.
Trade-off thinking. Locking would prevent conflicts but fails when a laptop goes offline holding the lock. Optimistic commits plus conflicted copies never lose data, at the cost of occasionally asking a human to merge.
6.7 Sharing and permissions
Sharing a folder with another user is modeled as making the folder its own namespace that several users are members of.
shares rows: (namespace_id, principal, role) with roles viewer, editor, owner. A principal is a user or a group.
Each user's file tree mounts shared namespaces at a path, so they appear in their folder. The change feed is per namespace, so every member syncs the shared folder through the same mechanism as their own files.
Permission checks happen in the metadata service on every metadata call and when issuing signed block URLs. Checks use the namespace ID plus the cached role, so they are one fast lookup.
Revocation: removing a member deletes the share row, invalidates the permission cache, and stops issuing URLs. Signed block URLs expire in 5 minutes so access ends soon.
Link sharing creates a random, unguessable token that maps to a file or namespace with an optional password and expiry. Anyone with the token gets read access.
Chunks are shared across users through dedup, so permissions are on files, never on chunks. A hash alone gives nothing: you must pass a file-level check first.
6.8 Versioning and trash
Every commit creates a version. Because versions share chunks, keeping 30 or 180 days of history adds only the changed chunks.
Delete is soft. It sets deleted_at, hides the file, and appends a delete event to the change feed. The file stays recoverable for 30 days.
Restore simply clears deleted_at, or moves current_version back to an older version. No bytes are copied.
Purge job permanently removes expired trash and versions beyond retention, decrementing chunk reference counts. Chunks reaching zero are deleted after a delay, so a delayed or retried commit cannot reference a chunk that was just removed.
Quota counts logical bytes of live versions and trash, which is what the user expects to see.
6.9 Durability: replication vs erasure coding
Eleven nines of durability needs redundancy. Replication stores full copies. Erasure coding splits an object into k data pieces and adds m parity pieces (computed from the data, like a cleverer checksum); any k of the k+m pieces rebuild the object.
Replication vs Erasure CodingComparison
3x replication
three full copies
1
Write the chunk to zone 1
2
Copy to zones 2 and 3
full copies
3
Read from any copy
fast, one machine
4
Repair by copying one replica
cheap and quick
Fast reads and writes
Simple to repair
3x storage: 420 PB for 140 PB
Survives only 2 losses
Use for new and hot chunks
Erasure coding 10+4
14 pieces, any 10 rebuild
1
Split chunk into 10 pieces
2
Compute 4 parity pieces
checksum-like math
3
Spread 14 pieces over machines
different zones and racks
4
Read any 10 to rebuild
survives 4 losses
Only 1.4x storage: 196 PB
Survives 4 failures
CPU for encode/decode
Reads and repair touch many machines
Use for cold chunks after about a week
Key point. Replicate hot data for speed; erasure code cold data, which is most of the bytes, for cost.
Both survive failures. They differ in storage cost and in read and repair cost.
3x replication over three zones: simple, fast reads and rebuilds, 3x storage cost. For 140 PB unique data that is 420 PB of raw disk.
Erasure coding 10+4: 14 pieces on 14 different machines or zones, survives any 4 losses, costs 1.4x, so 196 PB, saving over 200 PB of disk. Costs: more CPU, reads touch many machines, and repair is network heavy.
Practical plan: new and hot chunks replicated 3x for fast access. After about a week, a background job re-encodes cold chunks (most data) to erasure coding. Most bytes are cold, so most savings are captured.
Checksums and scrubbing: a background scrubber rereads chunks, verifies the hash, and repairs corruption from other pieces. Disks silently rot, so this is mandatory for eleven nines.
Zone placement: pieces are spread over multiple availability zones so one zone outage loses no data and, with 10+4 spread across 7 zones, no read availability.
Metadata durability is separate: synchronous replication to a second zone and point-in-time backups, because losing metadata makes the bytes unreachable.
Step 7: Bottlenecks and Failure Handling
Bottlenecks
Metadata database shards.Cause: a huge shared namespace (a company folder with millions of files) makes one hot shard. Mitigation: cache listings, paginate, split very large namespaces into sub-shards and rate limit per namespace.
Block service bandwidth.Cause: 5 GB/s peak downloads. Mitigation: scale block servers horizontally, use signed URLs so downloads go straight to storage or a CDN for popular shared links, and compress where it helps.
Chunk-index lookups.Cause: every upload checks hashes. Mitigation: batch many hashes in one call and put a bloom filter (a compact structure that quickly says "definitely not present") in front of the index.
Notification fan-out.Cause: a change in a folder shared with 100,000 people. Mitigation: batch notifications, send at most one nudge per device per few seconds.
Thundering herd after an outage.Cause: 20 million devices reconnect together. Mitigation: clients reconnect with jittered backoff; the server sheds load with 429 and a Retry-After value.
Failures
Client crashes mid-upload. The upload session lets it resume. Uncommitted chunks are cleaned up later.
Block server fails mid-write. The client sees an error or timeout, retries the chunk on another server. It is idempotent.
Metadata shard leader fails. A replica is promoted. Commits to that shard pause briefly; downloads of already-known files keep working from the cache and block service.
Notification server dies. Its devices reconnect elsewhere and call the change feed with their cursor, so nothing is missed.
Commit succeeds but response lost. The client retries with the same idempotency key and gets the same result, not a duplicate version.
Corrupt chunk detected. Read verification fails, the system reads another replica or reconstructs from parity, and heals the bad copy.
Zone outage. All tiers are multi-zone; erasure coding keeps data readable.
Accidental mass delete (or ransomware). Soft delete and version history allow a bulk "restore to time T" operation.
Interview tip. Pick two scenarios and walk through what the user sees and what you monitor: sync latency p99 (change to visible on another device), upload success rate, resume rate, chunk-verification failures, replication/repair backlog, change-feed lag per shard and open connection count.
Solid arrows are synchronous requests. Dashed arrows are asynchronous or background.
Request flow
Upload: client chunks and hashes, begins an upload with the metadata service, receives the missing chunks list, uploads them to the block service, commits atomically. Sync: metadata service emits a change event, notification service nudges devices, devices read the change feed after their cursor, download only missing chunks through signed block URLs.
Data flow
File names, folders, versions, chunk index, shares and the change log live in sharded, replicated relational databases (source of truth for "what exists"). Chunk bytes live in the block store, addressed by hash, replicated when hot and erasure coded when cold. Hot metadata and permissions live in a cache.
Background processing
A cleanup job removes orphaned uploaded chunks. A purge job expires trash and old versions and decrements reference counts. Garbage collection deletes chunks at zero references after a delay. A tiering job moves cold chunks to erasure coding. A scrubber verifies and repairs data. A queue distributes these jobs to workers.
Critical design decisions
Separate metadata from blocks, because there is 10,000 times more data than metadata and they need opposite consistency and cost profiles.
4 MB content-addressed chunks, giving dedup, delta sync, parallel and resumable uploads from one mechanism.
Strongly consistent, namespace-sharded relational metadata with atomic version commits.
Notification nudge plus cursor-based change feed, so sync is correct even when notifications are lost.
Optimistic concurrency with conflicted copies, so no edit is ever lost.
Replication for hot data, erasure coding for cold data, to reach eleven nines at about 1.4x storage overhead.
If time remains, discuss client-side encryption (dedup is harder when the server cannot see the bytes), a CDN for public link downloads, multi-region placement for data residency and regional latency, and metadata-only operations such as server-side copy that creates a file by reusing chunk references.