Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send Bulk leave event instead of multiple leave events on disconnect #928

Merged
merged 2 commits into from Jan 23, 2024

Conversation

ksahu750
Copy link

@ksahu750 ksahu750 commented Aug 2, 2023

We were on a rather old version of this library, so ran into #668, saw the issue was open so tried a fix, which worked for us

Checked the later version and found that this was fixed in commit 452870d, but the issue with the current approach is it issues leave event one by one for all the joined rooms, which puts a lot of stress on pubsub store if there are a lot of joined rooms.

Due to the above issue we had high CPU spikes, and had added this feature #873, a little while back.

Thinking of leveraging that here to send leave event for all the joined rooms at once, to reduce the stress on pubsub store.

Few possible solutions, that I can think of

  1. Do a bulk leave beforehand, as joinedRooms set gets modified on leaving room.
    The obvious problem here that I do see is we send pubsub event before actually leaving the rooms on this node.
  2. Copy joinedRooms and do bulk leave after leaving.
    Has a memory overhead for copying the joinedRooms set
  3. Have a separate event altogether like LEAVE_ALL (essentially same as DISCONNECT)
  4. Currently, the default DISCONNECT subscription we have in BaseStoreFactory is just a debug log, we can handle it there
    itself, but only sessionId is propagated there, namespace is not, we can either iterate all namespaces, or pass joined
    namespaces of the client in that packet.

Would like to know your opinion, or if there are better suggestions.

We were on a rather old version of this library, so ran into
mrniko#668, saw the issue was
open so tried a fix, which worked for us

Checked the later version and found that this was fixed in commit
452870d, but the issue with the current approach is it issues leave
event one by one for all the joined rooms, which puts a lot of stress
on pubsub store if there are a lot of joined rooms.

Due to the above issue we had high CPU spikes, and had added this
feature mrniko#873, a little
while back.

Thinking of leveraging that here to send leave event for all the joined
rooms at once, to reduce the stress on pubsub store.

Few possible solutions, that I can think of
1. Do a bulk leave beforehand, as joinedRooms set gets modified on
   leaving room
   The obvious problem here that I do see is we send pubsub event
   before actually leaving the rooms on this node.
2. Copy joinedRooms and do bulk leave after leaving
   Has a memory overhead for copying the joinedRooms set
3. Have a separate event altogether like LEAVE_ALL (essentially same as
   DISCONNECT)
4. Currently, the default DISCONNECT subscription we have in
   BaseStoreFactory is just a debug log, we can handle it there itself,
   but only sessionId is propagated there, namespace is not, we can
   either iterate all namespaces, or pass joined namespaces of the
   client in that packet.

Would like to know your opinion, or if there are better suggestions.
@mrniko mrniko merged commit 07d36f0 into mrniko:master Jan 23, 2024
@mrniko mrniko added this to the 2.0.7 milestone Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants