educative.io

Server does not need to keep track of the pending messages

If we go with our second approach, where all the active users keep a connection open with the server, then as soon as the server receives a message, it can immediately pass the message to the intended user. This way, the server does not need to keep track of the pending messages, and we will have minimum latency, as the messages are delivered instantly on the opened connection.

don’t we still need to keep track of pending messages if the user is offline?

Server does not need to keep track of the pending messages in case if user keeps a connection open with the server. Server will definitely need to keep track of the pending messages if a user is offline. Message will not be delivered to the user until he connects to the server.