For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > February 2005 > Server load calculation









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Server load calculation
Alvaro G Vicario

2005-02-24, 3:56 pm

I've seen some sites that display a "Server load" value in percentage. I've
tried to google out the formula they may be using but I couln't find it.
I'd like to implement such a thing in a Linux server but the typical values
returned by "uptime" (number of queued processes) are not as easy to
understand as a simple %.

Any idea? Thank you in advance,


--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
NC

2005-02-24, 3:56 pm

Alvaro G Vicario wrote:
>
> I've seen some sites that display a "Server load" value in

percentage.
> I've tried to google out the formula they may be using but I couln't
> find it. I'd like to implement such a thing in a Linux server but
> the typical values returned by "uptime" (number of queued processes)
> are not as easy to understand as a simple %.


How about this:

$load_info = `top -l 1`;

Now $load_info contains the output of the 'top' command, which
lists CPU and memory usage...

Cheers,
NC

Alvaro G Vicario

2005-02-24, 3:56 pm

*** NC wrote/escribió (24 Feb 2005 09:24:37 -0800):
> $load_info = `top -l 1`;
>
> Now $load_info contains the output of the 'top' command, which
> lists CPU and memory usage...


Not in my version (Red Hat 9). In any case, I don't really want mere CPU
usage but a sort of average of all resources that gives and idea of how
busy the system is. 100% CPU doesn't mean the server is collapsed.


--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Daniel Tryba

2005-02-24, 3:56 pm

Alvaro G Vicario <alvaro_QUITAR_REMOVE@telecomputeronline.com> wrote:
>
> Not in my version (Red Hat 9). In any case, I don't really want mere CPU
> usage but a sort of average of all resources that gives and idea of how
> busy the system is. 100% CPU doesn't mean the server is collapsed.


IOW tops output?

Alvaro G Vicario

2005-02-24, 3:56 pm

*** Daniel Tryba wrote/escribió (24 Feb 2005 17:43:34 GMT):
>
> IOW tops output?


This is top's output:

6:45pm up 2:32, 1 user, load average: 0,00, 0,00, 0,00
64 processes: 63 sleeping, 1 running, 0 zombie, 0 stopped
CPU states: 0,1% user, 0,3% system, 0,0% nice, 99,4% idle
Mem: 61676K av, 59836K used, 1840K free, 0K shrd, 5560K
buff
Swap: 196520K av, 10552K used, 185968K free 21068K
cached


I'm looking for something like:

0.12%


I don't know the English word, in Spanish we say "numeros indice" (index
numbers?). Like those that summarize the health of stock exchange in one
figure ;-)


--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
NC

2005-02-24, 8:56 pm

Alvaro G Vicario wrote:
>
> This is top's output:
>
> 6:45pm up 2:32, 1 user, load average: 0,00, 0,00, 0,00
> 64 processes: 63 sleeping, 1 running, 0 zombie, 0 stopped
> CPU states: 0,1% user, 0,3% system, 0,0% nice, 99,4% idle
> Mem: 61676K av, 59836K used, 1840K free, 0K shrd, 5560K

buff
> Swap: 196520K av, 10552K used, 185968K free 21068K

cached
>
> I'm looking for something like:
> 0.12%


OK, who says you can't make it up? The output above shows that
the server's CPU load is currently 0.6% (100% - 99.4%), memory
load is 97.0% (59836 / 61676), and swap space occupation is 5.4%
(10552 / 196520). If you believe all three resources are
equlally important for your application, you can compute a
simple average of the three:

$load = ($memory_load + $CPU_load + $swap_load) / 3;

If you think some resources are more important than others, you
can weigh them accordingly. Say, you think memory is twice as
important as CPU availability and four times as important as swap
space. So you can compute a weighted average:

$load = (4 * $memory_load + 2 * $CPU_load + $swap_load) / (4 + 2 + 1);


> I don't know the English word, in Spanish we say "numeros indice"
> (index numbers?). Like those that summarize the health of stock
> exchange in one figure ;-)


Same thing, an index. And, just like a stock index, yours can
be either equally weighted (first example) or capitalization-
weighted (second example)... :)

Cheers,
NC

Colin McKinnon

2005-02-25, 8:56 am

NC wrote:

> Alvaro G Vicario wrote:
> percentage.
>
> How about this:
>
> $load_info = `top -l 1`;
>
> Now $load_info contains the output of the 'top' command, which
> lists CPU and memory usage...
>


Yes, but:

1) 'top' generates quite a lot of load itself - try `cat /proc/loadavg`
2) load can't be claculated as a % (CPU utilization, disk & network
bandwidth can) but is still a better measure of availability
3) If you've got your webserver properly configured then a useful measure
might be the # of httpd processes/threads - which should have an upper
limit set, and therefore % is calculable.

HTH

C.
Alvaro G Vicario

2005-02-25, 3:57 pm

*** Colin McKinnon wrote/escribió (Fri, 25 Feb 2005 10:07:40 +0000):
> 3) If you've got your webserver properly configured then a useful measure
> might be the # of httpd processes/threads - which should have an upper
> limit set, and therefore % is calculable.


That's an excelent idea. It'll try to design my own index number based in a
weighed average using, among other, the % of httpd processes. Thank you
everyone.


--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com