Forums
We're experiencing major performance issues, even timing out on some actions. To put things in perspective: Our website has a total of ~4500 users, ~100 classes, ~42 courses. It might be called pretty big, I'm not sure if there are other users that have a similar setup in size.
Timeouts
At this moment we're experiencing blocking issues while implementing a new user registration service. When it creates a new user, it will automatically assign the user to the correct Class. Of course, Opigno default rules will kick in and will (among other things) assign the corresponding class-courses to the user. It looks like - when debugging - that the call stack jumps from ~0.7 seconds to ~38.3 seconds between RulesLoop->evaluate() and RulesActionContainer->evaluate().
Memberships
The current Opigno setup seems to create a MASSIVE amount of OG Memberships. I think this is because every Student, that has been assigned to a Class, will automatically be assigned to all Class Courses. This causes a major overhead on possible unnecessary correlations, and all of these will be loaded when some of the rules are being triggered.
I'm really wondering why all these memberships have to be created between the user and the class courses. Isn't it possible to relate class courses through the classes?
Workarounds?
Any suggestions how I would go about to reduce the load?
Update 2017-02-10 10:45 +1 GMT
I've pinned down the rule which is causing the massive load, by debugging inside RulesActionContainer->evaluate(). I've recursively checked for the action's root parent, which made it clear that og_user_was_granted_role has a massive amount of actions that are being evaluated. Disabling this rule makes the page load within a second, in contrast to a 30+ second timeout. I'm now about to dig into this rule, find out what it actually does and try to find a alternative / fix.
Update 2017-02-10 11:12 +1 GMT
WRONG: Also pinned down the rules_og_member_unsubscribe_class rule as a really hefty rule when deleting users. I'll be keeping track of the rules I'm encountering and try to describe each one's goal.
RIGHT: Had a small bug in my debugging logic. I think it's actually the og_user_delete rule, not yet entirely sure.
Hi ambidex,
Hi ambidex,
If you are want maximum performance i suggest you replace the rules by custom code. A rule acting on a specific even is a hook so you can replace them by your custom code.
For sure it will be better performance wise.
http://www.drupalcontrib.org/api/drupal/contributions!og!og.api.php/7
Best regards
Hi James, thanks for the
Hi ambidex,
Hi ambidex,
I took a look at that particular rule and in fact there seems a way of optimizing it.
After it loops over the class courses, it loops over all the memberships. So at that point we can load the membership of the course and check if it exists instead of doing the loop as it is.
Thank you for pointing this out. We will update this rule.
Best regards
Thanks James for keeping
Hi ambidex,
Hi ambidex,
Same logic in that rule, looping over the memberships instead of getting the specific one. We will change this logic in the rules.
Best regards
Hi James,
Hi ambidex.
It looks like that had a
I've just tried to optimise
Hi James, would you be so
Well, I am able to verify
Hi ambidex,
Hi ambidex,
As i said, once we update the all the rules with this change i will update this post.
Regarding your specific rule, i took a look and it should "work" correctly. Its just missing a check if the membership actually exists after you try to load it, thats why you get those message errors. It should work, but then again creating those error messages does not help performance.
Best regards
Hi ambidex,
Hi ambidex,
I have tested and pushed to the opigno_class_app both updated rules with the performance tweaks. "Class user was granted role" and "Class og member unsubscribe".
Best regards
Hi James!