Object Storage and Large Files
Store images, videos and backups in object stores like S3, use pre-signed URLs and multipart uploads, and keep only metadata in your database.
Beginner · about 2 hours · difficulty 2/5
Learn first: Content Delivery Networks (CDNs), Relational Databases and SQL for Design
Databases are poor places for large binary files. Object storage (Amazon S3, Google Cloud Storage, Azure Blob, MinIO) stores files as objects in buckets with very high durability and cheap, almost unlimited capacity.
The standard pattern
- Store the file in the object store; store metadata (owner, size, content type, object key, status) in your database.
- Serve files through a CDN in front of the bucket.
- Let clients upload directly to the bucket with a pre-signed URL, so gigabytes never pass through your app servers.
Useful features
- Multipart and resumable uploads: upload a 2 GB video in chunks, retry only failed parts. Essential on flaky mobile networks.
- Storage classes and lifecycle rules: move old objects to cheaper, colder tiers automatically.
- Versioning: protect against accidental overwrites and deletes.
- Event notifications: trigger a thumbnail or transcoding job when an upload completes.
Durability vs availability
S3 is designed for eleven nines of durability (you will not lose the object) but lower availability guarantees (a request can occasionally fail). Design clients to retry.
Block and file storage
- Block storage (EBS, local SSD): raw disks for databases and VMs.
- File storage (EFS, NFS): shared file systems mounted by many servers.
Pick object storage for user content and backups, block storage for database volumes.
Pitfalls
- Storing images as BLOBs in Postgres and bloating backups and replication.
- Public buckets by mistake. Default to private and use pre-signed URLs or a CDN with signed URLs.
- Uploading through your API servers and tying up threads for minutes.
You are ready to move on when you can sketch the upload and download flow for profile photos using pre-signed URLs, a CDN and a metadata table.
Key concepts
- Object vs block vs file storage
- Metadata in DB, bytes in object store
- Pre-signed URLs
- Multipart and resumable uploads
- Lifecycle rules and storage classes
- Upload event triggers
- MinIO for local development
Mini project
Build an upload service with MinIO or S3: the API issues a pre-signed URL, the browser uploads directly, an event triggers thumbnail generation, and a metadata row tracks status from pending to ready.
Check yourself
Why are pre-signed URLs better than streaming uploads through your API servers, and what security checks still belong on the server?
Free resources
- Amazon S3 documentation (AWS)
- MinIO documentation (MinIO)
- ByteByteGo System Design 101 (ByteByteGo)