<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>RSS Feed for dns - James Stone&apos;s Blog</title><description>Blog posts tagged with dns</description><link>https://jamesst.one/</link><item><title>A free multi-CDN, jsDelivr style</title><link>https://jamesst.one/posts/free-multi-cdn/</link><guid isPermaLink="true">https://jamesst.one/posts/free-multi-cdn/</guid><description>import Detail from &quot;../../components/Detail.astro&quot;;
import anycast from &quot;../post_assets/free-multi-cdn-anycast.svg?url&quot;;
import diagram from &quot;../post_assets/free-multi-cdn.svg?url&quot;;
import twoUsers from &quot;../post_assets/free-multi-cdn-two-users.svg?url&quot;;
import twoSteps from &quot;../post_assets/free-multi-cdn-two-steps.svg?url&quot;;

&lt;span&gt;[jsDelivr](https://www.jsdelivr.com/network) does something I have always found neat: it does not use one CDN, it uses several, and for every user it picks whichever one is &lt;Detail&gt;&lt;span slot=&quot;c&quot;&gt;fastest for them.&lt;/span&gt;&lt;span slot=&quot;e&quot;&gt;fastest for them &lt;Detail&gt;&lt;span slot=&quot;c&quot;&gt;right now.&lt;/span&gt;&lt;span slot=&quot;e&quot;&gt;right now, based on RUM.&lt;/span&gt;&lt;/Detail&gt;&lt;/span&gt;&lt;/Detail&gt; I wanted to see how close I could get to that on free tiers only. Plus the vanity of it is kinda nice. How many people can say their site is served from &lt;Detail&gt;&lt;span slot=&quot;c&quot;&gt;~660&lt;/span&gt;&lt;span slot=&quot;e&quot;&gt;&lt;Detail&gt;&lt;span slot=&quot;c&quot;&gt;340+ Cloudflare, 210+ Gcore and 114 Fastly&lt;/span&gt;&lt;span slot=&quot;e&quot;&gt;&lt;a href=&quot;https://www.cloudflare.com/network/&quot;&gt;340+ Cloudflare&lt;/a&gt;, &lt;a href=&quot;https://gcore.com/cdn&quot;&gt;210+ Gcore&lt;/a&gt; and &lt;a href=&quot;https://www.fastly.com/network-map&quot;&gt;114 Fastly&lt;/a&gt;, as at Nov 2026&lt;/span&gt;&lt;/Detail&gt;&lt;/span&gt;&lt;/Detail&gt; data centers globally.&lt;/span&gt;

The experiment lives at [cdn.jamesst.one](https://cdn.jamesst.one), which now serves a copy of this site, and you can watch where it is routing at [rum.jamesst.one](https://rum.jamesst.one).

## How a normal CDN works

&lt;span&gt;A plain server has one IP address in one place, so every visitor&apos;s packets travel all the way to it. A CDN instead announces the *same* IP address &lt;Detail&gt;&lt;span slot=&quot;c&quot;&gt;from hundreds of locations,&lt;/span&gt;&lt;span slot=&quot;e&quot;&gt;from hundreds of locations at once (this is called anycast: one address, many machines, and the network decides which one you reach),&lt;/span&gt;&lt;/Detail&gt; and internet routing (BGP) delivers each visitor to the nearest one. That location serves a cached copy, and only goes back to the origin on a cache miss. For example, `151.101.1.242`, one of Fastly&apos;s addresses this site uses, answers in 0.6 to 2 ms from Globalping probes in Copenhagen, Singapore and Melbourne alike. No single machine can be that close to all three.&lt;/span&gt;

{
/*
```mermaid
flowchart LR
    subgraph anycast[&quot;CDN, one anycast IP&quot;]
        direction LR
        A1([Copenhagen]) --&gt;|short hop| P1[&quot;Copenhagen PoP&lt;br/&gt;151.101.1.242&quot;]
        A2([Singapore]) --&gt;|short hop| P2[&quot;Singapore PoP&lt;br/&gt;151.101.1.242&quot;]
        A3([Melbourne]) --&gt;|short hop| P3[&quot;Melbourne PoP&lt;br/&gt;151.101.1.242&quot;]
        P1 &amp; P2 &amp; P3 -.-&gt;|&quot;cache miss only&quot;| OR[(&quot;Origin&quot;)]
    end
    subgraph single[&quot;One server, one IP&quot;]
        direction LR
        S1([Copenhagen]) --&gt;|&quot;long way&quot;| SV[&quot;203.0.113.10&lt;br/&gt;one server, Singapore&quot;]
        S2([Singapore]) --&gt;|&quot;close by&quot;| SV
        S3([Melbourne]) --&gt;|&quot;long way&quot;| SV
    end
```
*/
}
&lt;a href={anycast} title=&quot;Open the diagram full size&quot;&gt;&lt;img src={anycast} width=&quot;868&quot; height=&quot;790&quot; alt=&quot;Top: one server with one IP in Singapore; a visitor in Singapore is close by, visitors in Copenhagen and Melbourne travel the long way. Bottom: a CDN announces one anycast IP, 151.101.1.242, from PoPs in Copenhagen, Singapore and Melbourne; each visitor takes a short hop to the nearest PoP, which only goes back to the origin on a cache miss.&quot; /&gt;&lt;/a&gt;

The above diagram is actually a simplification, because before that, a client first has to look up the IP address to connect to, i.e. DNS. A multi-CDN hooks into the DNS reply and picks which CDN is best, then that CDN&apos;s anycast picks which specific data center based on network routing rules.

{
/*
```mermaid
flowchart LR
    V1([&quot;Melbourne visitor&quot;]) --&gt;|&quot;cdn.jamesst.one?&quot;| DNS[&quot;Gcore DNS&lt;br/&gt;step 1: which CDN?&quot;]
    V2([&quot;Copenhagen visitor&quot;]) --&gt;|&quot;cdn.jamesst.one?&quot;| DNS
    DNS --&gt;|&quot;e.g. Australia → Fastly&quot;| FA
    DNS --&gt;|&quot;e.g. Europe → Cloudflare&quot;| CF
    subgraph FA[&quot;Fastly anycast · step 2: which PoP?&quot;]
        direction TB
        FS[&quot;Melbourne PoP&quot;]
        FL[&quot;Copenhagen PoP&quot;]
    end
    subgraph CF[&quot;Cloudflare anycast · step 2: which PoP?&quot;]
        direction TB
        CS[&quot;Melbourne PoP&quot;]
        CL[&quot;Copenhagen PoP&quot;]
    end
    V1 -.-&gt;|&quot;nearest Fastly PoP&quot;| FS
    V2 -.-&gt;|&quot;nearest Cloudflare PoP&quot;| CL
```
*/
}
&lt;a href={twoSteps} title=&quot;Open the diagram full size&quot;&gt;&lt;img src={twoSteps} width=&quot;1204&quot; height=&quot;546&quot; alt=&quot;A Melbourne visitor and a Copenhagen visitor both ask Gcore DNS for cdn.jamesst.one. Step 1, DNS picks the CDN: for example Australia gets Fastly and Europe gets Cloudflare. Step 2, that CDN&apos;s anycast routes each visitor to its nearest PoP: the Melbourne visitor to Fastly&apos;s Melbourne PoP, the Copenhagen visitor to Cloudflare&apos;s Copenhagen PoP.&quot; /&gt;&lt;/a&gt;

## How it fits together

The CDN is chosen in DNS. When your resolver asks for `cdn.jamesst.one`, the answer is a CNAME to one of three CDNs, and which one depends on where you are. Or, more accurately, the network you are on.

{
/*
```mermaid
flowchart LR
    V([Visitor]) --&gt;|&quot;1 · cdn.jamesst.one?&quot;| DNS[&quot;Gcore DNS&lt;br/&gt;dynamic record&quot;]
    DNS --&gt;|&quot;2 · CNAME&quot;| CDNS
    subgraph CDNS[&quot;three CDNs&quot;]
        direction TB
        F[Fastly]
        G[Gcore CDN]
        C[Cloudflare Pages]
    end
    CDNS --&gt;|&quot;3 · cache miss&quot;| O[(&quot;Origin&lt;br/&gt;Singapore&quot;)]

    GP([&quot;Globalping&lt;br/&gt;probes&quot;]) -.-&gt;|&quot;ping every 5 min&quot;| CDNS
    GP -.-&gt;|&quot;RTTs&quot;| R[&quot;rumd&lt;br/&gt;scores CDNs&quot;]
    R -.-&gt;|&quot;recommends&quot;| D[dnsctl]
    D -.-&gt;|&quot;updates&quot;| DNS
```
*/
}
&lt;a href={diagram} title=&quot;Open the diagram full size&quot;&gt;&lt;img src={diagram} width=&quot;1917&quot; height=&quot;307&quot; alt=&quot;A visitor asks Gcore DNS for cdn.jamesst.one and gets a CNAME to Fastly, Gcore CDN or Cloudflare Pages, which fetch from the origin in Singapore on a cache miss. Globalping probes ping all three CDNs every 5 minutes; rumd scores them and dnsctl updates the DNS record.&quot; /&gt;&lt;/a&gt;

- **DNS:** [Gcore Managed DNS](https://gcore.com/dns). Its free plan supports &quot;dynamic&quot; records: a set of answers with metadata (countries, continents, networks) and pickers that choose one per query.
- **The CDNs:** Fastly, Gcore CDN and Cloudflare Pages. All three pull from the same origin and add the same response headers, plus a `Server-Timing: cdn;desc=&quot;fastly&quot;` style header so every measurement knows who served it.
- &lt;span&gt;**&lt;Detail&gt;&lt;span slot=&quot;c&quot;&gt;rumd:&lt;/span&gt;&lt;span slot=&quot;e&quot;&gt;rumd, the RUM daemon, as in Real User Monitoring:&lt;/span&gt;&lt;/Detail&gt;** a small Go service that collects measurements, scores each CDN per country, continent and network, and recommends a routing policy.&lt;/span&gt;
- **dnsctl:** applies that recommendation to Gcore, but only once it has been stable for a few checks and a minimum interval has passed, so DNS does not flap.

## The free tier gotchas

| Thing | What I hit |
|---|---|
| Cloudflare | The free plan only proxies a domain if Cloudflare hosts its DNS. Cloudflare for SaaS (custom hostnames) works with outside DNS, but needs a *root* domain zone in your account, and I wanted DNS to stay on Gcore. **Cloudflare Pages** saved the day: a Pages project accepts a subdomain on someone else&apos;s DNS as a custom domain. A tiny Worker in the project proxies to the origin and adds the headers. |
| Gcore DNS | One dynamic record set, at most **three** records, minimum TTL 120s. So at most three CDNs can be live at once. (I checked: a fourth record is refused.) |
| Certificates | Every CDN has to prove it controls `cdn.jamesst.one`. Fastly uses a DNS challenge, but Gcore and Cloudflare Pages validate over HTTP, which only works while DNS sends the validator to *them*. The first certificate meant pointing DNS at Pages for a few seconds. Renewals are a problem I have not fully solved. |
| Cloudflare Pages | Pages custom domains are built on Cloudflare for SaaS, which marks a hostname as &quot;moved&quot; once it stops pointing at Cloudflare and deletes it after a week. If Pages does the same, a multi-CDN setup is in trouble, since it points elsewhere most of the time... still watching this one. |

## Measuring without JavaScript

The first version used a small script on the page that read [Resource Timing](https://developer.mozilla.org/en-US/docs/Web/API/Resource_Timing_API) entries and beaconed them home. It worked, but I would rather not put JS on pages for this. jsDelivr itself gets its RUM data from elsewhere: it used Cedexis, then [PerfOps](https://perfops.net/blog/jsdelivr-now-handling-all-load-balancing-with-flexbalancer/), rather than running a script of its own.

&lt;span&gt;[Network Error Logging](https://developer.mozilla.org/en-US/docs/Web/HTTP/Network_Error_Logging) turned out to be a nice alternative. Each CDN sends a &lt;Detail&gt;&lt;span slot=&quot;c&quot;&gt;&lt;code&gt;NEL&lt;/code&gt;&lt;/span&gt;&lt;span slot=&quot;e&quot;&gt;&lt;code&gt;NEL&lt;/code&gt; (Network Error Logging)&lt;/span&gt;&lt;/Detail&gt; header with `success_fraction: 1`, and Chromium browsers then report *every* request, not just failures, including how long it took. Two catches:&lt;/span&gt;

- A NEL report has no custom headers, only the server IP, so attribution is by each CDN&apos;s IP ranges. Gcore publishes an IP list, but it turned out to be the addresses it uses to fetch from the origin, not the edges visitors connect to. Using the prefixes its network announces fixed it.
- Only Chromium browsers send NEL.

## Measuring without traffic

&lt;span&gt;The real problem: it is an experiment, nobody is going to visit `cdn.jamesst.one`. So I used jsDelivr&apos;s other project, [Globalping](https://globalping.io), a network of community-run probes you can ask to run measurements for free.&lt;/span&gt;

Every 5 minutes a job picks 10 probes randomly from around the world and pings each CDN&apos;s edge from them (TCP to port 443). Cloudflare is pinged first, and Fastly and Gcore reuse its probes, so every round compares the CDNs from exactly the same places. Routing now uses these pings rather than actual RUM page loads - so it&apos;s not as ideal as it could be.

## What it looks like from real networks

Here is one [Globalping HTTP measurement](https://globalping.io/?measurement=2OqfXU1hYpujYMV5O00121ZMh): `GET /blog` on `cdn.jamesst.one`, through normal DNS, from 12 probes on home broadband and mobile networks (25 Nov 2026, 14:27 UTC). Every request returned 200, and DNS had split the world three ways: most of Europe got Cloudflare Pages, Asia and North America got Gcore, and South America, Australia and Hamburg, Germany got Fastly.

| Location | Network | Served by | Cache | DNS lookup | First byte | Total |
|---|---|---|---|---|---|---|
| London, GB | British Telecommunications | Cloudflare Pages | HIT | 0 ms | 103 ms | 141 ms |
| Vienna, AT | T-Mobile | Cloudflare Pages | HIT | 1 ms | 70 ms | 110 ms |
| Düsseldorf, DE | Vodafone | Cloudflare Pages | HIT | 1 ms | 137 ms | 207 ms |
| Chicago, US | Comcast | Gcore | – | 31 ms | 23 ms | 100 ms |
| Kuala Lumpur, MY | TM Technology Services | Gcore | – | 292 ms | 34 ms | 396 ms |
| Taipei, TW | Data Communication Business Group | Gcore | – | 74 ms | 33 ms | 164 ms |
| Calgary, CA | Shaw Communications | Gcore | – | 631 ms | 50 ms | 803 ms |
| Hamburg, DE | Deutsche Telekom | Fastly | HIT | 7 ms | 202 ms | 267 ms |
| Brisbane, AU | Aussie Fibre | Fastly | HIT | 0 ms | 229 ms | 253 ms |
| Melbourne, AU | Aussie Fibre | Fastly | HIT | 1 ms | 266 ms | 281 ms |
| Santiago, CL | Telefónica Empresas Chile | Fastly | HIT | 1 ms | 193 ms | 208 ms |
| São Paulo, BR | Telefónica | Fastly | HIT | 250 ms | 43 ms | 307 ms |

&quot;Served by&quot; comes from the `Server-Timing` header each CDN adds, and Gcore does not report cache hits, hence the dashes. This was the second run from the same probes, two minutes after the first: on that first run every Fastly request was a cache miss that went all the way back to the origin in Singapore, taking 1.5 to 2.7 seconds, and most DNS lookups were slower because the resolvers had nothing cached yet. Hamburg and Düsseldorf landing on different CDNs is the DNS working per network: Gcore answers based on where the resolver appears to be, not the probe.

Two things stand out. Düsseldorf on Cloudflare (207 ms) beat Hamburg on Fastly (267 ms), and Fastly&apos;s cache *hits* took 190–270 ms to the first byte in Hamburg, Brisbane, Melbourne and Santiago (São Paulo: 43 ms). Fastly&apos;s own `X-Timer` header puts that time inside Fastly&apos;s edge, not on the network, and I haven&apos;t worked out why yet.

It also shows the limit of routing on pings: they measure how close each CDN&apos;s edge is (all within a couple of ms here), not how fast it answers an HTTP request.

Both are in Germany, so why the split? Gcore never sees the visitor, only the DNS resolver asking on their behalf (and the visitor&apos;s subnet, if the resolver passes it on). At the time the record sent Germany to Fastly and the rest of Europe to Cloudflare Pages. Telekom&apos;s resolver was placed in Germany; the Vodafone resolver the Düsseldorf probe used evidently was not, so it fell through to the Europe rule. Asking Gcore directly with German Vodafone and Telekom subnets both return Fastly, so it is the resolver, not the network:

{
/*
```mermaid
flowchart LR
    H([&quot;Hamburg&lt;br/&gt;Deutsche Telekom&quot;]) --&gt; RT[&quot;Telekom&apos;s&lt;br/&gt;DNS resolver&quot;]
    D([&quot;Düsseldorf&lt;br/&gt;Vodafone&quot;]) --&gt; RV[&quot;Vodafone&apos;s&lt;br/&gt;DNS resolver&quot;]
    RT --&gt;|&quot;cdn.jamesst.one?&quot;| DNS[&quot;Gcore DNS&lt;br/&gt;dynamic record&quot;]
    RV --&gt;|&quot;cdn.jamesst.one?&quot;| DNS
    DNS --&gt;|&quot;resolver placed in Germany&lt;br/&gt;rule: country DE&quot;| F[&quot;Fastly&quot;]
    DNS --&gt;|&quot;resolver not placed in Germany&lt;br/&gt;rule: continent EU&quot;| C[&quot;Cloudflare Pages&quot;]
    H -.-&gt;|&quot;GET /blog · 267 ms&quot;| F
    D -.-&gt;|&quot;GET /blog · 207 ms&quot;| C
```
*/
}
&lt;a href={twoUsers} title=&quot;Open the diagram full size&quot;&gt;&lt;img src={twoUsers} width=&quot;1217&quot; height=&quot;272&quot; alt=&quot;Two visitors in Germany. Each asks its own network&apos;s DNS resolver for cdn.jamesst.one, and the resolver asks Gcore DNS. Telekom&apos;s resolver is placed in Germany, matches the country DE rule and gets Fastly (GET /blog in 267 ms). Vodafone&apos;s resolver is not placed in Germany, falls through to the continent EU rule and gets Cloudflare Pages (207 ms).&quot; /&gt;&lt;/a&gt;

## Caching HTML on three CDNs

Each CDN reads a different header to decide how long to keep a page:

| CDN | Header it listens to |
|---|---|
| Fastly | `Surrogate-Control` (and strips it before it reaches you) |
| Cloudflare | `CDN-Cache-Control` |
| Gcore | its own rules; it ignored `s-maxage` next to `max-age=0` |

So the origin sends all of them: an hour for the home page, blog list and tags, six hours for everything else, while browsers still revalidate every time.

## A bonus: routing around outages

If a [CDN](https://www.thousandeyes.com/blog/inside-the-fastly-outage-analysis-and-lessons-learned) goes [down](https://blog.cloudflare.com/cloudflare-service-outage-june-12-2025/), a multi-CDN routes around it by updating DNS. Here a probe checks each CDN every 30 seconds, and after three failures in a row dnsctl takes it out of the DNS answers. Resolvers may keep the old answer for up to two minutes, so the switch takes a few minutes, with nobody having to wake up.</description><pubDate>Sat, 28 Nov 2026 00:00:00 GMT</pubDate></item></channel></rss>