Load balacing PHP Crons ~ Defcon Pixey/Pixel Sleep States – 


Too load balance PHP is much the same as any c it is with the function sleep(); unlike c which is in milliseconds PHP sleep runs in seconds. This is good for example up to three or four times in a loop in up to four defcons in any PHP Cron or schedule task it load balancers cpu: 

if( mt_rand(0, 3) == 1 )

         sleep(2, 11);

Okey so you have a at best a good quickly firing – 1m Cron you want to fire multiple of everything good except the Cron job or scheduling will fire them at the same 1m execution time on the CPU so you put at the top of the Cron the following depending on number being fired say 10 X 1m Cron job of the same then you would put:

sleep ( mt_rand(1, 158) );

Advertisements