Back
LearnSystem Design PlaybookCDNs, DNS & the Edge

CDNs, DNS & the Edge

2 min read

CDNs, DNS & the Edge

The fastest request is the one that never reaches your servers. Edge infrastructure serves users from nearby.

DNS — the internet's phone book

DNS translates example.com into an IP address. In system design it's also a routing tool:

  • Geo-routing — send users to the nearest region.
  • Failover — point away from a dead datacenter.
  • Load distribution — round-robin across multiple IPs.

The lookup is cached at many layers (browser, OS, resolver) governed by the record's TTL — low TTL = faster failover but more lookups.

CDN — content delivery network

A CDN is a global network of edge servers that cache your content close to users.

User (Tokyo) ──▶ Edge (Tokyo) ──cache miss──▶ Origin (US)
                     │
                     └──cache hit──▶ served locally, ~ms
  • Static assets — images, CSS, JS, video: cache them at the edge for months.
  • Dynamic acceleration — even uncacheable requests benefit from optimised edge-to-origin routes.
  • Benefits: lower latency, less origin load, DDoS absorption, bandwidth savings.

Cache control

You govern edge caching with headers:

  • Cache-Control: max-age=31536000, immutable — cache aggressively (fingerprinted assets).
  • Cache-Control: no-store — never cache (personalised/sensitive responses).
  • Cache busting — put a content hash in the filename (app.9f3c.js) so a new deploy = a new URL.

Push vs pull CDNs

  • Pull (common): CDN fetches from origin on first request, then caches. Low maintenance.
  • Push: you upload content to the CDN ahead of time. Good for large, infrequently changed files.

Combine them: DNS gets the user to the nearest edge, the CDN serves static content, and only true dynamic requests reach your origin — where your load balancers and caches take over.

Tip