Bird
Raised Fist0
HLDsystem_design~12 mins

Why messaging requires real-time architecture in HLD - Architecture Impact

Choose your learning style9 modes available
System Overview - Why messaging requires real-time architecture

This system enables instant message delivery between users. It must handle many users sending and receiving messages quickly and reliably. The key requirement is low delay so conversations feel natural and real-time.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
Message Service <-> Message Queue <-> Notification Service
  |                              |
  v                              v
Database                      Cache
Components
User
client
Sends and receives messages in real-time
Load Balancer
load_balancer
Distributes incoming user requests evenly to backend servers
API Gateway
api_gateway
Handles client requests, authentication, and routes to services
Message Service
service
Processes sending and receiving messages, interacts with queue and database
Message Queue
message_queue
Buffers messages for asynchronous processing and delivery
Notification Service
service
Sends real-time notifications to users about new messages
Database
database
Stores message history and user data
Cache
cache
Stores recent messages for fast retrieval
Request Flow - 8 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayMessage Service
Message ServiceMessage Queue
Message QueueNotification Service
Notification ServiceUser
Message ServiceDatabase
Message ServiceCache
Failure Scenario
Component Fails:Message Queue
Impact:Messages cannot be buffered for delivery, causing delays or loss of real-time notifications
Mitigation:Use replicated queues and fallback to direct delivery attempts; alert operators to fix queue issues quickly
Architecture Quiz - 3 Questions
Test your understanding
Why is the Message Queue important in this real-time messaging system?
AIt stores user profiles permanently
BIt buffers messages to ensure smooth and ordered delivery
CIt balances load between users
DIt authenticates user requests
Design Principle
This architecture uses asynchronous messaging with a queue to handle real-time message delivery reliably and at scale. Caching recent messages reduces database load and improves response speed. Load balancing and API gateway ensure scalability and security. The design balances speed, reliability, and user experience.