http://www.php.net/manual/zh/function.sys-getloadavg.php
<?php
/**
* Set some rules to skip the visit of some pages, for avoiding DDOS attack.
* Check system avg load, if too heavy, not allow to visit the page.
*/
$load = sys_getloadavg();
if ($load[0] > 80) {
header('HTTP/1.1 503 Too busy, try again later');
die('Server too busy. Please try again later.');
}
?>