Thanks for reading systemdesign.one newsletter. If you're not yet subscribed, let me help you with that:
High-Level Design
The real-time platform should display the online status of a client connected to it. The client needs to subscribe to the platform to receive notifications about the status of their connections (friends). At a high level, the presence platform 2 performs the following operations:
The subscriber (client) utilizes the HTTP GET method to query the presence service and retrieve the status of a publisher
The presence service then queries the presence database to determine the presence status
The client subscribes to the publisher's status through the real-time platform, establishing an SSE connection
Once the publisher comes online, they establish an SSE connection with the real-time platform
The real-time platform sends a UDP heartbeat signal to the presence service
The presence service queries the presence database to verify if the publisher has recently come online
If the publisher is confirmed as online, the presence service publishes an online event to the real-time platform using the HTTP PUT method
The real-time platform broadcasts the change in the publisher's presence status to subscribers through SSE
The presence service can retrieve the last active timestamp of an offline publisher by querying the presence database. The existing architecture can be leveraged to implement a real-time presence platform.