Course contents

14. Cloud and Infrastructure Lesson 7 of 8

Object Storage

Learn the bucket-and-key model, how erasure coding across zones keeps objects durable, why presigned URLs beat proxying uploads, and how to serve via a CDN.

14 minIntermediate8 steps
Loading the interactive simulation…
Loading the knowledge check…

Summary

  • Object storage is a flat key → object map behind an HTTP API: whole-object PUT, GET, DELETE and prefix listings.
  • Prefixes look like folders but are not; renames are copy + delete per object.
  • Durability comes from replicas or erasure-coded fragments across zones, written before the PUT is acknowledged.
  • Presigned URLs let clients upload and download directly while your app keeps authorization.
  • Serve public objects through a CDN from a private bucket.
Deep diveHow it works, trade-offs, failure modes, misconceptions and the interview angle.

What it is

Object storage keeps objects — a blob of bytes plus metadata such as content type and custom key-value pairs — in buckets. Every object is identified by a key, an arbitrary string like users/42/avatar.jpg, and accessed over an HTTP API: PUT writes a whole object, GET reads it (optionally a byte range), HEAD reads its metadata, DELETE removes it, and LIST returns keys that start with a given prefix. Amazon S3 popularised the model; Google Cloud Storage, Azure Blob Storage and many S3-compatible systems (including self-hosted ones) follow it.

Why it exists

Disks and file systems are bounded by one machine or one cluster, need capacity planning and fail with their hardware. Applications increasingly store large, unstructured data (uploads, media, backups, logs, analytics files) that is written once and read many times. Object storage gives practically unlimited capacity with no provisioning, very high durability, pay-per-use pricing and an API any client can reach, by dropping the parts of file-system semantics that are hard to scale: in-place edits, locks, renames and hierarchical directories.

How it works

Flat namespace. Keys are strings. The slash is just a character; consoles show "folders" by grouping common prefixes in listings. Renaming a prefix means copying and deleting each object.

Whole-object writes. You cannot append to or modify part of an object; you write a new version of the whole object. Large uploads use multipart upload: the object is sent in parts, possibly in parallel, each part retried on its own, and assembled when the upload is completed.

Consistency. The major providers now offer strong read-after-write consistency for single objects: after a successful PUT or DELETE, subsequent reads and listings reflect it. Documentation describing eventual consistency for S3 is from before late 2020. There are still no transactions across objects.

Durability. Objects are stored redundantly across devices and, for standard storage classes, across availability zones before the write is acknowledged. Two techniques: full replication (several complete copies) and erasure coding, which splits an object into k data fragments, computes m parity fragments and can rebuild the object from any k of the k + m. With 6 + 3 fragments spread over three zones, losing a whole zone still leaves 6 fragments, at 1.5× the raw size instead of 3× for three copies. Background processes verify checksums and repair lost fragments. Providers publish durability design targets for their storage classes; treat them as design goals, and remember they do not protect against your own deletes.

Access control. Requests are authenticated with credentials and authorised by identity policies and bucket policies. Presigned URLs are URLs that carry a signature made with valid credentials over the method, bucket, key, expiry and optionally headers; whoever holds the URL can perform exactly that operation until it expires. A POST policy (presigned POST) can add conditions such as a maximum size.

Storage classes and lifecycle. Classes trade storage price against retrieval price and latency: frequent access, infrequent access, archive. Lifecycle rules move objects between classes or delete them after a given age.

When to use it

  • User uploads: photos, documents, video.
  • Static website assets and media served through a CDN.
  • Backups, database snapshots and log archives.
  • Data lakes: analytics files (Parquet and similar) queried in place by engines that read object storage.
  • Artefacts: build outputs, container layers, ML datasets and model weights.

When not to

  • As a database: there are no queries over contents, no secondary indexes and no multi-object transactions. Keep metadata (owner, status, references) in a database and the bytes in object storage.
  • For workloads that need POSIX file semantics: in-place updates, appends, locks, atomic renames. Use block storage or a network file system.
  • For many tiny, latency-critical reads and writes: per-request latency (tens of milliseconds) and per-request pricing add up.

Trade-offs

Choice You gain You pay
Presigned direct uploads Servers stay out of the data path; scales with the store Signing logic, post-upload validation, URLs usable by whoever holds them
Proxying uploads through the app Full control and inspection in-line App connections and bandwidth tied up by transfers
Erasure coding vs replication Lower storage overhead for the same loss tolerance More work to read degraded data and to repair
Colder storage class Much cheaper storage Retrieval fees, minimum durations, slower or delayed access
Versioning / object lock Protection against deletes, overwrites and ransomware Storage for old versions; deletion rules to manage

