CDN
A globally distributed network of edge servers (PoPs) that caches and delivers web assets from locations physically closest to each user
Table of Contents
Structure Diagram
What is CDN?
A globally distributed network of edge servers (PoPs) that caches and delivers web assets from locations physically closest to each user. It is a core concept in Traffic & Scaling within Cloud / DevOps.
Core Principles
Physics sets a hard floor on latency: a user in New York talking directly to an origin server in Seoul spends 180–250ms per round trip just crossing oceans. A CDN (Content Delivery Network) places caching Edge Points of Presence (PoPs) in hundreds of cities worldwide and uses Anycast routing to connect every user to the nearest edge node.
When a requested asset—images, JS bundles, video chunks, or cacheable HTML—is already stored at the edge (Cache HIT), it returns in 10–30ms without touching the origin. On a Cache MISS, the edge fetches it once from the origin and serves subsequent users locally, simultaneously speeding up page loads, slashing origin bandwidth bills, and absorbing DDoS floods.
Practical Takeaways
- Pair hashed asset filenames with
immutablecaching: Stamp build artifacts (app.a1b2c3.js) with content hashes and serveCache-Control: public, max-age=31536000, immutable. For dynamic HTML or API responses, uses-maxagewithstale-while-revalidateto balance freshness and speed. - Keep your Cache Hit Ratio high: Strip marketing query params (
utm_*,fbclid) from CDN cache keys and never attach user-specific cookies to static assets, or every visitor will bypass the cache. - Prevent origin stampedes: Enable Origin Shield (tiered caching) so hundreds of global PoPs coalesce cache misses through a single regional shield instead of slamming your origin database simultaneously, and use tag-based purging for instant content updates.
Notable Examples
- Cloudflare, AWS CloudFront, Fastly, and Akamai: Global edge networks combining asset caching, TLS termination, WAF/DDoS protection, and Edge Compute.
- Video streaming (Netflix Open Connect, YouTube): Placing media caches directly inside regional ISPs to stream 4K video without saturating internet backbones.
- Global web apps & e-commerce: Serving ISR pages and on-the-fly WebP/AVIF image resizing at the edge to keep Largest Contentful Paint (LCP) fast worldwide.