This article details Cloudflare's migration of cdnjs, a massive open-source CDN, to its internal Developer Platform. It serves as a practical case study, highlighting the architectural challenges of an aging system, the pain points encountered (observability, split-brain storage, pipeline orchestration), and the design decisions made to build a more robust, scalable, and observable solution using various Cloudflare services.
Read original on Cloudflare Blogcdnjs is one of the internet's busiest open-source CDNs, serving 9 billion requests daily across over 330 Cloudflare data centers with a 98.6% cache hit rate. Its immutability and hash-verified nature make it crucial for supply-chain security, particularly for AI models that rely on its consistent URLs. The migration wasn't driven by performance issues, but by internal difficulties in maintaining, updating, and debugging the existing architecture.
The previous cdnjs architecture, partially migrated to serverless in 2020 for serving, still relied heavily on Google Cloud Platform (GCP) for its publishing pipeline. This hybrid setup led to significant operational pain points and architectural limitations, particularly as Cloudflare's Developer Platform matured.
The redesigned architecture leverages Cloudflare's Developer Platform extensively to address the legacy system's limitations, focusing on unified storage, durable execution, and improved observability. This migration allowed for the deprecation of multiple GCP services and a reduction in the attack surface.
Migration Lessons Learned
A crucial lesson from a previous failed attempt was the non-deterministic nature of minifiers and compressors across versions. Regenerating old packages resulted in different SRI hashes, which would break user-pinned dependencies. The successful migration involved copying existing content from KV to R2 as-is, preserving hashes, rather than reprocessing.