Build your own CDN
A small content delivery network on your laptop: nginx and Lua edge caches in front of an origin, with cache keys, load balancing and metrics.
- Advanced
- About 10–20 h
- 5 checkpoints
- 1 tutorial · Lua
Pick a tutorial, then check yourself at each checkpoint. Work in any language you like.
Choose a tutorialWhy build it
A CDN is a cache with geography. Building one with containers shows how cache keys, TTLs and the thundering-herd problem drive latency and origin load.
You will be able to
- Configure edge caching with TTLs and cache keys.
- Measure hit ratio, latency percentiles and origin load.
- Protect the origin from a thundering herd with request coalescing.
- Spread objects across edges with consistent hashing.
Skills it exercises
Recommended on System Design.
How you know you are there
Work in any language. Each checkpoint ends with something you can run or observe, so you can check it yourself.
- Checkpoint 1Self-check
Origin and edge
Done when: An edge in front of the origin serves repeat requests from cache, and a response header shows HIT or MISS.
- Checkpoint 2Self-check
Cache control
Done when: The edge honours the origin's Cache-Control max-age, and normalising the cache key (for example dropping tracking parameters) raises the hit ratio in a test.
- Checkpoint 3Self-check
Metrics
Done when: A dashboard or log summary shows hit ratio, latency percentiles and origin requests during a load test.
- Checkpoint 4Self-check
Origin protection
Done when: With request coalescing, 100 simultaneous requests for an expired object cause a single origin request.
- Checkpoint 5Self-check
Several edges
Done when: Two or more edges sit behind a balancer that uses consistent hashing, so each object is cached on one edge.
Stretch goals
- Purge by URL or tag.
- Serve stale content while revalidating.
Step-by-step guides
Pick one in a language you know (tutorial languages: Lua). They open on the author’s site.
- Lua
Building a CDN from Scratch to Learn about CDN(external site)
nginx, Lua and Docker Compose, with Prometheus and Grafana to measure every step.
Practice builds are self-paced: Tech Atlas does not track them or count them as evidence. To show a skill, take its knowledge check from the skill page.
Tutorials come from codecrafters-io/build-your-own-x (CC0, snapshot of 2026-07-14, commit aa17439; links checked on 2026-10-19). Each tutorial belongs to its author and keeps its own licence; Tech Atlas links to it and does not host it. Briefs, checkpoints and the mapping to skills are Tech Atlas editorial drafts.