LOAD-BEARINGfree
FoundationsTier 3 · unit 8 of 12 · 13 min read

Object storage: where the bytes live

Everything so far in this tier has been about rows — small, structured, queried by their contents. A forty-megabyte video is none of those things. It is a sequence of bytes with a name, written once, read many times, never queried by what is inside it. Putting it in your database is not merely inelegant; it is a specific set of injuries, and it is worth naming them because the instinct to add a BLOB column is genuinely strong.

A large binary in a relational database pushes real rows out of the buffer pool, so unrelated queries slow down. It lands in your backups, so a 50 GB database becomes 4 TB and the restore in Lesson 9.10 goes from minutes to a day. It replicates to every follower. And the upload holds an application thread and a database connection open for the entire duration of a phone on a train — which, per Lesson 3.06, is the resource you have least of.

So there is a fourth storage primitive alongside relational, key-value and search: object storage. S3 and its many imitators. It deserves ten minutes because half the systems in this course quietly depend on it.

What it actually is, and what it deliberately is not

A flat keyspace mapping a string to an immutable blob plus a little metadata, addressed over HTTP. Everything surprising about it follows from that one sentence:

  • There are no directories. videos/2026/07/clip.mp4 is one key containing slashes. Consoles render prefixes as folders to be kind. Listing a prefix with ten million keys is a paginated scan, not a lookup.
  • Objects are immutable and there is no append. You replace an object, you do not edit it. A rename is a copy followed by a delete, and it costs a full copy.
  • Durability and availability are different numbers. The famous eleven nines is durability — the bytes will still be there. Availability is three or four nines, so the store can be unreachable while losing nothing. Design for it being down, not for it losing data.
  • It is single-region until you pay for otherwise. "In the cloud" is not a backup strategy and not a multi-region strategy.

The upload path: bytes must not pass through your servers

The pattern that matters, and the one the video lab depends on. The client asks your API for permission to upload. Your API returns a presigned URL — a URL carrying a signature that grants exactly one operation, on exactly one key, expiring in minutes, optionally constrained to a content type and a maximum size. The client then PUTs the bytes straight to the object store. Your application never sees them.

What that buys is not subtle: no bandwidth through the app tier, no thread parked for three minutes, no gateway timeout at sixty seconds, no scaling your API fleet for upload concurrency. What it costs is that you no longer inspect what you accepted. Validation moves after the fact: the store emits an event, a worker checks type, size, and content, and only then flips the record's status to usable. Anything reading before that must treat the object as not yet real.

Large files need one more thing. A single PUT of 5 GB over a mobile network is one long bet you will lose. Multipart upload splits it into parts uploaded and retried independently, then a final call assembles them. Two things bite here: an interrupted multipart upload leaves parts that are stored and billed but invisible in a listing, so you need a lifecycle rule to abort incomplete uploads after a few days — and resumability is a client concern, because the client is the only party that knows which parts it finished.

Two systems, no transaction

The bytes live in the object store; ownership, status, checksum and key live in a row. There is no transaction across the two, so orphans are guaranteed in one direction or the other — and the directions are not equally bad. An orphaned object is a few paise of storage that a sweeper job reclaims. An orphaned row pointing at a key that was never written is a broken image on a user's screen.

So: write the row first in a pending state, upload, then confirm. Never delete the object in the same breath as the row either — mark it for deletion and let a job remove it, because a delete you cannot roll back paired with a transaction you can is exactly the shape that loses data.

Classes, lifecycle, and the bill

Storage classes — hot, infrequent access, archive — differ by more than an order of magnitude per GB, and you move data between them with lifecycle rules written against age or prefix rather than by hand. The catch is that cheaper classes are cheap on storage and expensive on retrieval: archive tiers charge a retrieval fee and take minutes to hours to produce the object. "Archive after ninety days" is therefore a product promise about read latency, not a finance decision, and it needs to be made with whoever owns that screen.

And the line item that surprises people every time: storage is cheap, requests are cheap-ish, and egress out of the cloud is where the money goes. Serving media directly from the bucket at scale is a bandwidth bill; a CDN in front of it (Lesson 4.03) is the standard fix and usually pays for itself immediately.

The trap

Using the object store as a database. It has no transactions, no secondary indexes, and no query language — so the moment you find yourself listing a prefix to find something, you have built a full scan with an HTTP call per page. Your database is the index; the object store holds bytes it never has to understand. The same mistake in a different costume is polling a prefix to discover new work: use the store's event notification into a queue instead, and let listing be the thing you do during a backfill and never in a request.