Server load calculation

This is a discussion on Server load calculation within the PHP Language forums, part of the PHP Programming Forums category; I've seen some sites that display a "Server load" value in percentage. I've tried to google ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-24-2005
Alvaro G Vicario
 
Posts: n/a
Default Server load calculation

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
--
Reply With Quote
  #2 (permalink)  
Old 02-24-2005
NC
 
Posts: n/a
Default Re: Server load calculation

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

Reply With Quote
  #3 (permalink)  
Old 02-24-2005
Alvaro G Vicario
 
Posts: n/a
Default Re: Server load calculation

*** 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
--
Reply With Quote
  #4 (permalink)  
Old 02-24-2005
Daniel Tryba
 
Posts: n/a
Default Re: Server load calculation

Alvaro G Vicario <alvaro_QUITAR_REMOVE@telecomputeronline.com> wrote:
>> $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.


IOW tops output?

Reply With Quote
  #5 (permalink)  
Old 02-24-2005
Alvaro G Vicario
 
Posts: n/a
Default Re: Server load calculation

*** Daniel Tryba wrote/escribió (24 Feb 2005 17:43:34 GMT):
>> 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?


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
--
Reply With Quote
  #6 (permalink)  
Old 02-24-2005
NC
 
Posts: n/a
Default Re: Server load calculation

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

Reply With Quote
  #7 (permalink)  
Old 02-25-2005
Colin McKinnon
 
Posts: n/a
Default Re: Server load calculation

NC wrote:

> 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...
>


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.
Reply With Quote
  #8 (permalink)  
Old 02-25-2005
Alvaro G Vicario
 
Posts: n/a
Default Re: Server load calculation

*** 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
--
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:38 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0