Apache uses 100% CPU. Can "ps" command tell me what it is doing?
I have a SLES 10 Linux server, and some times it is maxed out by Apache to 100% CPU.
With ps ax
can I see, that Apache have spawned ~50 Apache processes.
Can e.g. the ps
command tell me what each of these Apache processes are doing?
Or perhaps some other method so I can see what web pages that triggers the problem?
My /etc/httpd/conf/httpd.conf file has this section:
# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Change the ".example.com" to match your domain to enable.
#
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from .example.com
Allow from 127. 192.168.1.
</Location>
Thus if I go to http://192.168.1.1/server-status, I get a page that tells me:
- server version
- httpd uptime
- current CPU usage
of requests being processed and # of idle workers
- a grid of what each process is doing
-
recent requests
Apache Server Status for 192.168.3.1
Server Version: Apache/2.2.3 (Red Hat)
Server Built: Jul 14 2009 06:04:04Current Time: Saturday, 17-Jul-2010 10:20:31 CDT
Restart Time: Saturday, 17-Jul-2010 10:13:12 CDT
Parent Server Generation: 0
Server uptime: 7 minutes 19 seconds
Total accesses: 51 - Total Traffic: 156 kB
CPU Usage: u0 s0 cu0 cs0
.116 requests/sec - 363 B/second - 3132 B/request
1 requests currently being processed, 7 idle workers__W_____........................................................
................................................................
................................................................
................................................................Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current processSrv PID Acc M CPU SS Req Conn Child Slot Client VHost Request
0-0 20715 0/2/2 _ 0.00 418 0 0.0 0.01 0.01 192.168.3.97 dit GET /server-status HTTP/1.1
1-0 20716 0/49/49 _ 0.00 128 0 0.0 0.15 0.15 192.168.3.97 dit GET /server-status HTTP/1.1
2-0 20717 0/0/0 W 0.00 0 520222374 0.0 0.00 0.00 192.168.3.97 dit GET /server-status HTTP/1.1
strace
can tell you what a specific process is doing at the level of system calls, but it won't give you a "50-foot view" of what is happening. You will need to piece together the system calls it's using in order to figure that out.
If you have a website with a database backend then you could look in the DBMS what commands are currently running. Maybe this could help you to narrow down where in your code of the website the load is generated.
Else you could increase the log level of the httpd daemon. Then you have more information in the logs.
There is also ltrace, which works like strace but with library calls.