| Users | Media Storage | CDN Usage | Network Traffic | Latency |
|---|---|---|---|---|
| 100 users | Single storage server, local disk | Minimal or no CDN | Low, direct fetch from storage | Low latency, direct access |
| 10,000 users | Distributed storage cluster, object storage | Basic CDN with few edge nodes | Moderate, some caching | Improved latency via CDN edges |
| 1,000,000 users | Highly scalable object storage (S3-like), multi-region | Global CDN with many edge locations | High, CDN offloads origin | Low latency globally |
| 100,000,000 users | Multi-cloud, geo-redundant storage, sharded data | Advanced CDN with dynamic content optimization | Very high, optimized delivery | Consistent low latency worldwide |
Media storage and CDN in HLD - Scalability & System Analysis
Start learning this pattern below
Jump into concepts and practice - no test required
At small scale, the media storage server disk I/O and network bandwidth limit throughput.
At medium scale (~10K users), the origin storage bandwidth and read latency become bottlenecks.
At large scale (1M+ users), the CDN edge cache capacity and cache miss rate impact performance.
Without CDN, origin servers get overwhelmed by traffic spikes.
- Horizontal scaling: Add more storage nodes and CDN edge servers to distribute load.
- Caching: Use CDN to cache media close to users, reducing origin load.
- Sharding: Partition media storage by region or content type to improve access speed.
- Multi-region replication: Store copies of media in multiple geographic locations.
- Compression and optimization: Reduce media size for faster delivery.
- Load balancing: Distribute requests evenly across storage and CDN nodes.
Assuming 1M users, each streaming 1 video per day of 5 MB:
- Requests per second (QPS): ~12 (1M users * 1 request / 86400 seconds)
- Daily data transfer: 5 TB (1M * 5 MB)
- Bandwidth needed at origin: Reduced by CDN cache hit ratio (e.g., 90% cache hit reduces origin bandwidth to 0.5 TB)
- Storage needed: Depends on retention, e.g., 30 days = 150 TB
- Network bandwidth: CDN edges handle most traffic, origin bandwidth is bottleneck without caching
Start by defining user scale and media size.
Identify origin storage limits and CDN role early.
Discuss caching strategies and geographic distribution.
Explain how to handle cache misses and data consistency.
Always mention cost and latency trade-offs.
Your media storage origin handles 1000 QPS. Traffic grows 10x. What do you do first?
Answer: Deploy or increase CDN edge caching to offload origin servers and reduce direct requests, preventing origin overload.
Practice
Solution
Step 1: Understand CDN role
A CDN stores copies of media files in servers near users to reduce latency.Step 2: Differentiate storage vs delivery
Media storage holds original files; CDN speeds up delivery by caching.Final Answer:
To cache media files closer to users for faster access -> Option BQuick Check:
CDN = cache near users [OK]
- Confusing CDN with permanent storage
- Thinking CDN compresses files
- Assuming CDN encrypts files
Solution
Step 1: Understand request flow
User first hits CDN cache to get media quickly.Step 2: Handle cache miss
If CDN cache misses, it fetches from origin storage and caches it.Final Answer:
User requests -> CDN cache -> Origin storage if cache miss -> Option AQuick Check:
Request flow = User -> CDN -> Storage [OK]
- Thinking origin storage serves user directly every time
- Reversing CDN and storage order
- Ignoring cache miss step
Solution
Step 1: Understand CDN TTL effect
TTL controls how long CDN keeps cached copy before checking origin.Step 2: Effect of update during TTL
Until TTL expires, CDN serves cached old file despite origin update.Final Answer:
User gets the old cached file from CDN until TTL expires -> Option CQuick Check:
Cache TTL = old file served until expiry [OK]
- Assuming CDN always fetches fresh file immediately
- Thinking cache invalidates automatically on update
- Believing user request fails on stale cache
Solution
Step 1: Analyze slow loading cause
Slow loading often happens if CDN cache misses and fetches from origin repeatedly.Step 2: Identify cache header role
Incorrect or missing cache headers prevent CDN from caching files properly.Final Answer:
CDN cache miss due to incorrect cache headers -> Option DQuick Check:
Cache headers control CDN caching [OK]
- Assuming small files don't benefit from CDN
- Thinking storage location alone causes slowness
- Believing long cache time causes slow loading
Solution
Step 1: Consider storage and CDN roles
Central storage simplifies management; CDN edge caches bring content close to users.Step 2: Evaluate options for scalability and latency
Multiple regions without CDN adds complexity; CDN without origin lacks source; local storage is impractical.Final Answer:
Store media in a single central region and use CDN with regional edge caches -> Option AQuick Check:
Central storage + CDN edges = scalable & fast [OK]
- Ignoring CDN benefits by using multi-region storage only
- Thinking CDN can replace origin storage
- Assuming local user storage is feasible
