I have Apache on a Linux server, and a Python script inside it (Trac, to be more specific). With a minimum traffic it consumes 99% of CPU and load average is above 3.00. Is it possible to understand somehow what it's doing there - disc, network, which files, etc.? Are the some tools to analyze what a particular process is busy with?
Edit: strace apache2 -X
showed me a lot of lines with similar content:
stat("/home/foo/apache/conf.d/trac-XXX.conf", {st_mode=S_IFREG|0644, st_size=1014, ...}) = 0
open("/home/foo/apache/conf.d/trac-XXX.conf", O_RDONLY|O_CLOEXEC) = 6
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f6a93021000
fstat(6, {st_mode=S_IFREG|0644, st_size=1014, ...}) = 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f6a9301e000
read(6, "contents of my trac-XXX.conf"..., 4096) = 1014
read(6, "", 4096) = 0
close(6)
And the same lines for every file in /home/foo/apache/conf.d/
directory (I have hundreds of them). Do you know how to interpret this information and fix the problem? Looks like Apache is reloading all config files on every HTTP request.
You can use
strace
(man strace
). As root tryor similar with
trac
instead ofapache2
. You might also want to configure LogLevel todebug
.The following edit is a wild shot in the dark, not being familiar with Trac.
In the comments following Trac ticket 3833 osimons states:
So the question is, are you using
mod_python
or plain CGI to run Trac? If you are using plain CGI, then it is clear why the Trac configuration files get read on each request.