Bird
0
0
LLDsystem_design~12 mins

Observer pattern in LLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Observer pattern

The Observer pattern is a design approach where one object (the subject) keeps a list of dependents (observers) and notifies them automatically of any state changes. This pattern helps in building systems where multiple components need to stay updated with changes without tight coupling.

Architecture Diagram
  +------------+       notify()       +-------------+
  |  Subject   |---------------------->|  Observer1  |
  +------------+                       +-------------+
        |                                   ^
        |                                   |
        |                                   |
        |                                   |
        |       notify()                    |
        +-------------------------------> +-------------+
                                        |  Observer2  |
                                        +-------------+
Components
Subject
service
Maintains state and notifies observers about changes
Observer1
observer
Receives updates from Subject and reacts accordingly
Observer2
observer
Receives updates from Subject and reacts accordingly
Request Flow - 2 Hops
SubjectObserver1
SubjectObserver2
Failure Scenario
Component Fails:Observer1
Impact:Observer1 does not receive updates and may have stale data
Mitigation:Subject continues notifying other observers; Observer1 can resubscribe or recover later
Architecture Quiz - 3 Questions
Test your understanding
Which component holds the main state in the Observer pattern?
AObserver2
BObserver1
CSubject
DLoad Balancer
Design Principle
The Observer pattern decouples the subject from its observers, allowing dynamic subscription and automatic updates. This promotes loose coupling and scalability in systems where multiple components depend on shared state changes.