Aegir should check its environment condition before dispatching new tasks/crons + simple recipe

omega8cc - November 5, 2009 - 03:50
Project:Hosting
Version:6.x-0.4-alpha2
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Aegir should check its environment condition before dispatching new tasks/crons when it is easy to kill the server using just a few heavy distros with very busy crons, with batch migrate or with mass-re-verify sites/platforms on Aegir upgrade.

Before trying to implement this in Aegir as a part of future enhancements, useful to monitor resources used by sites/platforms, like CPU and RAM estimated usage based on requests/minute, sites size (numbers of users/nodes/comments) bandwidth etc. it is also possible to introduce simple server load control before running Aegir cron.

Every minute we can run from cron simple shell script to check current load and decide if we can run the Aegir dispatcher safely.

Example:

#!/bin/sh

renice -9 $$

control()
{
NOW_LOAD=`awk '{print $1*100}' /proc/loadavg`
CTL_LOAD=200
if [ $NOW_LOAD -lt $CTL_LOAD ]; then
echo load is $NOW_LOAD while maxload is $CTL_LOAD
echo ... now doing CTL...
su - aegir -c "sh /home/aegir/aegir.sh"
else
echo load is $NOW_LOAD while maxload is $CTL_LOAD
echo ...we have to wait...
fi
}
control

and /home/aegir/aegir.sh script can include just:

#!/bin/sh

/path/to/php '/path/to/drush/drush.php' hosting dispatch --root='/path/to/aegir/domain' --uri=http://aegir.domain

#1

omega8cc - November 5, 2009 - 04:18

BTW: we can also run dispatcher every 15 seconds, just for crash-test or to avoid too long waiting for safe load :)

#!/bin/sh

renice -9 $$

control()
{
NOW_LOAD=`awk '{print $1*100}' /proc/loadavg`
CTL_LOAD=200
if [ $NOW_LOAD -lt $CTL_LOAD ]; then
echo load is $NOW_LOAD while maxload is $CTL_LOAD
echo ... now doing CTL...
su - aegir -c "sh /home/aegir/aegir.sh"
else
echo load is $NOW_LOAD while maxload is $CTL_LOAD
echo ...we have to wait...
fi
}
control
sleep 15
control
sleep 15
control

#2

adrian - November 5, 2009 - 08:11

we can't depend on the /proc filesystem, and we can't depend on bash.

we need php functions to test these things if we are to test them at all, and i don't object to putting a switch into the dispatcher to not fire if the system load is too heavy.

 
 

Drupal is a registered trademark of Dries Buytaert.