Lesson 10 of 16
26. CDNs

26.9 What happens when the CDN fails?

3 min read+10 XP

In the warehouse: If the warehouse chain goes on strike, every shop in the country is suddenly empty, even though the factory is fine. Big companies keep a second warehouse chain on contract, and a way to send shops straight to the factory in an emergency.

In the system: A CDN sits in front of everything, so its failures are your failures. On 8 June 2021, a valid configuration change by one Fastly customer triggered a latent software bug, and 85% of Fastly's network returned errors; many large news, government and shopping sites went down at once. Fastly detected it within a minute and had 95% of the network back to normal within 49 minutes. The sites' own servers were fine the whole time.

Kinds of trouble:

  • A whole-CDN or regional outage (software bug, bad config push, network problem).
  • A bad configuration of yours: a wrong caching rule caching private pages (Level 4), a broken redirect, a WAF rule blocking real users.
  • Origin overload after a purge-all or cold start, when every PoP misses at once.

Defences:

  • Serve stale on origin errors (stale-if-error) so an origin outage becomes "slightly old pages" instead of errors. In the chapter's code, the edge serves a stale book page while the origin is down, within its 600-second window.
  • Multi-CDN: two CDN providers, with DNS or traffic steering based on health checks. If one fails, send users to the other. It costs more and doubles the configuration to keep in sync.
  • An origin that can take a direct hit (for a while), or a "bypass" DNS record for emergencies, protected by its own rate limits (Chapter 25).
  • Treat CDN config as code: review, test in staging, roll out gradually, and keep a fast rollback.
  • Monitor from the user's side (real-user monitoring and synthetic checks from many regions, Chapter 30), not just your origin's health.

Memory code: "If the warehouses strike, have a second chain, and keep old stock you can still sell."