High Level Design
Content Delivery Networks (CDN)
What CDNs are, how they work with edge servers and origin servers, their benefits and challenges, and how to choose the right provider.
The Problem CDNs Solve#
- A single origin server causes high latency for distant users
- Leads to slow load times, buffering, and poor user experience
- Network distance directly impacts performance
What is a CDN?#
A Content Delivery Network (CDN) is a geographically distributed network of servers that serves content from the nearest server to the user, reducing latency and improving performance & availability.
Core Components#
| Component | Role |
|---|---|
| Edge Servers (PoPs) | Cache and deliver content close to users |
| Origin Server | Source of the original content |
| DNS | Routes user requests to the nearest edge server |
How a CDN Works#
- User requests content
- DNS resolves the request to the nearest CDN edge server
- Cache Hit → Content served from the edge (fast)
- Cache Miss → Fetch from origin server, cache it, then serve
- Subsequent requests are served from the edge
CDNs use TTL (Time To Live) to refresh cached content when it becomes stale.
Benefits#
- Faster load times (low latency)
- Reduced load on origin server
- High availability and fault tolerance
- Better handling of traffic spikes
- Global content delivery
- Security features (DDoS protection, WAF, bot protection)
Challenges#
- Added system complexity
- CDN cost increases with bandwidth and traffic
- Cache invalidation must be managed carefully
Common Use Cases#
- Websites with global users
- Video streaming & OTT platforms
- Online gaming (low latency requirements)
- Media and news platforms
- Software and OS update distribution
CDN Providers#
| Provider | Best For |
|---|---|
| Akamai | Enterprise-scale, massive global network |
| Cloudflare | Free tier, security-focused |
| Fastly | Real-time caching, edge compute |
| AWS CloudFront | AWS-native integration |
| Google Cloud CDN | GCP-native |
| Azure CDN | Azure-native |
Choosing a provider:
- Small to medium apps → Cloudflare / Fastly
- Cloud-native apps → CloudFront / GCP / Azure CDN
- Enterprise scale → Akamai
Summary#
CDNs improve performance, scalability, reliability, and security by serving content closer to users and reducing origin server load.