Bird
Raised Fist0
HLDsystem_design~12 mins

Online presence system in HLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Online presence system

An online presence system shows if users are currently active or offline in real time. It must handle many users updating their status frequently and provide quick updates to friends or contacts.

Key requirements include low latency updates, scalability to millions of users, and fault tolerance to avoid losing presence data.

Architecture Diagram
User Clients
   |
   v
Load Balancer
   |
API Gateway
   |
Presence Service <-> Cache (Redis)
   |
Database (NoSQL)
Components
User Clients
client
Users' devices sending presence updates and requesting friends' presence
Load Balancer
load_balancer
Distributes incoming user requests evenly to API Gateway instances
API Gateway
api_gateway
Handles authentication, routing requests to Presence Service
Presence Service
service
Processes presence updates and queries, interacts with cache and database
Cache (Redis)
cache
Stores recent presence states for fast read/write access
Database (NoSQL)
database
Stores durable presence history and user metadata
Request Flow - 8 Hops
User ClientsLoad Balancer
Load BalancerAPI Gateway
API GatewayPresence Service
Presence ServiceCache (Redis)
Presence ServiceDatabase (NoSQL)
Presence ServiceAPI Gateway
API GatewayLoad Balancer
Load BalancerUser Clients
Failure Scenario
Component Fails:Cache (Redis)
Impact:Presence reads become slower as cache misses increase; writes still succeed but with higher latency
Mitigation:Presence Service falls back to database reads; cache is restored from DB asynchronously; use cache replication for high availability
Architecture Quiz - 3 Questions
Test your understanding
Which component handles user authentication before processing presence data?
ALoad Balancer
BPresence Service
CAPI Gateway
DCache (Redis)
Design Principle
This design uses a cache to provide fast access to frequently changing presence data, reducing load on the database and improving user experience with low latency. The layered approach with load balancer and API gateway ensures scalability and security.