-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Notifications.prune taking too long #999
Comments
Running it on a per-user basis would be fine, unless a user does not log in... Notifications cron should only be run once a day anyway... when did it run for you? |
Hmm I think its running 7pm est. Even with 650 users its taking 52 seconds, so it will be a huge problem on bigger forums. Not really sure how the notification pruning works, I think it doesnt prune anything if they are not read? So if a user never logs in the notifications just keep increasing forever? |
Yes. I'll be the first to admit that notifications need an overhaul. Notification pruning works thusly:
Steps 2 and 3 are obviously the O(derp) part, because the more users there are, the longer it will take. Step 3 is, I believe, running Instead, I think we should simpify the system:
|
Something I forgot to reply about much earlier:
Not the case if so:
|
The simplest possible solution would be to use a Child Process to do this work instead, hence not blocking the main web server thread. |
That could be done with https://www.npmjs.org/package/cronos potentially. |
I believe the second task (in the ones I listed above) is already done, so I'll go ahead and just have prune delete the expired notification objects after 7 days. Can extend this to be an admin definable value, but is not necessary at the moment. |
Hahaha, I like how the "status" for that module is "Alpha as f*ck". NodeBB already uses cron as a dependency, so no need to change, I think... |
This function needs rethinking, right now takes up to a minute to process causing the forum to become unresponsive.
Instead of running it on a cron for all users it can be run on a user basis when they receive a notification.
The text was updated successfully, but these errors were encountered: