开发者

is there a widely accepted way of presenting a "high server load" error page on LAMP?

We're actually using Solaris instead of a Linux distro, but I was wondering if there was a way more specific to开发者_开发知识库 Apache to do it.

I don't really know where to start with it past a few exec'd commands in PHP. (prstat -avm 1 1 | grep webservd | tail -1)

Some further information - I'm unfortunately in an old environment with nothing that even slightly resembles load balancing, so I have to make my own...


I don't think there's any Apache-specific way.

I once wrote a cron job that checked CPU load on each run and exited if above a certain threshold. You could run the check above, and if load is high output a 5xx status and an error. Something like:

$load = exec('prstat -avm 1 1 | grep webservd | tail -1');
if($load > $threshold) {    
    header('HTTP/1.1 503 Service unavailable - server load too high');
    die('Load is too high');
}

(I'm not sure the format of the output of prstat)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