| Users | Traffic Pattern | Latency | Origin Server Load | Cache Hit Rate | Bandwidth Usage |
|---|---|---|---|---|---|
| 100 users | Low, local requests | Low, direct origin access | Low | Minimal caching needed | Low |
| 10,000 users | Moderate, regional spread | Improved with CDN edge nodes | Moderate | Cache hit ~30-50% | Moderate |
| 1,000,000 users | High, global distribution | Significantly reduced latency | High without CDN, reduced with CDN | Cache hit ~70-90% | High, but origin bandwidth offloaded |
| 100,000,000 users | Very high, global and peak loads | Low latency worldwide | Origin server offloaded heavily | Cache hit >90% | Very high, mostly edge bandwidth |
CDN concept and usage in HLD - Scalability & System Analysis
As user count grows beyond 10,000, the origin server bandwidth and response time become the first bottleneck. Without a CDN, the origin must serve all requests, causing high latency and potential overload. Network congestion and geographic distance increase delays for users far from the origin.
- Edge Caching: Store static content (images, scripts, videos) on CDN edge servers close to users to reduce origin load and latency.
- Geographic Distribution: Use multiple CDN PoPs (Points of Presence) worldwide to serve users locally.
- Cache Invalidation: Implement smart cache refresh strategies to keep content fresh without overloading origin.
- Load Balancing: Distribute requests among CDN nodes and origin servers to avoid hotspots.
- Compression and Optimization: Use gzip, Brotli, and image optimization at CDN edges to reduce bandwidth.
- SSL Termination: Offload SSL/TLS processing to CDN to reduce origin CPU usage.
Assuming 1 million users each making 1 request per second:
- Requests per second (RPS): 1,000,000
- Origin server without CDN: must handle 1M RPS, likely impossible on a single server.
- With CDN cache hit rate 80%, origin handles 200,000 RPS.
- Bandwidth saved at origin: 80% reduction.
- CDN edge bandwidth: high, but distributed globally.
- Storage at CDN edges: depends on cached content size, typically tens of TBs.
- Network bandwidth: 1 Gbps server handles ~125 MB/s; origin needs multiple servers or CDN to scale.
Start by explaining the problem of origin server overload and latency. Then describe how CDN edge caching reduces load and improves user experience. Discuss cache hit rates and geographic distribution. Finally, mention cache invalidation and SSL offloading as optimizations. Use numbers to show impact on requests and bandwidth.
Your origin server handles 1,000 requests per second. Traffic grows 10x to 10,000 RPS. What do you do first and why?
Answer: Deploy a CDN to cache static content at edge servers. This reduces origin load by serving most requests from cache, lowering bandwidth and latency before scaling origin servers.
Practice
CDN) in system design?Solution
Step 1: Understand CDN's role in content delivery
A CDN caches copies of content at locations near users to reduce latency and speed up access.Step 2: Compare options with CDN purpose
Only To store copies of content closer to users for faster delivery describes storing content near users for faster delivery, which is the main CDN function.Final Answer:
To store copies of content closer to users for faster delivery -> Option AQuick Check:
CDN = content near users for speed [OK]
- Thinking CDN replaces main server
- Confusing CDN with encryption service
- Assuming CDN increases database size
Solution
Step 1: Understand CDN request routing
CDNs route user requests to the closest edge server that has cached content to reduce latency.Step 2: Evaluate options for request handling
User requests are routed to the nearest CDN edge server if content is cached correctly states requests go to nearest CDN edge if cached; others are incorrect or unrelated.Final Answer:
User requests are routed to the nearest CDN edge server if content is cached -> Option DQuick Check:
CDN routes requests to nearest cache [OK]
- Assuming all requests hit origin server
- Believing CDN changes content on the fly
- Confusing CDN with authentication service
Solution
Step 1: Identify CDN edge server selection logic
CDNs serve content from the closest edge server to the user to reduce latency.Step 2: Match user location with server location
A user in Europe will get content from a European CDN edge server if available, not from origin or distant servers.Final Answer:
A CDN edge server located in Europe -> Option AQuick Check:
User location matches nearest CDN edge server [OK]
- Assuming origin server always serves content
- Choosing random or distant CDN servers
- Ignoring CDN edge server caching
Solution
Step 1: Analyze slow load cause with CDN
If CDN cache misses occur, requests go to origin server, increasing latency and slowing load times.Step 2: Evaluate options for likely cause
The CDN is not caching the content properly, causing requests to go to the origin server explains cache miss causing slow loads; others are unrelated or incorrect.Final Answer:
The CDN is not caching the content properly, causing requests to go to the origin server -> Option BQuick Check:
Cache miss = slow load [OK]
- Blaming encryption for speed issues
- Assuming CDN blocks requests randomly
- Confusing CDN with security storage
Solution
Step 1: Identify content types for CDN caching
Videos are large static files that benefit greatly from CDN caching near users to reduce latency and origin load.Step 2: Evaluate CDN strategies for global streaming
Caching all static content including videos on CDN edges worldwide improves performance and reduces origin server load.Final Answer:
Cache all static content including videos on CDN edge servers worldwide -> Option CQuick Check:
Cache large static files globally for best performance [OK]
- Caching only small files and ignoring videos
- Disabling CDN caching unnecessarily
- Using CDN for unrelated tasks like authentication
Ready to prove it?
Pass the test and this pattern moves unknown
