Skip to content
Preptima
hardDesignScenarioMidSeniorStaff

Ten million users need a green dot beside their name. What does that cost, and what happens when a phone loses signal without disconnecting?

Presence at 10 million users is a lease system, not a connection-state table. Clients renew short-lived keys, the dot expires when renewals stop, and the real cost is bounded fan-out to visible watchers rather than every contact.

5 min readUpdated 2026-08-15

Answer

Short answer

Design presence as expiring leases, not as a boolean written on connect and disconnect. Each active device renews a short-lived presence key; if a phone loses signal and cannot disconnect cleanly, the lease expires and the dot turns off. The scaling problem is not just heartbeat writes, but fan-out to watchers, so subscribe only to users currently visible on screen and batch presence reads.

Mention ephemeral state where it changes the risk, the owner, or the next check. A useful ephemeral state point should make the answer more testable, not merely longer. Tie ephemeral state back to the scenario so the interviewer can see why it matters here.

Was this answer helpful?

Likely follow-ups

  • A user is signed in on a phone and a laptop and closes the laptop. What does the dot do, and where is that decided?
  • How would you serve "last seen 3 minutes ago" without storing a timestamp per user per second?
  • The presence store loses a node holding two million leases. What do watchers see during the next thirty seconds, and is that the right thing?
  • How does the design change if a user can appear invisible to some contacts and online to others?

Related questions

Related Topics