awesome-everything RU
↑ Back to the climb

Networking & Protocols

CDN: putting content next door

Crux A CDN moves copies of your content to hundreds of edge servers worldwide so each user fetches from a server 20 ms away instead of 200 ms.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at junior altitude — the surface
◷ 8 min

When Bea · Browser in London loads a page whose server sits in California, every request travels 200 ms round-trip — and nothing in your code can fix that. The speed of light is finite. A CDN closes the gap by moving content, not by speeding up the network.

What a CDN does in one sentence

A CDN (Content Delivery Network) keeps copies of your website on hundreds of servers around the world so the user’s browser fetches bytes from a server 20 ms away instead of one 200 ms away.

Why latency is the real problem

Speed of light is ~300,000 km/s in vacuum; in fiber it’s slower (~200,000 km/s). London to California is ~8,700 km. The one-way minimum is 8,700 / 200,000 = ~43 ms. Round-trip: ~87 ms. Add TCP handshake, TLS, queuing — you’re at 200–250 ms per request. No code optimisation closes that gap. A CDN closes it by moving the content.

The warehouse metaphor

Imagine you publish a magazine. Without a CDN you mail every reader a copy from one print shop. With a CDN you ship pallets to local distribution centres in every city; each reader picks up a copy from their nearest one. Same magazine, far shorter trip. Each Point of Presence (PoP) is one of those warehouses — a data center with CDN servers.

One scenario end to end

Bea · Browser in London navigates to a CDN-fronted site:

  1. Browser does DNS — returns the IP of the nearest CDN edge server (either via Anycast routing or GeoDNS).
  2. TCP + TLS + HTTP request all happen against the edge, not the origin.
  3. Cache hit: edge has the page cached → response in ~20 ms.
  4. Cache miss: edge forwards to origin (or an intermediate shield), caches the answer, returns it.

Patty · Proxy / CDN edge in Tokyo asks the same URL and lands on the Tokyo edge with its own cached copy. Sven · Origin server , the origin server in California, sees one request from each city’s edge and almost no traffic from users directly.

Edge hit vs. origin round-trip
Origin (California → London) round-trip
~200–250 ms
Edge cache hit (London POP)
~10–20 ms
Speed-up factor on a cache hit
10–20×
Cloudflare edge POPs (2026)
330+ cities, 120+ countries
Typical cache hit ratio (static assets)
90–98%
Origin shield traffic absorption
90%+ of edge misses

When does a CDN NOT help?

A CDN helps when content can be shared across users — static assets (JS, CSS, images), HTML pages without user-specific data. It does not help when every response is unique (bank balance, personalised feed, checkout total) — there is nothing to cache, so the request still hits origin. The connection still terminates at the edge, which saves TLS setup latency, but the response must be fetched fresh each time.

Why this works

Why three mechanisms work together. Anycast IP routing (same address advertised from many cities) delivers requests to the BGP-nearest POP without any DNS special-casing. GeoDNS adds explicit control: the CDN operator returns different A records by resolver geography, so a London resolver gets a London edge IP. The edge cache then serves most requests without ever contacting the origin. All three cooperate: Anycast or GeoDNS finds the right edge; the cache does the heavy lifting.

Quiz

What is the main job of a CDN?

Quiz

When does a CDN NOT reduce latency?

Order the steps

Order what happens on a CDN cache HIT:

  1. 1 Browser DNS resolves to CDN edge IP via Anycast or GeoDNS
  2. 2 Browser opens TCP + TLS connection to the edge
  3. 3 Browser sends HTTP request
  4. 4 Edge looks up the URL in its cache and finds a fresh copy
  5. 5 Edge returns the cached response to the browser
Complete the analogy

Fill in the blank: a CDN is like a chain of _______ distributing your content so each user picks up from the closest one.

Recall before you leave
  1. 01
    In one sentence: what trade-off does a CDN ask you to accept in exchange for speed?
  2. 02
    Name the two mechanisms a CDN uses to route a user to the nearest edge server.
  3. 03
    Why does a CDN still help latency for personalised responses even though it cannot cache them?
Recap

A CDN (Content Delivery Network) replicates content to hundreds of edge Points of Presence (POPs) worldwide so users fetch from a server 20 ms away instead of 200 ms away. Anycast routing or GeoDNS directs each request to the nearest POP; the edge’s local cache serves it without contacting origin. A cache hit is 10–20× faster than an origin round-trip — the win comes entirely from proximity, not from faster hardware. CDNs help most for cacheable content (static assets: JS, CSS, images) and least for personalised responses where caching is impossible. The origin sees only a fraction of total traffic, typically under 10% for a well-configured static site.

Connected lessons
appears again in162
Continue the climb ↑Anycast and GeoDNS: routing to the nearest edge
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.