catalyst / moodle-local_cohortauto

Automatically add users into cohorts. (Previously moodle-auth_mcae.)
https://moodle.org/plugins/local_cohortauto
11 stars 14 forks source link

Massive Server Load #25

Closed wbuk closed 4 months ago

wbuk commented 1 year ago

Since upgrading to moodle 4, we are experiencing extreme server loads from Cohort_Auto. Is there a way we can make an adjustment to reduce server the server load?

It was set to 15 minutes but takes 12-13 minutes to complete so the server is not recovering, we have changed it to 30 minutes but wondered if we can make any other changes. For example, is changing it to 60 minutes ok? Can we do anything to reduce the server load on the 12 mins run? Does it support Redis?

danmarsden commented 1 year ago

what is set to 15minutes? - this plugin doesn't have any scheduled tasks that you can adjust like that - it makes changes on user action/events.

Can you please provide more information on what process is running slowly?

wbuk commented 1 year ago

Hi, yes we have it set as a CRON job that runs it every 15 minutes, we have now changed this to once a day in the early morning. Is this unnecessary?

Please can I also as, we are using Moodle, 4, our sever provider is saying that it is down on the moodle website as only being compatible with Moodle 3, but we have used it with Moodle 4 for many months with no issues. So I can let them know, can you confirm that it does work with Moodle 4, or could this be the issue?

danmarsden commented 1 year ago

The sync users script is intended as a once off thing you can run on the cli to add existing users in the site based on your rules or if you change your rules after users have been created or if you have a process that inserts users directly into the db not using normal moodle apis. If you only use moodle ui or apis to insert users and your rules don't change you shouldn't need to run it on cron at all. Running it once a day would probably be enough(but we don't tend to run it at all as the clients that use it don't change their rules)

I'm not aware of any issues using it in 4.0

wbuk commented 1 year ago

Can I PM you a link from our service provider, who needs you to check 1 line of code that is sucking up 68% of the server resoures.

wbuk commented 1 year ago

Here is the code 840 xxxxxx 20 0 893824 456384 13120 R 68.6 0.7 10:17.01 /opt/plesk/php/7.4/bin/php /var/www/vhosts/xxxx/httpdocs/moodle/local/cohortauto/cli/sync_users.php

danmarsden commented 1 year ago

I don't engage with people "privately" to provide support/help with moodle unless it's part of a commercial agreement sorry. as mentioned above - we don't run this task on cron at all in our use of this plugin, we only run it ad-hoc as required - but the ruleset is static and doesn't change.

If your ruleset is changing regularly - just get them to set it to run once a day overnight. If your ruleset doesn't change, don't run it on cron at all.

wbuk commented 1 year ago

Thank you.