Bird
Raised Fist0
HLDsystem_design~12 mins

Heartbeat mechanism in HLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Heartbeat mechanism

A heartbeat mechanism is used to monitor the health and availability of components in a distributed system. It regularly sends signals (heartbeats) from one component to another to confirm they are alive and responsive, enabling quick detection of failures.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
+----------------+       +----------------+
| Service A      |<----->| Heartbeat      |
| (Worker Node)  |       | Monitor Service|
+----------------+       +----------------+
        |                        |
        v                        v
   Database                  Message Queue
        |                        |
        v                        v
      Cache                  Alert System
Components
User
user
Initiates requests to the system
Load Balancer
load_balancer
Distributes incoming requests evenly across services
API Gateway
api_gateway
Routes requests to appropriate services and handles authentication
Service A (Worker Node)
service
Performs main business logic and sends heartbeat signals
Heartbeat Monitor Service
service
Receives heartbeat signals and checks service health
Database
database
Stores persistent data for services
Cache
cache
Speeds up data retrieval for frequent requests
Message Queue
queue
Queues alerts and notifications asynchronously
Alert System
service
Sends notifications when a service failure is detected
Request Flow - 4 Hops
Service A (Worker Node)Heartbeat Monitor Service
Heartbeat Monitor ServiceDatabase
Heartbeat Monitor ServiceMessage Queue
Message QueueAlert System
Failure Scenario
Component Fails:Service A (Worker Node)
Impact:Heartbeat signals stop; Heartbeat Monitor detects missing heartbeats and triggers alerts; service requests fail or timeout
Mitigation:Heartbeat Monitor retries checks; Alert System notifies operators; Load Balancer stops sending traffic to failed node; auto-scaling or manual intervention replaces the node
Architecture Quiz - 3 Questions
Test your understanding
Which component is responsible for detecting if a service has stopped sending heartbeats?
ALoad Balancer
BAPI Gateway
CHeartbeat Monitor Service
DMessage Queue
Design Principle
This design uses a heartbeat mechanism to monitor service health by sending regular signals. The Heartbeat Monitor Service checks these signals and triggers alerts asynchronously via a message queue if failures occur. This approach enables quick failure detection and decouples alerting from the main service flow, improving system reliability and scalability.