0
0
HLDsystem_design~12 mins

Why async processing decouples systems in HLD - Architecture Impact

Choose your learning style9 modes available
System Overview - Why async processing decouples systems

This system demonstrates how asynchronous processing helps separate parts of a system so they work independently. It shows how a user request is accepted quickly and processed later by a worker, improving system reliability and scalability.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
Message Queue <--> Worker Service
  |
  v
Database
  |
  v
Cache
Components
User
client
Sends requests to the system
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Receives requests and places tasks into the message queue asynchronously
Message Queue
message_queue
Holds tasks for processing, decoupling request reception from processing
Worker Service
service
Processes tasks from the message queue and updates the database
Database
database
Stores persistent data updated by the worker
Cache
cache
Speeds up data retrieval for read requests
Request Flow - 7 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayMessage Queue
API GatewayUser
Worker ServiceMessage Queue
Worker ServiceDatabase
Worker ServiceCache
Failure Scenario
Component Fails:Message Queue
Impact:Tasks cannot be queued or consumed, causing processing delays and possible data loss
Mitigation:Use a highly available message queue with replication and persistence to prevent data loss and allow failover
Architecture Quiz - 3 Questions
Test your understanding
Why does the API Gateway place tasks into a message queue instead of processing them immediately?
ABecause the database cannot handle direct requests
BTo reduce network latency between user and database
CTo allow the system to respond quickly and process tasks later
DTo avoid using a load balancer
Design Principle
Asynchronous processing decouples the request reception from task execution, allowing the system to respond quickly to users and handle tasks independently. This separation improves scalability, fault tolerance, and system responsiveness.