Cron load issue

Cron load issue

by Randy Obert -
Number of replies: 6

Greetings:

I am the owner of a webhosting company that uses Fantastico and it also installs Moodle.  Our servers are loaded fairly light and so we allow crons to be installed by clients provided that they are well behaved crons.

I have a client that is running "cron.php" every 15 minutes and this script is buring 30% of the total CPU every 24 hours.  Even with lightly loaded servers I hope you can understand why we can not allow a single user to occuply fully 1/3 of the available CPU time.  

I do not have time to dig in to Moodle and learn about it, so in the interest of providing a hosting site that is favorable to this software, I was hoping that someone here could just give me the lowdown on the cron and why it might be such a CPU hog. 

Thanks

Average of ratings: -
In reply to Randy Obert

Re: Cron load issue

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Cron runs jobs like sending email from forums, cleaning up old users, calculating summary statistics, creating RSS feeds etc. Mnay of the things it does INCREASE general performance and drop load overall.

Usually each cron job runs in about 10 seconds for moodle.org (this site) which is a pretty big one.

It's possible something is misconfigured on your server, like email, otherwise it might just be a very busy Moodle site.

Try running the cron.php manually from the command line (php admin/cron.php) or from the browser to see what it is doing, that should provide some clues.
In reply to Martin Dougiamas

Re: Cron load issue

by Martín Langhoff -
A couple more ideas...

* Running cron.php directly with the CLI php4 binary is more efficient than triggering it via Apache (using curl or wget). That should ease the load (memory and cpu) on your server.

* If you are performing database-level backups, it may make sense to indicate that to your users. Moodle has an app-level backup facility that gets triggered on a daily cron and can be quite heavy for really large installs. There's an option as well to disable it entirely from config.php

* The other CPU-bound task is the stats calculation. Also once a day, and strictly optional (and not recommended for hosted sites).

All these options are settable from the admin->variable pages.

Hope that helps!
In reply to Martín Langhoff

Re: Cron load issue

by Samuli Karevaara -
"Moodle has an app-level backup facility that gets triggered on a daily cron and can be quite heavy for really large installs. There's an option as well to disable it entirely from config.php"

If the slowdown was happening every 24 hours, I'd guess the reason is this. There might be some courses with a lot of files and/or big log tables, which get compressed every day to backups. This would also show as a jump in used quota after every slow cron job.
In reply to Martín Langhoff

Re: Cron load issue

by Randy Obert -

I have run the cron from the command line and it seems to execute in pretty short order, however the stats collection is something I did not know about. (a big issue with many CMS's that are installed btw).  I moved his cron back to every 30 minutes for now and will look into the stats collection. As we already provide Urchin, Webalizer, Analog, and one other, I see no reason for yet another.

I will update this thread when I get a handle on this issue.

Thanks guys for the help

In reply to Randy Obert

Re: Cron load issue

by Randy Obert -

The cron the owner set was entered twice. I have removed the second identical cron and hope this fixes the issue. My bad for not spotting this on my first pass thru the spool folder.

In reply to Randy Obert

Re: Cron load issue

by Scott Elliott -
I can't really address your issue except to say you've got a good answer from the Main Moodler himself smile

I did want to say I appreciate the fact that you are seeking help in finding out how to make your company better serve Moodle users!  The easy thing to do would be to "pass the blame" and just say "it's not our problem".  Good luck in straightening things out!

Scott