advanced crontab q: off peak hours

Topics brought up by the TimeTrex open source community.
Locked
mrworldcup
Posts: 8
Joined: Tue Jul 06, 2010 9:27 pm

advanced crontab q: off peak hours

Post by mrworldcup »

Hello again,

Got a few questions about TimeTrax's crontab config. The readme file that comes with TimeTrex suggests that timetrax's cron.php needs to run every minute (as well as some of these forum posts which suggest architectural or historical reasons for the software currently doing so [1] [2])

Various posts have attempted to suggest the possibility of running at alternate times, or wider cron intervals, to which the most notable rebuke to these posts I found to be [3].

In my setup, I want to run the appropriate cronjobs at night and during off peak hours on the server. I also want to support being able to better profile (for both security and load purposes) the server utilization 'signature' attributed to running this software (as well as observing how this may vary over time as the TimeTrex deployment grows and gets more complex with more data).

How can we achieve this goal? Perhaps I can offer to setup my timetrex deployment in such a way to support longitudinal investigation of this possibility.







[1] quoting: "but TimeTrex needs one minute timing resolution for future purposes, so thats the reason it runs so often. 99.9% of the time it just exits without doing anything."
http://forums.timetrex.com/viewtopic.php?p=3564#p3564

[2] it has been this way since 2007 (or earlier) according to the timestamp of this post
http://forums.timetrex.com/viewtopic.php?p=2893#p2893

[3] maint. jobs take a while to run if not run several days
http://forums.timetrex.com/viewtopic.php?p=3990#p3990

[4] "Not all cron jobs run everytime cron.php is executed."
http://forums.timetrex.com/viewtopic.php?p=1010#p1010
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Re: advanced crontab q: off peak hours

Post by shaunw »

Changing how often crontab runs the TimeTrex maintenance jobs won't affect server load virtually at all. As mentioned in other posts, 99% of the time the maint.php exits immediately and does nothing, so the affect that this has on server load is virtually unnoticeable.

Changing it to every 10 minutes for example will only reduce the responsiveness of some tasks (like adding new schedules), and may actually hurt server performance because now it has essentially 10x more work to do at once, requiring more resources and slowing down everything else. That is one reason why it runs so often, so the work that it does can be broken up into small bite size chunks that don't become resource hogs on the server, the less often it runs, the larger the chunks of work need to be and the greater the number of resources are used at any one time.

The majority of the jobs do run just after midnight, but some of the jobs need to be run constantly throughout the day, and these are the ones that benefit from being run more often in smaller "chunks".
mrworldcup
Posts: 8
Joined: Tue Jul 06, 2010 9:27 pm

Re: advanced crontab q: off peak hours

Post by mrworldcup »

Hey, thanks for responding and providing that detail. After reading your post which suggested that having tasks run less frequently, as was observed, "may actually hurt server performance", I just thought to ask something:

When I've setup cron entries for other tasks in my 'crontab -e', I usually prepend the 'nice' command (for example, something like 'nice -n 15') before the task which i find is a good way to be more considerate of my surroundings.

For instance, the crontab entry defined in templates/install/MaintenanceJobs.tpl would change

from:

Code: Select all

* * * * * su <b>www-data</b> -c "php {$cron_file}" > /dev/null 2>&1
to:

Code: Select all

* * * * * su <b>www-data</b> -c "nice -n 15 php {$cron_file}" > /dev/null 2>&1

Have you guys considered this? Has there been any experimentation in this direction? Hmm... Would this potentially cause any problems/instability with the design of the software that I'm not aware of?
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Re: advanced crontab q: off peak hours

Post by shaunw »

Its not a problem at all to renice the maintenance jobs, unless your sever is so busy already that it causes them to take too long to run of course.
mrworldcup
Posts: 8
Joined: Tue Jul 06, 2010 9:27 pm

Re: advanced crontab q: off peak hours

Post by mrworldcup »

Hey shaun,

When you said nicing the crontab tasks would 'renice' the maintenance jobs, does that mean the jobs were already 'nice'd (per the unix command 'nice'?)

I grepped through for the 'nice' command in the TimeTrex directory and didn't see the command 'nice' in use. Perhaps I am wrong, but maybe I think you mean the maintenance jobs are 'nice'd' in the sense that 99% of the time when the cronjob kicks off it does nothing?

thanks, i'm curious... as you can tell, i very much trend server usage. ; )
Locked