httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jan van den Berg" <>
Subject [users@httpd] Graceful: stat64 DocumentRoot directories
Date Mon, 12 Feb 2007 15:08:23 GMT


I have a couple of questions about the inner workings of the apachectl
graceful command and I can't seem to find the answer anywhere so maybe
you can help.


Normally with a graceful the following happens.

I issue a graceful.

With strace I see something like this:

{st_mode=S_IFREG|0644, st_size=680, ...}) = 0

open("/usr/local/apache/conf/sites/", O_RDONLY) = 4

fstat64(4, {st_mode=S_IFREG|0644, st_size=680, ...}) = 0

read(4, "ServerRoot /usr/local/apache\n###"..., 4096) = 680

stat64("/usr/local/apache", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096,
...}) = 0

read(4, "", 4096)                       = 0


Then I see this:

{st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0



So my config is read and the DocumentRoots from the VHost are 'statted'
on the disc.

This process/pid is done rather quickly after which I see that this
process terminates. During this time Apache functions fine!

Next I can see with strace that the main Apache thread is "taking over".
So in this case 25527.

25527 ?        Ss    10:01 /usr/local/apache/bin/httpd -k start   

 5371 ?        S      0:15  \_ /usr/local/apache/bin/httpd -k start


According to strace this happens:

stat64("/usr/home/ws/blah/", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0


Apache is "statting" all the DocumentRoot directories on disk.

This usually takes a long time and at this point Apache stops accepting
new threads! This is really painful.


My question based on my observations are:

I did a little research on the stat64 function and this seems to be a
function that causes a lot of IO. From what I gather all extended file
attributes for all dirs are processed. This seems like of lot of

1. It seems Apache does an stat64 of my DocumentRoots twice! Why? This
doesn't make sense. First with the graceful command and next the Apache
process itself.

2. Is there a way to get rid of stat64 or use a lighter/less intense
stat function?

3. Further it seems when Apache is actually restarting/gracefulling that
Apache stops accepting new threads. This isn't very convenient. What can
I do about this?


I run my Apache server from a NFS storage mount. Statting files by
querying their (extended) attributes is very costly/slow/inefficient. So
I'm running into problems; are there ways to speed this up (apart from
the obvious NFS and other filesystem optimizations I have done).

I seems Apache is statting the directories because it wants to make sure
it exists. But should I care whether a DocumentRoot from a Virtual Host
exists? I've tested deleting directories and this doesn't crash Apache.
So what's the reason behind this.


Hope someone can provide some insight.




Jan van den Berg





View raw message