finds.dev

leandromoreira/cdn-up-and-running

CDN Up and Running - Building a CDN from Scratch to Learn about CDN, Nginx, Lua, Prometheus, Grafana, Load balancing, and Containers.

View on GitHub

★ 3,685LuaBSD-3-Clauseupdated Jan 2026

// the take

A hands-on tutorial that walks you through building a CDN from scratch using OpenResty (Nginx + LuaJIT), starting from a single backend node and progressively adding caching, metrics, load balancing, and multi-node routing. It's aimed at developers who want to understand what a CDN actually does internally rather than just consuming one as a black box.

The incremental git-tag structure (1.0.0 → 4.0.1) is genuinely good pedagogy — you can check out each version, run docker-compose, and see exactly what changed and why. The load testing loop with wrk and real Grafana dashboards gives you measurable feedback instead of hand-waving about performance. The cache key discussion is honest about the tradeoffs (uri-only keys collide across hostnames). The consistent hashing vs round-robin comparison is concrete, not theoretical — actual numbers from actual runs.

The whole thing stops before TLS, which is a gaping hole for anyone trying to apply this in a real environment — nginx TLS configuration is non-trivial and it's not even flagged as out of scope until a brief mention at the end. The Lua code is minimal and unstructured; someone learning Lua from this will pick up habits (no error handling, global state) that would be a problem in production OpenResty. The grafana.db is committed to the repo, which is a bad habit to normalize. The miscellaneous section lists a dozen important CDN concerns (purging, geoblocking, token auth, DDoS) as bullet points with no code — it reads like a table of contents for a book that doesn't exist.

We read the README, the directory tree and a key source file in July 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
3,685
Forks
238
Language
Lua
License
BSD-3-Clause
Last commit
21 Jan 2026

// nearby

If cdn-up-and-running isn't quite it.

All repos →