CDNs and the edge

Play this lesson

Halfway around the world

Shard Garden's servers are in Europe. Kai hears from players in Sydney: every image and page travels halfway around the world and back while they wait.

A CDN (content delivery network) keeps copies in data centres all over the world. Cloudflare's docs say its cache stores copies in data centres "located closer to end users than origin servers". The origin is our own server.

Light is not fast enough

Even light in a glass fibre covers only about 200 km every millisecond. Halfway around the Earth is about 20,000 km, so a trip there and back takes at least 200 ms before any server does any work.

No code can beat that. The only fix is a shorter trip: an answer from a data centre nearby.

Quick check

Why does a CDN make the garden page faster in Sydney?

  1. The copy comes from a nearby data centre, so the data travels a short distance
  2. CDNs make light travel faster
  3. It makes the page smaller
Show the answer

The copy comes from a nearby data centre, so the data travels a short distance

Distance sets a minimum time. Serving a copy from nearby removes most of the trip.

Code at the edge

The data centres where a CDN serves players are called the edge. Platforms like Cloudflare Workers, which the studio uses, also run code there, across Cloudflare's global network.

Edge code can check a sign-in token or pick the nearest match server before a request ever reaches Europe.

What stays at the origin

A player's private save, or a price that differs per player, must not be served from a shared copy. The server says so with headers: Cache-Control: private tells shared caches not to keep it.

Quick check

Every request a CDN handles must still go to the origin server.

Show the answer

False

A cache hit is answered at the edge. Only misses, and private requests, travel to the origin.

Read the numbers

Garden page, players in Sydney
Origin (Europe)      310 msEdge (Sydney)         25 msCache hit ratio         92%

Priya reads the CDN's numbers. What does a 92% cache hit ratio mean?

  1. 92 of every 100 requests were answered at the edge without asking the origin
  2. The page is 92% faster
  3. 92% of players are in Sydney
Show the answer

92 of every 100 requests were answered at the edge without asking the origin

The hit ratio is the share of requests answered from the cache. The other 8 in 100 went to Europe and took the slow trip.

Back at the database

Caches answer repeated questions. New questions still reach the database, and some of them are slow.

Bolt says: Next: database indexes.

Fact-checked 12 October 2026