All Questions
Real Time Updates hard

You need a 'Who is Online' feature for 10 million users. Storing 'Online' status in a SQL DB with `UPDATE users SET last_seen = NOW()` is too slow. What is the standard high-scale pattern?

  1. A Broadcast a message to everyone when someone joins.
  2. B Use a global hash map in the application memory.
  3. C Log every request to a file and parse it.
  4. D Use Redis Sorted Sets (ZSET) or Keys with TTL. Clients send a heartbeat every minute to refresh the TTL. If the key expires, they are considered offline.

One system design question a day, with spaced repetition so the ones you miss come back.

Get the app

Related questions