Bird
Raised Fist0
HLDsystem_design~20 mins

Media sharing in messages 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 Sharing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Architecture
intermediate
2:00remaining
Design components for media sharing in messaging

Which component is most essential to handle media file uploads in a scalable messaging system?

AA media storage service that stores files and provides URLs
BA message queue to deliver text messages only
CA notification service that sends alerts without storing media
DA user authentication module without media handling
Attempts:
2 left
💡 Hint

Think about where the media files themselves are kept and accessed.

scaling
intermediate
2:00remaining
Scaling media delivery in messaging apps

What is the best approach to efficiently deliver large media files to many users in a messaging app?

ASend media files directly from the sender's device to each recipient
BStore media files only on the messaging server without caching
CUse a Content Delivery Network (CDN) to cache and serve media files globally
DCompress media files on the client side and send as text messages
Attempts:
2 left
💡 Hint

Consider how to reduce latency and server load when many users access the same media.

tradeoff
advanced
2:00remaining
Tradeoffs in media storage formats

Which storage format tradeoff is most important when designing media sharing for messages?

AChoosing between SQL and NoSQL for user profile data
BChoosing between storing media as blobs in a database or as files in object storage
CChoosing between synchronous and asynchronous message delivery
DChoosing between storing user passwords as plain text or hashed
Attempts:
2 left
💡 Hint

Focus on how media files are stored and accessed efficiently.

🧠 Conceptual
advanced
2:00remaining
Handling media metadata in messaging systems

What is the primary reason to store metadata (like file type, size, thumbnail) separately from media files?

ATo allow users to edit media files directly in the database
BTo reduce the total storage space used by media files
CTo encrypt media files separately from metadata
DTo enable quick access and filtering without loading large media files
Attempts:
2 left
💡 Hint

Think about how apps show previews or lists of media without downloading full files.

estimation
expert
3:00remaining
Estimating storage needs for media sharing

A messaging app expects 1 million users sharing an average of 5 media files per day. Each file averages 3 MB. What is the approximate monthly storage requirement in terabytes (TB)?

A450 TB
B15 TB
C900 TB
D150 TB
Attempts:
2 left
💡 Hint

Calculate total daily data, then multiply by 30 days, convert MB to TB (1 TB = 1,000,000 MB).

Practice

(1/5)
1. What is the main reason to separate media storage from message text storage in a messaging system?
easy
A. To reduce the number of messages sent
B. To make the user interface more colorful
C. To improve performance and scalability by handling large media files separately
D. To avoid using cloud storage services

Solution

  1. Step 1: Understand media file size impact

    Media files like photos and videos are large and can slow down message storage if kept together.
  2. Step 2: Separate storage benefits

    Separating media storage allows using specialized systems like CDNs and cloud storage optimized for large files.
  3. Final Answer:

    To improve performance and scalability by handling large media files separately -> Option C
  4. Quick Check:

    Separate media storage = better performance [OK]
Hint: Separate big files from text for faster message handling [OK]
Common Mistakes:
  • Thinking media size doesn't affect performance
  • Confusing UI design with storage design
  • Ignoring scalability needs
2. Which component is essential for efficiently delivering media files in a messaging system?
easy
A. Content Delivery Network (CDN)
B. Message queue
C. Load balancer for text messages
D. Database index

Solution

  1. Step 1: Identify media delivery needs

    Media files are large and need fast delivery to users worldwide.
  2. Step 2: Role of CDN

    A CDN caches media files close to users, reducing latency and bandwidth usage.
  3. Final Answer:

    Content Delivery Network (CDN) -> Option A
  4. Quick Check:

    Fast media delivery = CDN [OK]
Hint: Use CDN to speed up media file delivery [OK]
Common Mistakes:
  • Confusing CDN with database indexing
  • Thinking load balancers handle media files
  • Ignoring network latency
3. Given a messaging system where media files are uploaded to cloud storage and messages store only media URLs, what is the expected behavior when a user sends a photo?
medium
A. The photo is embedded directly in the message text stored in the database
B. The photo is uploaded to cloud storage and the message stores a URL pointing to it
C. The photo is sent as a base64 string inside the message
D. The photo is stored in the message queue before delivery

Solution

  1. Step 1: Understand media upload flow

    Media files are large, so they are uploaded separately to cloud storage for efficiency.
  2. Step 2: Message stores media reference

    The message contains a URL pointing to the media location, not the media itself.
  3. Final Answer:

    The photo is uploaded to cloud storage and the message stores a URL pointing to it -> Option B
  4. Quick Check:

    Media URL in message = cloud upload [OK]
Hint: Messages store URLs, not media files directly [OK]
Common Mistakes:
  • Embedding large media in message text
  • Using base64 which increases size
  • Storing media in message queues
4. A messaging system stores media files directly in the message database causing slow queries. What is the best fix?
medium
A. Increase database RAM without changing design
B. Delete all media files from messages
C. Compress media files and keep them in the database
D. Move media files to cloud storage and store only URLs in the database

Solution

  1. Step 1: Identify problem with current design

    Storing large media in the database slows down queries and reduces scalability.
  2. Step 2: Apply best practice for media storage

    Moving media to cloud storage and storing URLs improves performance and scalability.
  3. Final Answer:

    Move media files to cloud storage and store only URLs in the database -> Option D
  4. Quick Check:

    Separate media storage = faster queries [OK]
Hint: Store URLs, not media, in message DB for speed [OK]
Common Mistakes:
  • Relying only on hardware upgrades
  • Compressing media but still storing in DB
  • Removing media reduces feature, not fix
5. You design a messaging app that supports sharing photos and videos. To handle millions of users, which combination of components best ensures scalability and fast media delivery?
hard
A. Upload media to cloud storage, use a CDN for delivery, and store media URLs in messages
B. Store media in the message database and use a single server for all requests
C. Send media as base64 in messages and cache messages on client devices
D. Use peer-to-peer media sharing without central storage

Solution

  1. Step 1: Analyze scalability needs

    Millions of users require scalable storage and fast delivery without overloading servers.
  2. Step 2: Choose best architecture components

    Cloud storage handles large media files reliably; CDN speeds up delivery globally; storing URLs keeps messages lightweight.
  3. Step 3: Evaluate other options

    Single server or embedding media causes bottlenecks; peer-to-peer lacks reliability and control.
  4. Final Answer:

    Upload media to cloud storage, use a CDN for delivery, and store media URLs in messages -> Option A
  5. Quick Check:

    Cloud storage + CDN + URLs = scalable media sharing [OK]
Hint: Combine cloud storage, CDN, and URLs for scalable media [OK]
Common Mistakes:
  • Storing media in DB causing bottlenecks
  • Sending base64 increases message size
  • Ignoring global delivery speed