Split multiple user activity notifications into chunks
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| Mahara |
High
|
Son Nguyen |
Bug Description
See bug #716812.
When there are lots of users that need to be notified about a single activity, they need to be chunked and processed over several cron runs to avoid running out of memory.
tags: | added: scalability |
Robert Lyon (robertl-9) wrote : | #2 |
A possible solution to this is we could add a column to the activity queue table to indicate the highest userid that has been processed for a cron run and limit the cron run to do only a certain amount each time so the cron just pocks up from userid x+1
Aaron Wells (u-aaronw) wrote : | #3 |
So here's why this is complicated.
Mahara has a separation between "Activities" and "Notifications". The Activities are the things that cause notifications to be sent out -- posting to a forum, posting to a wall, sending a user message, these all create an Activity record in the "activity_queue" table.
Then, the activity_
So the problem is that, because we delete the record from activity_queue, everything has to be processed in one go. And in the case of the mahara.org news forum, the 36,000 records to process is too many.
The proposed fix is:
1. Add a "last_processed
2. In the cron, only process users whose usr.id > last_processed_user
3. After processing each user, update the activity_
4. After processing a certain number of users (1000 is probably good), quit processing users
5. If all the users get processed, then delete the activity_queue record.
It appears that we'll need to make some changes to activity_
Hm... so, that it is a little tricky. None of the standard ActivityType subclasses override the constructor or the notify_users() method, so... that's good. It may be worth rethinking how we do all this ActivityType stuff in order to make it easier to split it into chunks.
Changed in mahara: | |
assignee: | nobody → Son Nguyen (ngson2000) |
status: | Confirmed → In Progress |
Aaron Wells (u-aaronw) wrote : | #4 |
For the specific case of the mahara.org News forum, I think what we should do is turn off auto-subscription. Currently it's set so that every user who registers a mahara.org account gets joined to the Mahara Community group, and subscribed to the News forum.
Or, to put it another way, perhaps we should reserve the News forum for news about *mahara.org* itself (because maybe there will be times when we need to send an email to every user on mahara.org?); and create a separate forum for news about Mahara.
Kristina Hoeppner (kris-hoeppner) wrote : | #5 |
Changing the subscription may solve part of the problem, but not really its cause because you may need a forum to really reach everyone and then you could still not do it.
Son Nguyen (ngson2000) wrote : | #7 |
Note for testing:
1. Add an group and turn on "Auto-add users"
2. Add hundreds users via CSV (attached file)
3. Change the minute of activity_
4. Change the minute of interaction_
The chunk size is set to '1000' (Activity:
You may change it to smaller value to see if it works
Reviewed: https:/
Committed: http://
Submitter: Son Nguyen (<email address hidden>)
Branch: master
commit 3921ebdd0f5a074
Author: Son Nguyen <email address hidden>
Date: Thu Nov 21 15:55:00 2013 +1300
Split multiple user activity notifications into chunks (Bug 778254)
1. Add a new column 'last_processed
activity_queue
2. Enable the notify_users() method to work with split user chunks
3. Modify the activity_
activity_queue with the new process
Change-Id: Id404aa8e8fa651
Signed-off-by: Son Nguyen <email address hidden>
Aaron Wells (u-aaronw) wrote : | #9 |
So it turns out the implementation in in patch 2729 still errored out mahara.org. By placing a lot of log_info() statements throughout the activity_
The reason this is a problem, is because patch 2729 doesn't actually chunk the data pulled from the database; instead, it pulls the full amount of data and then only processes a subset of it.
So, I've submitted a patch which actual alters ActivityInterac
Mahara Bot (dev-mahara) wrote : | #10 |
Reviewed: https:/
Committed: http://
Submitter: Robert Lyon (<email address hidden>)
Branch: master
commit 876305ec4e20d0e
Author: Aaron Wells <email address hidden>
Date: Wed Dec 11 15:04:39 2013 +1300
Making the notification batching system also batch the data pulled from the DB
Change-Id: I273b347070266d
Changed in mahara: | |
status: | In Progress → Fix Committed |
Changed in mahara: | |
milestone: | none → 1.9.0 |
tags: | added: nominatedfeature |
Changed in mahara: | |
status: | Fix Committed → Fix Released |
This problem still exists and would be good to sort out as it means notifications for an activity like a forum posts can crash the system