System Design · Senior · Question 12 of 75
How do you implement an "online" status for millions of users?
- ✓Correct answer: Heartbeat with TTL: the status expires without client signals
- 2Write the status to the main database on every mouse move
- 3Poll every user from the server once a second
Explanation
The client sends a signal every N seconds, and the server stores a key with a TTL in fast storage (Redis). A disconnect without an explicit logout is detected by expiration. Status changes are broadcast only to those who can see them.