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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 -- |
|
|||
|
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 |
|
|||
|
*** 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 -- |
|
|||
|
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? |
|
|||
|
*** 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 -- |
|
|||
|
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 |
|
|||
|
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. |
|
|||
|
*** 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 -- |