Alternatives

  • Block storage (virtual disks): attached to one machine, low latency, needs a file system and capacity planning.
  • Network file systems: shared POSIX-like access for applications that need it, at higher cost per gigabyte.
  • Databases with blob columns: transactional with metadata, but large blobs bloat backups and replication.
  • CDN storage or edge key-value stores: for small objects needed at the edge.

Failure modes

  • Public buckets by mistake: a misconfigured policy exposes everything. Block public access by default and serve public content through a CDN.
  • Leaked or long-lived presigned URLs: anyone can use them until expiry.
  • Accidental or malicious deletion: durability does not protect against DELETE. Use versioning, object lock and backups in a separate account.
  • Hot prefixes and request throttling: very high request rates concentrated on one key prefix can be throttled; spread keys or ramp traffic gradually.
  • Egress bills: serving popular objects straight from the bucket can cost more than storing them.
  • Orphans: objects whose database records were deleted (or uploads never completed) accumulate silently; lifecycle rules and reconciliation jobs clean them up.

In production

Block public access and grant least privilege per application. Upload directly with short-lived presigned URLs (server-generated keys, fixed content type, size limits), then validate content asynchronously from a storage event before marking it usable. Serve through a CDN with the bucket readable only by the CDN. Enable versioning on buckets that matter, add lifecycle rules for old versions, incomplete multipart uploads and cold data, and replicate critical buckets to another region if you need regional disaster recovery. Monitor request errors, 4xx from expired signatures, egress and storage growth.

Common misconceptions

  • "Folders exist." Only prefixes exist.
  • "Very high durability means I cannot lose data." Durability covers hardware loss, not your own deletes, bugs or a compromised account.
  • "Object storage is eventually consistent." No longer true for single-object reads on the major providers.
  • "Presigned URLs are secure because they are secret." They are bearer credentials: keep them short-lived and narrow.

Interview angle

In designs with user uploads or media, put the bytes in object storage and the metadata in a database, upload with presigned URLs, process with events (thumbnails, virus scans, transcoding), and serve through a CDN. Be ready to explain durability (replication or erasure coding across zones), the consistency model, multipart uploads for large files, lifecycle and storage classes for cost, and how you protect against public exposure and accidental deletion.

Model assumptions

Steps 1–4 are scripted illustrations, not simulations: packets are placed by hand to show request order, the zone storage nodes have no simulation model, and the 6 + 3 erasure-coding scheme is an example (providers do not publish their exact layouts). Steps 5–7 use the engine. The object store is modelled as a server with 2,000 concurrent transfers and a 400 ms mean time per multi-megabyte transfer (lognormal, cv 0.3). The app servers have 4 workers and room for 8 waiting requests; when they proxy an upload they hold a worker until the store answers. In the presigned step the engine carries only the uploads to the store; the signing request and the storage event are scripted packets. The CDN edge is a fast proxy with a fixed 90% hit ratio. Arrivals are random (Poisson). One-way latencies are fixed: users to app or store 20 ms, app to store 2 ms, viewers to edge 8 ms, edge to store 30 ms. Numbers show behaviour and orders of magnitude only.

