CDN

Share
CDN
A CDN helps users download content from servers close to them.
In interviews, CDN is usually the right tool for static files, images, videos, and other content that can be cached at the edge.

What a CDN does

CDN means Content Delivery Network.

It is a network of edge servers around the world.

Instead of every user downloading content from your origin server, users download from a nearby edge server.

User → Nearby CDN Edge → Origin Server

If the content is already cached at the edge, the request does not need to hit your origin at all.

Why CDN helps

CDN improves:

  • latency,
  • availability,
  • origin server load,
  • global performance,
  • handling of hot or viral content.

For example, a user in Germany should not need to download an image from a server in California if a CDN edge server in Europe already has it.

What to put on CDN

CDN and blob storage

A very common pattern is:

Blob Storage as origin
CDN as delivery layer

Example:

A good interview phrase:

I would store the media in object storage and serve it through a CDN for low-latency global access.

URL Shortener example

A URL shortener may not need CDN for the basic redirect path.

But if it supports QR code images or public preview images, CDN becomes useful.

Example:

QR code image stored in S3
CDN caches QR image globally
Users load QR image from nearest edge

For very hot short links, CDN may also cache redirect responses, but this has tradeoffs.

If the CDN returns the redirect directly, your server may not see every click. That can affect analytics.

A good answer:

For QR code images, CDN is a clear win. For redirect responses, I would be more careful because edge caching may reduce server-side tracking.

When to mention CDN

Use CDN when the prompt includes:

  • images,
  • videos,
  • file downloads,
  • global users,
  • static content,
  • public content,
  • high read traffic for the same objects.

Examples:

  • YouTube,
  • Instagram,
  • Dropbox,
  • Google Drive,
  • image upload system,
  • product catalog,
  • QR code images.

When not to mention CDN

Do not add CDN just because you want the diagram to look advanced.

CDN is less useful when:

  • content is private and unique per user,
  • data changes every second,
  • the system is only used in one region,
  • the response requires authentication and cannot be cached safely,
  • the problem is mainly about writes or transactions.

Common mistakes

  • Putting highly personalized data on CDN without explaining security.
  • Forgetting cache invalidation.
  • Using CDN for a system that has no static or media content.
  • Ignoring analytics tradeoffs when caching redirects or API responses.
  • Not explaining what the origin is.

Final takeaway

CDN is the right tool when the system serves cacheable content to many users, especially across regions.

A strong answer is:

We serve static or media content through CDN because it reduces latency and origin load. The tradeoff is cache invalidation and less control over what happens at the edge.