What is a CDN? Content Delivery Networks Explained
A Content Delivery Network (CDN) is a geographically distributed network of servers that delivers web content from locations close to end users. CDNs reduce latency, improve load times, and absorb traffic spikes by caching content at the network edge — often within the same city as the user, rather than serving everything from a central origin server that might be thousands of miles away.
The Problem CDNs Solve
Without a CDN, every user who visits a website hits the same origin server. A startup based in New York serving users in Tokyo, Nairobi, and São Paulo imposes intercontinental round-trip latency on every request. A 200ms round trip across the Pacific means a simple page with 20 requests stacks up to seconds of latency, and that is before any content is actually downloaded.
TCP's congestion control behavior makes this worse: the slow-start phase requires multiple round trips to ramp up to full throughput. Across a 150ms intercontinental path, reaching 10 Mbps throughput from slow start takes several seconds. A CDN edge node 5ms away reaches the same throughput in milliseconds.
How CDNs Route Users to the Edge
CDNs use two primary mechanisms to direct users to nearby edge nodes:
- DNS-based routing — The CDN operates its own authoritative DNS servers. When a user resolves the CDN's hostname, the DNS server returns a different IP address based on the user's location (inferred from the resolver's IP). This is the classic approach used by Akamai and AWS CloudFront.
- Anycast routing — The same IP address is announced via BGP from all CDN edge locations simultaneously. BGP's path selection naturally routes each user to the topologically nearest instance of the anycast address. Cloudflare uses this approach for nearly all services: 1.1.1.1 is the same IP in 300+ cities.
Anycast is simpler from the client's perspective — the IP address is stable, DNS TTL games are unnecessary — but it places more weight on peering relationships to ensure "nearest" in BGP terms correlates with "nearest" in geographic terms.
What CDNs Cache
CDN edge nodes cache content based on HTTP caching headers sent by the origin server:
- Static assets — JavaScript, CSS, images, fonts, and video segments. These change infrequently and are ideal for long cache TTLs.
- HTML pages — Cacheable for short TTLs when content is not user-specific.
- API responses — Cacheable when responses are shared across users and marked with appropriate headers (
Cache-Control: public, max-age=60). - Streaming video — CDNs cache video segments (HLS/DASH chunks) at the edge, enabling efficient large-scale video delivery.
Content that cannot be cached — authenticated pages, shopping carts, user-specific API responses — is proxied to the origin on every request. Even then, the CDN's TCP connection to the origin is maintained as a persistent pool (avoiding handshake overhead), and the user-to-edge leg benefits from low latency.
CDN as DDoS Protection
A CDN's distributed architecture provides inherent resistance to distributed denial-of-service attacks. Attack traffic directed at an anycast CDN address is automatically spread across all edge nodes worldwide. A 1 Tbps attack absorbed by a CDN with 300 PoPs averages ~3 Gbps per location — manageable for a large network.
Beyond volume distribution, CDNs operate at the TCP layer: they terminate connections from clients at the edge and proxy valid requests to the origin. This means:
- SYN floods never reach the origin server
- Application-layer attacks (HTTP floods) can be rate-limited at the edge before hitting origin
- The origin's IP address is not publicly known, so attackers cannot bypass the CDN by targeting it directly
CDN Peering Strategy
CDN performance depends heavily on peering strategy. To be "close" to every user in BGP terms, a CDN must peer directly with the user's ISP or be present at an IXP where that ISP is also connected. This minimizes the number of AS hops — and therefore latency — between the CDN edge and the end user.
Cloudflare (AS13335) is the most extreme example: it peers at over 300 IXPs and has direct private peering with most major ISPs globally. When you look up AS13335, you see hundreds of peer relationships and extremely short AS paths.
Akamai (AS20940) takes a different approach: it embeds caching servers directly inside ISP networks under commercial agreements, so traffic served by Akamai may not even traverse the ISP's peering fabric at all — it comes straight from a server inside the ISP's own data center.
Major CDN Providers
| Provider | ASN | Key approach |
|---|---|---|
| Cloudflare | AS13335 | Anycast, 300+ PoPs, aggressive IXP peering |
| Akamai | AS20940 | ISP-embedded servers, oldest CDN |
| Fastly | AS54113 | Programmable edge, Varnish-based caching |
| Amazon CloudFront | AS16509 | AWS-integrated, 400+ PoPs |
| Google Cloud CDN | AS15169 | Integrated with GCP, Google's own backbone |
CDNs and the BGP Routing Table
CDN providers announce hundreds to thousands of prefixes from their autonomous systems. Because they use anycast, the same prefix may appear to be reachable via many different paths from different vantage points — each path actually leads to a different physical edge node serving the same IP address.