The lesson as textEvery step of the simulation, written out.
  1. 1. Buckets, keys and whole objects

    Object storage keeps objects (a blob of bytes plus metadata such as content type) in buckets. Each object is addressed by its key, a string like users/42/avatar.jpg, through an HTTP API: PUT stores a whole object, GET reads it (or a byte range), DELETE removes it.

    The slashes are just characters in the key. There are no real directories: the namespace is flat, and “folders” in consoles are a display of common key prefixes. In exchange for this simple model you get practically unlimited capacity, billed per gigabyte-month and per request.

    *This step is a scripted illustration.*

    Scene: The app server stores an object in the bucket “photos” under the key users/42/avatar.jpg with a PUT, then reads it back by the same key with a GET. Scripted illustration.

    Key idea: An object store is a huge, flat key → blob map behind an HTTP API, not a disk.

  2. 2. It is not a file system

    Renaming the “folder” users/42/ is not one operation. The app first lists the keys with that prefix, then copies each object to its new key and deletes the old one: two requests per object, and not atomic as a whole.

    There is no appending, no editing bytes in place and no file locks: to change an object you write a new version of the whole thing. Large files are uploaded in parts (multipart upload) and assembled at the end. Reads of a single object are strongly consistent on the major providers today (a GET after a successful PUT returns the new data), but nothing gives you transactions across several objects.

    *Scripted illustration.*

    Scene: To rename a prefix with two objects, the app lists the prefix, then copies and deletes each object: five request–response pairs in a row. Scripted illustration.

    Key idea: Design for whole-object writes, prefix listings and per-object operations; anything file-system-like has to be built on top.

  3. 3. Durability: fragments in three zones

    Behind the API, the store does not keep your object on one disk. A common technique is erasure coding: split the object into, say, 6 data fragments, compute 3 parity fragments, and spread all 9 over three availability zones. Any 6 of the 9 are enough to rebuild the object, so even losing a whole zone (3 fragments) loses nothing, at 1.5× the raw size instead of 3× for three full copies.

    The store answers the PUT only after the fragments are stored in every zone. That is why a successful upload is safe the moment you get the 200, and why a PUT takes a little longer than a write to a local disk.

    *Scripted illustration with example numbers; providers do not publish their exact schemes.*

    Scene: The app uploads an object. The store writes fragments to storage nodes in Zones a, b and c in parallel, waits for all three acknowledgements, then answers the app. Scripted illustration.

    Key idea: Durability comes from spreading redundant fragments across failure domains before acknowledging the write.

  4. 4. A zone fails, the object survives

    Zone b goes offline with a third of the fragments. A GET still works: the store reads fragments from Zones a and c, which hold 6 of the 9, rebuilds the object and returns it, a little slower than usual.

    In the background the store repairs: it recreates the lost fragments elsewhere so the object is protected against the next failure, too. Durability (not losing data) and availability (being able to read it right now) are different promises; storage classes that keep data in a single zone are cheaper but give up the first one when that zone is lost.

    *Scripted illustration.*

    Scene: Zone b is offline. The store reads fragments from Zones a and c, returns the rebuilt object to the app, then recreates the lost fragments in the remaining zones. Scripted illustration.

    Key idea: Redundancy across zones keeps objects both durable and readable through a zone outage; repair restores the margin.

  5. 5. Uploads through the app servers

    Zone b is back. Now users upload photos, about 12 per second, and the obvious design streams every upload *through* the app servers to the store.

    That ties up an app worker for the whole transfer, about 400 ms per photo here. The four workers can handle roughly 9 uploads per second, so their queue fills and uploads are rejected, while the object store, built for thousands of parallel transfers, is barely touched. Every other request the app serves would be stuck behind the uploads too.

    Scene: Users upload 12 photos per second through the app servers. Each upload holds an app worker for about 400 ms; the app is 100% busy with a full queue and rejects some uploads, while the object store has plenty of spare capacity.

    Key idea: Proxying large uploads through your servers spends their scarcest resource, concurrent connections, on moving bytes.

  6. 6. Presigned URLs: upload straight to the store

    Instead, the browser asks the app for permission. The app checks who the user is, then returns a presigned URL: the bucket, the key and an expiry, signed with the app’s credentials (the gold token). The browser PUTs the photo directly to the object store, which verifies the signature. When the object is written, the store can emit an event (the async message) so the app records it.

    The app now spends a few milliseconds per upload instead of a worker for the whole transfer: no more rejections, and the store does the heavy lifting it was built for. Keep expiries short, fix the key and content type in the signature, and use a POST policy if you need a size limit; anyone holding the URL can use it until it expires.

    Scene: The browser gets a signed URL from the app, then uploads directly to the object store, which notifies the app when the object exists. The app is idle, uploads no longer fail and the store handles all 12 per second.

    Key idea: Presigned URLs keep authorization in your app and move the bytes directly between the client and the store.

  7. 7. Serve objects through a CDN

    People view the photos about 300 times per second. Instead of pointing them at the bucket, we put a CDN in front. The edge answers about 90% of views from its cache in about 20 ms; only misses travel to the store.

    The store sees about a tenth of the reads, which cuts per-request and egress charges, and viewers get low latency wherever they are. Keep the bucket private and let only the CDN read it (an origin access identity or signed origin requests); for private photos, the CDN can check signed URLs or cookies itself.

    Scene: Viewers request photos from a CDN edge 300 times per second. About 90% are answered from the edge cache; only the misses reach the object store, which also keeps receiving direct uploads.

    Key idea: Object storage is the origin, a CDN is the front door: private bucket, public edge.

  8. 8. Where object storage fits

    Uploads go straight to the store with presigned URLs, views come through the CDN, and the app servers only make decisions.

    Use object storage for user uploads, media, backups, logs, data-lake files and static sites: large, written once, read many times. Do not use it as a database (no queries, no transactions across objects) or as a mounted file system for software that expects POSIX semantics.

    Also plan for: lifecycle rules (move old objects to colder, cheaper classes or delete them), versioning or object lock against accidental deletes and ransomware, keys that do not create hot prefixes, and egress costs, which often exceed storage costs.

    Scene: Users upload directly to the object store, viewers read through the CDN edge, and the app servers are nearly idle. Nothing fails.

    Key idea: Let the store hold and move the bytes; keep your servers for authorization and metadata.