Bird
Raised Fist0
HLDsystem_design~7 mins

Online presence system in HLD - System Design Guide

Choose your learning style9 modes available
Problem Statement
When users interact in real-time applications like chat or collaboration tools, the system often fails to accurately show who is currently online or available. This leads to confusion, missed messages, and poor user experience because stale or incorrect presence information is displayed.
Solution
The system tracks user activity and status updates continuously, using a combination of heartbeat signals and event-driven updates. It maintains a centralized or distributed presence store that reflects the current online/offline/away status of each user, updating clients in real-time to keep presence information fresh and accurate.
Architecture
User Client ├──────▶
(Web/Mobile)
Presence
Heartbeat
Signals

This diagram shows how user clients send heartbeat signals and status updates to the presence service, which stores current user states and notifies application servers and other clients via event streams.

Trade-offs
✓ Pros
Provides near real-time updates of user presence improving user experience.
Reduces stale or incorrect presence information through heartbeat and event-driven updates.
Scalable with distributed presence stores and pub/sub event streams.
Supports multiple client platforms (web, mobile) with consistent presence data.
✗ Cons
Requires additional infrastructure for presence storage and event streaming.
Heartbeat signals increase network and processing overhead, especially at large scale.
Complexity in handling network partitions and ensuring consistency of presence data.
Use when your application requires real-time or near real-time user presence updates, especially if you have more than 1,000 concurrent users or multiple client types needing synchronized presence.
Avoid if your application is mostly asynchronous or does not require live presence updates, or if user scale is under 500 concurrent users where simpler polling may suffice.
Real World Examples
Slack
Slack uses an online presence system to show which team members are currently active or idle, enabling real-time collaboration and message awareness.
Discord
Discord tracks user presence across devices to display online, idle, or offline status in real-time for voice and text chat communities.
LinkedIn
LinkedIn shows online presence indicators for messaging, helping users know when their contacts are available for chat.
Alternatives
Polling-based presence
Clients periodically request presence status from the server instead of receiving push updates.
Use when: Choose when real-time accuracy is less critical and user scale is small to medium.
Push notification presence
Uses push notifications to update presence only on significant status changes rather than continuous heartbeats.
Use when: Choose when minimizing network overhead is important and presence updates can tolerate slight delays.
Summary
An online presence system prevents stale or incorrect user availability information in real-time applications.
It uses heartbeats and event-driven updates to keep presence data fresh and synchronized across clients.
This system improves user experience but requires careful trade-offs between accuracy, overhead, and complexity.