Why you need object storage, and when to use it
Photos, videos, documents, backups and logs are large files that are written once and read many times. Storing them in a database makes it huge and slow, and storing them on one server's disk risks losing them and limits how many can be kept. Object storage keeps each file as an object (the bytes plus metadata) under a key in a bucket, spread across many machines and copied for durability.
It gives you two things interviewers always ask about:
- Durability: objects are copied across machines or zones, so a failed disk does not lose data.
- Scalability and cost: capacity grows almost without limit at a low price per gigabyte, and the application servers stay stateless.
Use it when:
- You store user uploads, media, backups, logs or datasets.
- Files are large and read as a whole, or by ranges.
- You want to serve files through a CDN straight from storage.
- Data must survive hardware failures cheaply.
Skip it, or use something else, when:
- You need fast random updates inside a file or transactions across files: use a database or a file system.
- Objects are tiny and queried by content: use a database.
- You need very low latency for hot data: put a cache in front or use a block volume.
Try it
Upload a 100 MB file over a network that can fail. Compare one request against chunks.
Blob and Object Storage
Step 1 of 4 · Press Space to play, arrow keys to stepInitial state. A 100 MB file must reach the object store over a network that can fail.
- tick:
- 0
- MB sent:
- 0
- wasted MB:
- 0
- attempts:
- 1
1 tick = one step of the simulation.
Terms used in the counters: wasted MB is data sent that had to be sent again, attempts counts upload tries, and a tick is one step of the simulation. A CDN is a network of caches near users, a queue holds messages for background workers, and a lifecycle rule is an automatic rule such as "delete abandoned parts after 7 days".
Things to try:
- Run One request with Connection drops at 70%. The whole upload restarts and 70 MB are wasted.
- Switch to Chunks with the same failure. Only the lost chunk is sent again.
- Choose One piece arrives damaged with both. See how a checksum per chunk limits the repair.
Storage choices
| Kind | How it stores data | Good when | Weakness |
|---|---|---|---|
| Object storage | Immutable objects by key, over HTTP | Media, backups, data lakes | No in-place edits, higher latency than a disk |
| Block storage | Raw disk volumes attached to a server | Databases and operating systems | Tied to one machine, you manage the file system |
| File storage | A shared file system with folders and locks | Shared files for several servers | Harder to scale, more expensive |
| Database blob column | The file inside a row | Tiny files that need a transaction | Bloats the database and backups |
Direct upload vs uploading through your servers
- Through your servers: the client sends the file to your API, which forwards it to storage. It is simple, but your servers carry all the bytes and become the bottleneck.
- Direct upload with a presigned URL: your API checks permission, then gives the client a time-limited signed URL. The client uploads straight to storage, and your servers handle only small requests. This is the usual choice at scale.
How a large upload works
- The client asks your API for permission to upload and receives a presigned URL (or a set of them) valid for a few minutes.
- For large files the client starts a multipart upload and splits the file into chunks of a few megabytes.
- Each chunk is uploaded on its own, possibly in parallel, with a checksum. The store rejects a chunk whose checksum does not match.
- If the connection drops, the client asks which chunks are stored and resumes with the missing ones.
- When all chunks are in, the client completes the upload and the store joins them into one object.
- The store sends an event (for example to a queue) so other services can process the file, such as making thumbnails. Events are usually delivered at least once, so a worker may see the same event twice and must be idempotent (doing it twice gives the same result).
- Abandoned partial uploads are cleaned up by a lifecycle rule.
Object storage vs the alternatives
| Concern | Object storage | Database blobs | Server disk |
|---|---|---|---|
| Capacity | Practically unlimited | Limited | Limited |
| Durability | Very high, copied | High | Low |
| Cost per gigabyte | Low | High | Medium |
| Edit part of a file | No | Yes | Yes |
| Serve through a CDN | Easy | Awkward | Awkward |
| Best for | Files and media | Tiny files | Temporary data |
Object storage wins for files. Keep the metadata (owner, name, size, permissions) in a database and only the bytes in object storage.
What a presigned URL allows
A presigned URL is a bearer credential: anyone who holds it can use it until it expires. Scope it tightly.
- One method (PUT or GET), one key, and a short expiry.
- Where the provider supports it, restrict size and content type (for example with signed headers or a POST policy), and still validate the file after upload.
- Give each user a key prefix you control, never a name the client chooses.
A rough estimate
A 100 MB file split into 10 MB chunks is 10 requests, plus one to start and one to complete. If the connection drops at 70%, a single request resends 100 MB (170 MB sent in total), while chunks resend at most the chunk in flight. Larger chunks mean fewer requests but more resent data on a failure; smaller chunks mean the opposite. Providers set limits on chunk size, number of chunks and object size (Amazon S3, for example, allows up to 10,000 parts per object), so check your provider's documentation.
Avoiding a new single point of failure
- Durability comes from the provider copying objects across zones. For critical data, add cross-region replication and versioning, which keeps older copies when an object is overwritten or deleted.
- Access: serve through a CDN so a storage hiccup does not break every page.
- Metadata database: replicate it. An object with no metadata row is effectively lost, so write the row and the object in a safe order and reconcile regularly.
You accept higher latency than a local disk and no in-place edits in exchange for durability and scale. Consistency rules differ between providers (Amazon S3 has been strongly consistent for reads and lists since 2020, but older or self-hosted systems may not be), so check yours.
When the object and the row disagree
| Step order | Crash between the two writes | Repair |
|---|---|---|
| Write the object, then the row | An orphan object with no row (wasted money, no user impact) | A periodic job lists objects and deletes those with no row after a grace period |
| Write the row, then the object | A dangling row pointing at nothing (users see a broken file) | Harder: mark the row pending and only show it once the object exists |
Prefer object first, then row, and reconcile regularly.
Common mistakes
- Streaming uploads through application servers. Use presigned URLs.
- One huge request for big files. Use multipart upload with resume.
- Public buckets by accident. Default to private and serve through signed URLs or a CDN.
- Trusting the file name or type. Validate content, size and type, and scan for malware.
- No lifecycle rules. Abandoned uploads and old versions pile up and cost money.
- No link between the row and the object. Deleting one and not the other leaves orphans.
How to talk about object storage in an interview
- Say the files go to object storage, with metadata in a database and a CDN for reads.
- Describe the presigned URL flow and multipart upload with checksums and resume.
- Mention durability (copies, versioning, replication), access control, lifecycle rules and events for processing.
- Name the trade-off: objects are cheap and durable but cannot be edited in place, so a change means writing a new object.