User uptime status tracking

Asad Dhamani
1 min readJan 5, 2017

I have been working on a chat system as of late, and one of the most important features a chat platform could have is tracking the online status of people.

Initially I just used a package that would send a heartbeat every x seconds to the server, which would then update the user document on the database with the new timestamp, and on a disconnection from the client, it would mark them offline in the database.

This is good enough to start off with, but I think how Facebook does it is a lot more interesting and intuitive. You see online users, and for offline users, you see when they were last seen online.

I think a good way to implement this could be to have a heartbeat over a websocket sent every x seconds, and append a time series database with the new status. This way, on the client side, you can mark users as offline if they disconnect, you can track activity and mark them as away if they haven’t been on the page in the past few minutes, and you can show them online if they were active in the last say two minutes.

--

--

Asad Dhamani

Tech Entrepreneur. Software Development Consultant. Full stack developer and astrophotography enthusiast.