Skip to content
QuizMaker logoQuizMaker
Activity
System Design: The Complete Guide
1. System Design Basics
1. Introduction to System Design
2. Vertical vs Horizontal Scaling
3. Load Balancing
4. Caching Strategies
5. CDNs (Content Delivery Networks)
6. SQL vs NoSQL
7. Database Sharding & Partitioning
8. The CAP Theorem
9. Microservices Architecture
10. Message Queues & Event Streaming
12. Design BookMyShow (Ticket Booking)
14. Design Dropbox (Cloud File Storage)
15. How to Approach Any System Design Interview
16. Back-of-the-Envelope Estimation
17. Consistent Hashing
18. Bloom Filters & Probabilistic Data Structures
19. Database Replication
20. Leader Election & Consensus (Raft & Paxos)
21. Distributed Transactions (Saga, 2PC, Outbox)
22. Event Sourcing & CQRS
23. Unique ID Generation at Scale
24. Rate Limiting Algorithms
25. Circuit Breakers & Bulkhead Pattern
26. API Gateway, Proxies & Service Mesh
27. Real-Time Communication
28. Observability (Tracing, Logging, SLOs)
30. Design a Chat System (WhatsApp)
31. Design YouTube (Video Streaming)
32. Design a Web Crawler
CONTENTS

5. CDNs (Content Delivery Networks)

Bringing static assets closer to users globally.

Feb 22, 202640 views0 likes0 fires
18px

Beating the Speed of Light

Network packets are physically bound by the speed of light across fiber optic cables. If your server sits in a data center in Virginia and a user connects from a café in Mumbai, their request physically crosses undersea cables beneath the Atlantic and Indian Oceans. This creates an unavoidable ~200ms round-trip penalty.

A modern webpage loads 50+ assets (images, scripts, fonts). Without optimization, that Mumbai user stares at a blank screen for 3-4 seconds. A CDN (Content Delivery Network) solves this constraint of physics.

Real-World Example: Netflix

Netflix serves over 15% of all internet bandwidth globally. They built their own CDN called Open Connect—custom hardware appliances placed directly inside ISP data centers in 1,000+ locations worldwide. When you stream a movie, you''re literally downloading from a server in your ISP''s own building, not from Netflix''s AWS origin. This is why Netflix can deliver 4K video with barely any buffering, even during peak evening hours.

How CDNs Work: Edge Servers

A CDN is a globally distributed network of proxy servers called "Edge Nodes." Providers like Cloudflare (300+ cities), AWS CloudFront (400+ edge locations), and Akamai (4,000+ edge servers) maintain physical presence worldwide.

When a user in Tokyo requests your website''s logo, their DNS query is transparently routed to the nearest edge node—right there in Tokyo. The latency drops from 200ms to 5ms.

[!NOTE] CDNs primarily cache static assets: JavaScript bundles, CSS stylesheets, images, fonts, and video files. You cannot easily cache live, dynamic data (like a user''s shopping cart) at the edge. But static assets often account for 80-90% of bandwidth, so this alone massively offloads your origin server.

Push vs Pull CDNs

Push CDN

You manually upload assets to the CDN, which proactively distributes them to all global nodes. You''re responsible for pushing updates when files change.

  • Best for: Large, rarely changing libraries of static files (e.g., Apple''s App Store assets, game downloads).
  • Example: Apple pre-pushes iOS updates to CDN nodes worldwide before the public release date. When 100 million iPhones hit "Download" simultaneously, the traffic is already distributed.

Pull CDN

Assets live on your origin server. When a user first requests logo.png, the nearest edge node fetches it from the origin ("Cache Miss"), caches it locally, and serves all subsequent requests from cache ("Cache Hit").

  • Best for: Sites with high traffic and frequently updating assets (e.g., news sites, blogs, SaaS products).
  • Example: The New York Times uses a pull CDN—when a breaking news story goes viral, CloudFront caches the article and images at hundreds of edge locations within seconds.

Cache Invalidation: The Hard Problem

There''s a famous saying in computer science: "There are only two hard things in CS: cache invalidation and naming things." With CDNs, this problem is real:

  • Fingerprinted filenames: The safest approach. Name your files with a content hash (e.g., app.3f2a1b.js). When the file changes, the hash changes, so the CDN treats it as a brand new file. No stale cache risk.
  • Cache-Control headers: Set max-age and s-maxage to control how long edge nodes cache each asset.
  • Purge APIs: Most CDNs let you manually purge specific URLs or entire paths when needed (e.g., after a critical hotfix).

Beyond Static: Edge Computing

Modern CDNs are evolving beyond static caching. Cloudflare Workers, AWS Lambda@Edge, and Vercel Edge Functions let you run server-side code at the edge—executing authentication, A/B testing, or personalization logic in the edge node closest to the user. This blurs the line between "CDN" and "distributed compute platform."

[!TIP] Interview tip: When designing any read-heavy system, mention CDNs early. A CDN is often the first thing you deploy to improve user experience globally. Even if your origin server is in one region, a CDN gives you global performance for pennies per GB.

Share this article

Share on TwitterShare on LinkedInShare on FacebookShare on WhatsAppShare on Email

Test your knowledge

Take a quick quiz based on this chapter.

easySystem Design
Quiz: CDNs
5 questions5 min

Continue Learning

6. SQL vs NoSQL

Intermediate
16 min

7. Database Sharding & Partitioning

Intermediate
14 min

8. The CAP Theorem

Intermediate
16 min
Lesson 5 of 5 in 1. System Design Basics
Previous in 1. System Design Basics
4. Caching Strategies
Completed
You finished this lesson → take the quiz
5 questions • 5 min
Next section: 2. Intermediate Architecture
← Back to System Design: The Complete Guide
Back to System Design: The Complete GuideAll Categories