Design Dropbox: file chunking, sync, and storage
Dropbox
Guided ModeSeparate File Bytes from Metadata
The first fix: stop storing file bytes in the database. Put them in S3 / Blob Storage — an infinitely scalable object store designed for binary data. The database only stores the file key, owner, and metadata.
Request Flow
API uploads file to S3
The API receives the file, streams it to S3 / Blob Storage via a PUT request. S3 returns the object key.
PUT s3://dropbox-files/user123/abc.zip Content-Length: 524288000
API saves key in DB
The Database row is now tiny — just the S3 key, filename, size, and owner. No blob.
INSERT INTO files (user_id, name, s3_key, size) VALUES ($1, $2, $3, $4)
Device B fetches via key
Device B asks the API for the file. The API looks up the S3 key and redirects Device B to fetch directly from S3 using a pre-signed URL.
Why We Need This
S3 stores objects at $0.023/GB/month and serves them at 100 GB/s. Your database is now lean — it only handles tiny metadata rows, so queries, backups, and replication are fast again.
Key Insight
S3 is not a database — it's a flat key-value store for bytes. The DB stores what the file is; S3 stores what the file contains.
Step 2 of 8
