SD System Design In Depth
0%
lesson system-designobject-storage

Object storage vs database

Module 2.3: Storage Engine Internals & Blob Systems Updated Sep 17, 2026
📄 Cheat Sheet
Object Storage in System Design Interviews w/ Ex-Meta Staff Engineer
Hello Interview Object Storage in System Design Interviews w/ Ex-Meta Staff Engineer Watch on YouTube ↗

Kept: Hello Interview's object-storage video is squarely about when to put blobs in object storage versus a database, presigned URLs and metadata-in-DB patterns.

0:00 / --:--

Under the Hood: The Three Storage Abstractions

Enterprise infrastructure categorizes persistent storage into three distinct fundamental primitives: Block Storage, File Storage, and Object Storage. Choosing the wrong primitive leads to catastrophic scaling bottlenecks and astronomical cloud bills.

Storage Primitive Comparison

flowchart TD subgraph Block ["1. Block Storage (EBS / SAN)"] B1["Raw 512B / 4KB Sectors"] --> OS["Filesystem mounted by single OS kernel (ext4, XFS)"] end subgraph File ["2. File Storage (EFS / NFS)"] F1["POSIX Tree Hierarchy (/usr/bin/...)"] --> Locks["Distributed locking and shared network mounts"] end subgraph Object ["3. Object Storage (S3 / GCS)"] O1["Flat Namespace (Bucket + Key)"] --> REST["HTTP REST API (GET, PUT, DELETE) - Immutable Blobs"] end

Detailed Architectural Differences

FeatureRelational / NoSQL DatabaseObject Storage (S3 / GCS)
Data GranularityFine-grained: Mutate single columns, rows, or key-value fields.Coarse-grained: Entire blobs (bytes 0 to N). Partial in-place mutation is not supported; an object can only be replaced or deleted as a whole.
Access ProtocolBinary database protocols (TCP sockets, prepared statements, gRPC).HTTP/1.1 and HTTP/2 REST APIs (PUT /bucket/key, GET /bucket/key).
Latency ProfileSub-millisecond to low single-digit milliseconds (100µs - 5ms).Tens to low hundreds of milliseconds time-to-first-byte (AWS cites roughly 100-200 ms for small objects on S3 Standard; S3 Express One Zone offers single-digit milliseconds).
Throughput & ScalingBound by cluster instance size and replication topologies.Virtually infinite: Scale to millions of concurrent requests across petabytes.
Cost per GigabyteHigh (~$0.10 - $0.50 / GB / month on managed SSD volumes).Ultra-Low (~$0.015 - $0.023 / GB / month on standard tiers).

Worked example: 50 million photos

50 million images averaging 500 KB is 25 TB.

OptionApproximate monthly storage costNotes
S3 Standard, about USD 0.023 per GB-monthAbout USD 575Durability across multiple AZs is included
Database on gp3 SSD, about USD 0.08 per GB-month, 3 replicasAbout USD 6,000 before instance costsPlus larger backups and slower replica rebuilds

Request costs matter too. At roughly USD 0.005 per 1,000 PUTs and USD 0.0004 per 1,000 GETs, 50 million uploads cost about USD 250 once and 100 million monthly reads cost about USD 40; a CDN in front usually removes most reads. Prices vary by region and change over time, so treat these as orders of magnitude.

The standard pattern

  1. Client asks the API for an upload; the API creates a pending row (photo_id, owner, status=pending) and returns a presigned PUT URL for key photos/ab/photo_id.
  2. Client uploads directly to object storage, bypassing the application servers.
  3. An upload-complete event or client callback verifies size and checksum, then marks the row active.
  4. A periodic sweeper deletes objects with no active row older than a day, and alerts on active rows whose object is missing.

When a database blob is reasonable

  • Values are small (kilobytes) and read together with the row.
  • You need the blob to commit or roll back atomically with other rows.
  • The total volume is modest and the operational simplicity of one system wins.

Since December 2020, S3 provides strong read-after-write consistency for PUTs and LISTs, which removes an old class of "row says active but GET returns 404" races.

Check yourself Question 1 of 3
Editing an object recall
From: Detailed Architectural Differences

You need to change 1 KB in the middle of a 2 GB object stored in S3. What does the object model require?

Key Takeaways

Databases provide low-latency sub-millisecond access to mutable, fine-grained structured records.
Object storage provides named blob versions over an HTTP API; keys can usually be overwritten or deleted, while retained versions may be immutable. Cost and latency depend on provider, tier, request mix, and data transfer.
For large independently accessed payloads, compare object storage with database blobs using transactionality, backup, access size, request cost, and operational simplicity rather than applying a universal prohibition.
Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue