Understanding the CPU Usage in Apache server status

I was spending time on graphing the Apache Server status values in graphite ( Cpu load and busy worker etc ) .

While doing all this performance testing I was curious to know about the CPU usage,

So how does the status is saying 2.51% of CPU usage.

<dt>Current Time: Wednesday, 12-Aug-2015 06:32:02 PDT</dt>

<dt>Restart Time: Wednesday, 05-Aug-2015 11:48:40 PDT</dt>

<dt>Parent Server Generation: 0</dt>

<dt>Server uptime:  6 days 18 hours 43 minutes 22 seconds</dt>

<dt>Total accesses: 15410608 - Total Traffic: 104.8 GB</dt>

<dt>CPU Usage: u14425.6 s284.27 cu0 cs0 - 2.51% CPU load</dt>

<dt>26.3 requests/sec - 187.5 kB/second - 7.1 kB/request</dt>

<dt>8 requests currently being processed, 4 idle workers</dt>

So basically the numbers in CPU usage (system and user ) indicate the total cpu time, in seconds, that httpd has been using.

And percentage value is the amount of CPU time used over the existence of the process.

e.g. with above data :

The server is up from 6 days 18 hours 43 minutes 22 seconds i.e. (6*24)*3600+18*3600+43*60+22=585802 seconds

and it has used 14709.87 seconds ( System+user second's ) out of 629002 i.e. 14709.87/585802=0.0251  i.e. 2.51%.

On the similar lines the server-status calculates the requests/second.

e.g. with above sample values,

requests_per_second  = Total accesses / uptime in seconds

= 15410608/585802 = 26.3 

Voila, that's how the values are calculated.

So if your server's uptime is quite high  you  will always be getting the cpu usage and throughput averaged out.

And if you are relying too much on CPU Load from server status you will  loose the momentarily load spikes ( so keep watching top too :)

Happy monitoring.

comments powered by Disqus