0
0
LLDsystem_design~12 mins

Event-driven design in LLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Event-driven design

This system uses event-driven design to handle tasks asynchronously. When a user triggers an action, an event is created and sent to a message queue. Services listen for these events and process them independently, allowing the system to be scalable and responsive.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
Event Producer Service
  |
  v
Message Queue
 /   \
v     v
Worker Service A  Worker Service B
  |               |
  v               v
Database A       Database B
  ^               ^
  |               |
Cache A         Cache B
  
Components
User
user
Initiates requests to the system
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Receives user requests and forwards them to the Event Producer Service
Event Producer Service
service
Creates events based on user requests and sends them to the Message Queue
Message Queue
message_queue
Holds events until Worker Services consume and process them asynchronously
Worker Service A
service
Consumes events from the queue and processes tasks related to Database A
Worker Service B
service
Consumes events from the queue and processes tasks related to Database B
Database A
database
Stores data processed by Worker Service A
Database B
database
Stores data processed by Worker Service B
Cache A
cache
Speeds up data retrieval for Database A
Cache B
cache
Speeds up data retrieval for Database B
Request Flow - 13 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayEvent Producer Service
Event Producer ServiceMessage Queue
Message QueueWorker Service A
Worker Service ACache A
Worker Service ADatabase A
Worker Service ACache A
Worker Service AMessage Queue
Message QueueWorker Service B
Worker Service BCache B
Worker Service BDatabase B
Worker Service BCache B
Failure Scenario
Component Fails:Message Queue
Impact:Events cannot be delivered to Worker Services, causing processing delays and possible data loss
Mitigation:Use a replicated and durable message queue with retry mechanisms and dead-letter queues to handle failures
Architecture Quiz - 3 Questions
Test your understanding
Which component is responsible for holding events until workers process them?
AAPI Gateway
BLoad Balancer
CMessage Queue
DCache
Design Principle
This architecture shows how event-driven design decouples components using a message queue, enabling asynchronous processing and better scalability. It also demonstrates how caches improve performance by reducing database load.