goauthentik / authentik

The authentication glue you need.
https://goauthentik.io
Other
12.79k stars 851 forks source link

Forcibly Limit Notifications to Max (like 1000) Per User #7802

Open ReaHe opened 9 months ago

ReaHe commented 9 months ago

Is your feature request related to a problem? Please describe. Notifications (shown on the user interface around the top right corner), sometimes pile up on accident due to a reoccurring error. For example I have over 100,000+ notifications for my admin users. This becomes problematic when you need to clear them or even remove the user (which clears them - https://discord.com/channels/809154715984199690/809154716507963434/1179886907275096215 ). A single clear all task can spin forever it feels like or even a remove user request.

While removing the user, the system also becomes overly taxed, maxing memory usage on my server for instance.

Describe the solution you'd like Force notifications to a max of 1000 notifications and even provide a admin settible setting for all users (using 1000 as default) for max number of notifications per user. There's no reason for a user to need even more then 100 in reality, since the user probably is not gonna read all of them. Especially if theres far more then 1000. This should also save space as well remove any bottlenecks created while trying to remove a user.

I imagine this issue will become even more evident when someone needs to remove a old admin user which may have accidently tons of notifications piled up and now it feels impossible to remove the user since it taxes the whole system to do so.

Describe alternatives you've considered Removing the user, however the clearing of notifications still takes forever.

Additional context As of this ticket, I am trying to remove a user with 100,000+ notifications and it's taking more then 15 minutes. The server was sitting at 2 gbs of memory usage but has jumped to 3.5 gbs of usage out of 4 gbs.

ReaHe commented 9 months ago

For awareness, I let the remove user run for two hours and it still didn't finish and it lowered about 20% mem usage. But it was still using up a gb of extra memory. I ended up restoring the server for fear of corrupting something since I wanted to reboot the server to fix the memory usage issue.

BeryJu commented 1 month ago

I think as a relatively simple partial solution, it would make sense to have notification expire after a certain amount of time. Especially since 99% of notifications are tied to an event anyways, which will usually have a longer retention time, and notifications are more so for just-in-time...notifications