A free multi-CDN, jsDelivr style

post 1727 words #webdev #cdn #dns
jsDelivr 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
fastest for them.fastest for them
right now.right now, based on RUM.
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
~660
340+ Cloudflare, 210+ Gcore and 114 Fastly340+ Cloudflare, 210+ Gcore and 114 Fastly, as at Nov 2026
data centers globally.

The experiment lives at cdn.jamesst.one, which now serves a copy of this site, and you can watch where it is routing at rum.jamesst.one.

How a normal CDN works

A plain server has one IP address in one place, so every visitor’s packets travel all the way to it. A CDN instead announces the same IP address
from hundreds of locations,from hundreds of locations at once (this is called anycast: one address, many machines, and the network decides which one you reach),
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’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.
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.

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’s anycast picks which specific data center based on network routing rules.

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's anycast routes each visitor to its nearest PoP: the Melbourne visitor to Fastly's Melbourne PoP, the Copenhagen visitor to Cloudflare's Copenhagen PoP.

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.

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.

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’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 “moved” 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 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, rather than running a script of its own.

Network Error Logging turned out to be a nice alternative. Each CDN sends a
NELNEL (Network Error Logging)
header with success_fraction: 1, and Chromium browsers then report every request, not just failures, including how long it took. Two catches:

Measuring without traffic

The real problem: it is an experiment, nobody is going to visit cdn.jamesst.one. So I used jsDelivr’s other project, Globalping, a network of community-run probes you can ask to run measurements for free.

Every 5 minutes a job picks 10 probes randomly from around the world and pings each CDN’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’s not as ideal as it could be.

What it looks like from real networks

Here is one Globalping HTTP measurement: 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

“Served by” 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’s cache hits took 190–270 ms to the first byte in Hamburg, Brisbane, Melbourne and Santiago (São Paulo: 43 ms). Fastly’s own X-Timer header puts that time inside Fastly’s edge, not on the network, and I haven’t worked out why yet.

It also shows the limit of routing on pings: they measure how close each CDN’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’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’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:

Two visitors in Germany. Each asks its own network's DNS resolver for cdn.jamesst.one, and the resolver asks Gcore DNS. Telekom's resolver is placed in Germany, matches the country DE rule and gets Fastly (GET /blog in 267 ms). Vodafone's resolver is not placed in Germany, falls through to the continent EU rule and gets Cloudflare Pages (207 ms).

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 goes down, 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.