CDN
A network of servers distributed globally that caches content close to users. Netflix uses CDNs to stream video from servers near you, not from one central location.
What is CDN?
In short
A CDN (Content Delivery Network) is a globally distributed group of servers that store copies of your content close to users, so a request is answered by a nearby server instead of traveling all the way to your origin. By serving cached files from the nearest edge location, a CDN cuts latency, reduces load on your origin servers, and keeps sites fast and available even under heavy traffic.
What a CDN actually is
A CDN is a network of servers placed in data centers around the world, often called edge locations or points of presence (PoPs). Each edge server keeps cached copies of content that originally lives on your own server, which the CDN calls the origin.
When someone in Tokyo loads your website, they do not pull every image and script from your server in Virginia. The CDN routes them to a nearby edge server, maybe in Tokyo or Osaka, that already holds those files. The data travels a few hundred kilometers instead of crossing the Pacific, so the page loads faster.
Large CDNs are huge. Cloudflare advertises a presence in over 300 cities. Akamai runs hundreds of thousands of servers across thousands of locations. The point of all that hardware is simple: keep a copy of your content physically close to as many people as possible.
How it works under the hood
Two pieces do the heavy lifting: request routing and caching. When a user requests a file, the CDN uses DNS or anycast routing to send them to the closest healthy edge server, usually measured by network distance rather than raw geography.
On the first request for a file, the edge server does not have it yet. This is a cache miss. The edge fetches the file from your origin, sends it to the user, and stores a copy. Every later request for that file from that region is a cache hit, served directly from the edge with no trip back to origin.
How long a file stays cached is controlled by HTTP headers, mainly Cache-Control and the file's TTL (time to live). A logo with a one year TTL almost never hits your origin again. When you ship a new version, you either change the filename or send a purge command that tells edge servers to drop the old copy.
CDNs were built for static content like images, CSS, JavaScript, fonts, and video segments. Modern ones also do more: terminating TLS, compressing responses, blocking DDoS attacks, and running code at the edge with platforms like Cloudflare Workers or AWS Lambda@Edge.
When to use one and the trade-offs
Reach for a CDN any time you serve the same files to many users in different places: a marketing site, a video platform, an app's static assets, or software downloads. The bigger your geographic spread, the bigger the win. A site whose users are all in one city sees far less benefit.
The main trade-off is staleness. Aggressive caching means an edge server can keep serving an old file after you have updated the origin. You manage this with sensible TTLs, versioned filenames, and cache purges, but a misconfigured cache can show users yesterday's content or, worse, leak a private response to the wrong person.
CDNs are weaker for content that is unique per user or changes every second, like a personalized dashboard or live stock prices. You can still route those requests through the CDN for TLS and DDoS protection, but you usually mark them as uncacheable so they pass straight to origin.
Other costs to weigh: most CDNs bill per gigabyte of egress and per request, debugging gets harder because a cached bug can persist after a deploy, and you are trusting a third party with your traffic. For the vast majority of public web content, the latency and reliability gains are worth it.
A concrete example: Netflix Open Connect
Netflix is the textbook case. Instead of streaming every movie from a central data center, Netflix built its own CDN called Open Connect and places storage appliances, called OCAs, directly inside internet service provider networks and at internet exchange points.
Each appliance is preloaded overnight with the shows most likely to be watched in that region. When you press play, the video streams from an OCA that might be in the same building as your ISP, often just one network hop away. That is why a 4K stream starts in a second or two without buffering.
This design saves enormous bandwidth. Netflix can account for a large share of evening internet traffic in many countries, and Open Connect keeps that traffic off expensive long haul links by serving it locally. It is the same core idea as Cloudflare or Akamai, just owned and tuned end to end by one company for one workload.
Where it is used in production
Netflix Open Connect
Netflix's own CDN; storage appliances sit inside ISP networks and stream video from a hop or two away.
Cloudflare
Runs edge servers in 300+ cities, serving cached content plus TLS, DDoS protection, and edge compute via Workers.
Amazon CloudFront
AWS's CDN with hundreds of edge locations; commonly fronts S3 buckets and origin servers for static assets and video.
Akamai
One of the oldest and largest CDNs, with hundreds of thousands of servers delivering web, software, and media at global scale.
Frequently asked questions
- What is the difference between a CDN and a web server?
- A web server (the origin) holds the original, authoritative copy of your content and runs your application. A CDN is a layer of caching servers in front of it that stores copies of that content close to users. The CDN answers most requests itself and only falls back to the origin on a cache miss.
- Does a CDN cache dynamic or personalized content?
- By default no. CDNs shine with static files that are identical for everyone, like images, CSS, JavaScript, and video segments. Personalized or constantly changing responses are usually marked uncacheable so they pass through to the origin, though the CDN can still provide TLS termination and DDoS protection for them.
- How does the CDN know how long to keep a file?
- The origin sets HTTP headers, mainly Cache-Control with a max-age value, which defines the TTL (time to live). When the TTL expires the edge revalidates with the origin. You can also force an immediate update by purging the cache or by changing the filename, such as adding a content hash.
- Does using a CDN reduce my hosting bills?
- Often yes for compute and origin bandwidth, since the CDN absorbs most repeat traffic and your servers handle far fewer requests. But CDNs charge for their own egress and request volume, so for low traffic sites the net cost can be similar. The bigger and more global your traffic, the more you save.
- What is the difference between an edge server and the origin?
- The origin is your source of truth where content is created and stored. An edge server is a CDN node near users that caches copies of that content. Edge servers serve cache hits directly and only contact the origin when they lack a fresh copy.
Learn CDN hands-on
This page explains the idea. The full lesson lets you step through the ring as servers join and leave, read the implementation, and check yourself with a quiz. It is one of 760+ lessons in the System Design Masterclass, from your first API call to distributed consensus. Eleven Foundation lessons are free, no signup. Lifetime access is ₹499 in India or $7.99 worldwide, one payment, no subscription.
Related lessons
Lessons that touch on CDN as part of a larger topic.
Design a Content Delivery Network
Design a CDN from scratch - edge caching, origin shield, cache purging, anycast routing, TLS termination, and global distribution
capstone · capstone
Content Delivery Network (CDN)
Serve content from edge locations worldwide for sub-50ms response times using Cloudflare, CloudFront, and edge caching
foundation · load balancing proxies
Design YouTube/Netflix
Design a video streaming platform - transcoding pipelines, adaptive bitrate streaming, CDN architecture, and recommendation engines at planetary scale
capstone · capstone
Server-Side Caching
Caching at the server and infrastructure level, reverse proxies, CDNs, and full-page caching
foundation · caching strategies
Edge-Side Includes (ESI)
Assembling pages from fragments at the CDN edge, mixing cached and dynamic content at the network layer
intermediate · web content delivery
See also
Related glossary terms you might want to look up next.
Caching
Storing frequently accessed data in a faster storage layer so you don't have to fetch it from the original (slower) source every time.
Latency
The time delay between sending a request and getting a response. Amazon found every 100ms of extra latency costs 1% in sales.
DNS
The phonebook of the internet. Translates human-readable domain names (google.com) into IP addresses that computers understand.
Cache Eviction
The process of removing entries from a cache when it's full. Common policies: LRU (least recently used), LFU (least frequently used), FIFO (first in, first out).
Cache-Aside
A caching pattern where the application checks the cache first; on a miss, it fetches from the database and populates the cache. Also called lazy loading.
Write-Through Cache
A caching pattern where every write goes to both the cache and the database simultaneously. Ensures consistency but adds write latency.