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

Remove sessions after last user disconnects #11

Open
angelsl opened this issue Jul 26, 2020 · 3 comments
Open

Remove sessions after last user disconnects #11

angelsl opened this issue Jul 26, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@angelsl
Copy link
Contributor

angelsl commented Jul 26, 2020

Currently sessions are never removed from memory, and we prevent the server from running out of memory by externally restarting it every Sunday morning.

Instead of this, we can automatically remove sessions from the ShareDB some time after the last user disconnects.

Implementation:

  1. Track the number of users connected to each session by binding to the WebSocket connect/disconnect events. Also track the last disconnect time.
  2. Every hour or so, remove sessions that have no users and whose last disconnection time is more than an hour old.
@martin-henz
Copy link
Member

Not sure if this is better than what we have. There might be the following case: students accidentally lose track of the browser tab that they are using. If they realize this before Sunday morning, they can retrieve the content with the session key, which they probably have in some telegram message.

Another issue is security: This is publicly available, and people could abuse the system as a chat service. If they do that, the weekly reboot means that we are not accumulating any storage.

@martin-henz martin-henz added the enhancement New feature or request label Jul 26, 2020
@angelsl
Copy link
Contributor Author

angelsl commented Jul 26, 2020

That's fair I guess. We can stick with the current setup.

I was worried the server might run out of memory towards the end of the week if all sessions are kept until Sunday—because that means memory usage simply grows as the week progresses until Sunday. Removing old sessions periodically would keep the memory usage to just the most recent one or two hours or so.

As far as I know this problem has not occurred yet; it's just a concern that I had, since I expect this feature will see much greater usage this semester.

@martin-henz
Copy link
Member

I see. Yes. please keep an eye on it. We could go for daily reboot if we have to, and then think of something better next year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants