Bird
Raised Fist0
HLDsystem_design~12 mins

Media sharing in messages in HLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Media sharing in messages

This system allows users to share media files like images, videos, and audio within their messages. It ensures media is uploaded, stored securely, and delivered efficiently alongside text messages.

Key requirements include fast upload/download, media format support, storage scalability, and message synchronization.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  +---------------------+
  |                     |
  v                     v
Media Service         Messaging Service
  |                     |
  v                     v
Media Storage         Message Database
  |
  v
CDN Cache
Components
User
client
Initiates media upload and message sending requests
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Routes requests to appropriate backend services and handles authentication
Media Service
service
Handles media upload, processing, and retrieval
Messaging Service
service
Manages message creation, storage, and delivery
Media Storage
storage
Stores media files persistently and securely
Message Database
database
Stores message metadata and text content
CDN Cache
cache
Caches media files close to users for fast delivery
Request Flow - 11 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayMedia Service
Media ServiceMedia Storage
Media ServiceAPI Gateway
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayMessaging Service
Messaging ServiceMessage Database
UserCDN Cache
CDN CacheMedia Storage
Failure Scenario
Component Fails:Media Storage
Impact:Media files cannot be stored or retrieved, causing upload failures and broken media links in messages
Mitigation:Use replicated storage clusters with failover; CDN cache serves previously cached media to reduce impact
Architecture Quiz - 3 Questions
Test your understanding
Which component handles routing requests to the correct backend service?
AMedia Service
BAPI Gateway
CLoad Balancer
DCDN Cache
Design Principle
This design separates media handling from message processing to optimize storage and delivery. Using a CDN cache reduces latency for media retrieval. The API Gateway centralizes routing and security, while the load balancer ensures scalability and availability.