A 2-minute product demo video, uploaded once in Bengaluru, gets watched by people in Chennai, Delhi, Dubai and London within the hour. Should every single one of those views travel all the way back to a server in Bengaluru? And should that video's raw bytes even live inside the same database that holds usernames and order rows? Both answers are no — and this lesson covers exactly why.
Why large files don't belong in a database
A relational database is optimized for structured rows, indexes, and transactions — not for storing and streaming large binary blobs. Technically, a database CAN store a file in a blob column, but it bloats backups, slows replication, and burns an expensive, transaction-optimized system on something that doesn't need transactions at all. The standard split: metadata (owner, filename, size, a pointer/URL) lives in the database; the actual bytes live somewhere purpose-built.
Object storage
Object storage (Amazon S3 being the best-known example) is built exactly for this: durable, cheap storage of unstructured files, addressed by a key, at essentially unlimited scale. A photo upload writes the bytes to object storage and stores just the resulting key/URL, plus lightweight metadata, in the database — each system doing what it's actually good at.
The best-known object storage service
What a CDN actually does
A CDN (Content Delivery Network) is a network of edge servers spread across many physical locations worldwide. The first request for a file from a given region is a cache miss and travels all the way to the origin server, but the response is cached at the nearby edge — every request after that, from anyone near that region, is served locally. This mostly wins on physical distance: fewer network hops and less round-trip time, not compression or a different protocol.
A widely used CDN provider
Cache invalidation for static content
Every object a CDN caches has a TTL. Until that expires — or the CDN is explicitly told to purge it — edge nodes keep serving the OLD version, which is exactly why a freshly deployed logo update can appear stale for some users. The fix is either an explicit purge/invalidate call for that path, or (the more common production approach) versioning the asset's URL itself — e.g. logo.a1b2c3.png — so a changed file is automatically a brand-new object with nothing to invalidate.
Origin shields and the viral-moment problem
During a viral moment, thousands of edge locations can all get a cache miss for the same brand-new object at nearly the same instant, each independently hammering the origin — the CDN-scale version of the cache-stampede problem from the caching lesson. An origin shield — a middle caching layer between the many edge nodes and the single origin — coalesces these near-simultaneous misses into a single origin fetch, then fans the result back out, protecting the origin from that thundering herd.
Common mistakes
- Storing large binary files as blob columns in the main relational database.
- Forgetting that a CDN needs an explicit invalidation strategy, and being surprised when a deploy appears stale.
- Assuming every kind of content benefits from a CDN, including highly personalized or rapidly-changing data.
- Not considering an origin shield for content expected to go viral.
Quick recap
| Concept | One-liner |
|---|---|
| Object storage | Cheap, durable storage for large files, addressed by key — not a database. |
| CDN | A network of edge servers caching static content close to users. |
| Invalidation | TTL, explicit purge, or (best) versioned filenames. |
| Origin shield | Protects the origin from a thundering herd of simultaneous cache misses. |
Practice Zone
Five MCQs, then two applied questions.
Why does a CDN make a video load faster for a user in Chennai if the origin server is in Virginia?
Asked in


Why do large files like videos and images usually go into object storage (like Amazon S3) instead of a relational database?
Asked in

A company updates its logo image but the CDN keeps serving the old one to some users. What is the most common cause?
Asked in


Which kind of content benefits most from a CDN?
Asked in

During a viral moment, thousands of edge locations all get a cache miss for the same new image at once and hammer the origin server simultaneously. What common CDN feature reduces this?
Asked in

A photo-sharing feature needs to store: (1) the photo file itself (2-8 MB), (2) the caption text, (3) the like count, (4) who uploaded it and when. Decide, for each, whether it belongs in the relational database or in object storage, and explain why.
Asked in
Instagram-style rounds
Your site's CSS file is served through a CDN with a 24-hour TTL. You just deployed a critical CSS fix and need every user to see it within minutes, not hours. Name two different techniques that would work, and the trade-off of each.
Asked in

FAQ
Is a CDN the same as a cache?
A CDN IS a form of caching — specifically, geographically distributed caching for static content, close to users worldwide, rather than a single cache sitting near one application server.
Does every website need a CDN?
Not a tiny internal tool with a handful of users in one office — but any public-facing site serving images, videos, or static assets to a geographically spread audience benefits meaningfully.
Can dynamic, personalized content ever go through a CDN?
Some CDNs support caching at the edge for short windows even for semi-dynamic content, or handle routing/security (not caching) for fully dynamic requests — but the core caching benefit is strongest for genuinely static or rarely-changing content.


