Bird
Raised Fist0
HLDsystem_design~20 mins

Media storage and CDN in HLD - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Media Storage & CDN Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Architecture
intermediate
2:00remaining
Design a scalable media storage system for millions of users

You need to design a media storage system that can handle millions of users uploading images and videos daily. Which architectural component is most critical to ensure scalability and fast access?

AStore media files in distributed object storage and metadata in a separate database.
BStore media files directly in the application server's local disk for faster access.
CUse a peer-to-peer network where users share media files directly without central storage.
DUse a single large database server to store all media files and metadata.
Attempts:
2 left
💡 Hint

Think about separating file storage from metadata and how to handle large scale.

scaling
intermediate
2:00remaining
Handling sudden traffic spikes in CDN delivery

Your CDN is delivering media content globally. Suddenly, a viral video causes a huge spike in traffic. What is the best way to handle this spike without degrading user experience?

ADisable caching so all requests go to the origin server for fresh content.
BIncrease the origin server capacity to handle all requests directly.
CRely on CDN edge caching to serve most requests and scale edge nodes automatically.
DLimit user access by blocking some regions temporarily to reduce load.
Attempts:
2 left
💡 Hint

Consider how CDNs reduce load on origin servers during high traffic.

tradeoff
advanced
2:00remaining
Choosing between CDN push and pull models

When designing a CDN for media delivery, you must choose between push and pull models. Which tradeoff is true?

APull CDN preloads all content to edges, which reduces storage cost but increases latency.
BPush CDN requires preloading content to edge servers, increasing storage cost but reducing first-request latency.
CPush CDN always delivers content slower than pull CDN because of extra replication steps.
DPull CDN requires manual upload of content to each edge server before delivery.
Attempts:
2 left
💡 Hint

Think about when content is sent to edge servers in each model.

component
advanced
2:00remaining
Key components of a media CDN architecture

Which component is essential in a CDN architecture to ensure media content is delivered efficiently and securely?

AEdge servers that cache media content close to users and handle most delivery requests.
BOrigin server that stores the original media files and handles all user requests.
CLoad balancer that distributes user requests only among origin servers.
DDatabase cluster that stores user credentials and media metadata but does not cache content.
Attempts:
2 left
💡 Hint

Consider which component reduces latency and bandwidth usage.

estimation
expert
3:00remaining
Estimating storage and bandwidth for a global media CDN

Your service expects 10 million daily active users uploading 5 MB average media files each, and 100 million daily views with average 3 MB per view. Estimate the daily storage and bandwidth requirements for the CDN.

AStorage: 50 TB per day; Bandwidth: 30 TB per day
BStorage: 500 TB per day; Bandwidth: 30 TB per day
CStorage: 5 TB per day; Bandwidth: 3000 TB per day
DStorage: 50 TB per day; Bandwidth: 300 TB per day
Attempts:
2 left
💡 Hint

Calculate storage from uploads and bandwidth from views multiplied by average sizes.

Practice

(1/5)
1. What is the main purpose of a Content Delivery Network (CDN) in media storage systems?
easy
A. To store original media files permanently
B. To cache media files closer to users for faster access
C. To compress media files before storage
D. To encrypt media files for security

Solution

  1. Step 1: Understand CDN role

    A CDN stores copies of media files in servers near users to reduce latency.
  2. Step 2: Differentiate storage vs delivery

    Media storage holds original files; CDN speeds up delivery by caching.
  3. Final Answer:

    To cache media files closer to users for faster access -> Option B
  4. Quick Check:

    CDN = cache near users [OK]
Hint: CDN = cache near users for speed [OK]
Common Mistakes:
  • Confusing CDN with permanent storage
  • Thinking CDN compresses files
  • Assuming CDN encrypts files
2. Which of the following is the correct sequence for serving media using storage and CDN?
easy
A. User requests -> CDN cache -> Origin storage if cache miss
B. User requests -> Origin storage -> CDN cache
C. CDN cache -> User requests -> Origin storage
D. Origin storage -> CDN cache -> User requests

Solution

  1. Step 1: Understand request flow

    User first hits CDN cache to get media quickly.
  2. Step 2: Handle cache miss

    If CDN cache misses, it fetches from origin storage and caches it.
  3. Final Answer:

    User requests -> CDN cache -> Origin storage if cache miss -> Option A
  4. Quick Check:

    Request flow = User -> CDN -> Storage [OK]
Hint: Requests hit CDN first, then storage if needed [OK]
Common Mistakes:
  • Thinking origin storage serves user directly every time
  • Reversing CDN and storage order
  • Ignoring cache miss step
3. Consider a system where media files are stored in cloud storage and served via CDN. If the CDN cache TTL (time-to-live) is set to 1 hour, what happens when a media file is updated in storage immediately after a user requests it?
medium
A. User gets the updated file immediately from CDN
B. CDN automatically invalidates cache and fetches new file
C. User gets the old cached file from CDN until TTL expires
D. User request fails until cache refresh

Solution

  1. Step 1: Understand CDN TTL effect

    TTL controls how long CDN keeps cached copy before checking origin.
  2. Step 2: Effect of update during TTL

    Until TTL expires, CDN serves cached old file despite origin update.
  3. Final Answer:

    User gets the old cached file from CDN until TTL expires -> Option C
  4. Quick Check:

    Cache TTL = old file served until expiry [OK]
Hint: Cache TTL controls update delay [OK]
Common Mistakes:
  • Assuming CDN always fetches fresh file immediately
  • Thinking cache invalidates automatically on update
  • Believing user request fails on stale cache
4. A developer implemented a media delivery system using CDN and storage but users report slow media loading. Which of the following is the most likely cause?
medium
A. CDN is caching files for too long
B. Media files are too small to benefit from CDN
C. Storage is located in the same region as users
D. CDN cache miss due to incorrect cache headers

Solution

  1. Step 1: Analyze slow loading cause

    Slow loading often happens if CDN cache misses and fetches from origin repeatedly.
  2. Step 2: Identify cache header role

    Incorrect or missing cache headers prevent CDN from caching files properly.
  3. Final Answer:

    CDN cache miss due to incorrect cache headers -> Option D
  4. Quick Check:

    Cache headers control CDN caching [OK]
Hint: Check cache headers if CDN misses often [OK]
Common Mistakes:
  • Assuming small files don't benefit from CDN
  • Thinking storage location alone causes slowness
  • Believing long cache time causes slow loading
5. You are designing a global media storage system with CDN for a video streaming service. Which combination best improves scalability and user experience?
hard
A. Store media in a single central region and use CDN with regional edge caches
B. Store media in multiple regions without CDN to reduce latency
C. Use CDN only without origin storage to reduce costs
D. Store media locally on user devices to avoid network delays

Solution

  1. Step 1: Consider storage and CDN roles

    Central storage simplifies management; CDN edge caches bring content close to users.
  2. Step 2: Evaluate options for scalability and latency

    Multiple regions without CDN adds complexity; CDN without origin lacks source; local storage is impractical.
  3. Final Answer:

    Store media in a single central region and use CDN with regional edge caches -> Option A
  4. Quick Check:

    Central storage + CDN edges = scalable & fast [OK]
Hint: Central storage + CDN edges = best scalability [OK]
Common Mistakes:
  • Ignoring CDN benefits by using multi-region storage only
  • Thinking CDN can replace origin storage
  • Assuming local user storage is feasible