httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Noel Butler <>
Subject Re: [users@httpd] vhosts conf file efficiency
Date Wed, 15 Feb 2012 03:58:08 GMT
On Tue, 2012-02-14 at 12:18 -0500, Sean Conner wrote:

> It was thus said that the Great Tom Evans once stated:
> > On Tue, Feb 14, 2012 at 4:32 PM, Sean Conner <> wrote:
> > >  And really, how often is Apache restarted?  On a graceful restart, it can
> > > still serve requests.
> > >
> > 
> > It's clear you have a strong opinion on this. I prefer my mission
> > critical systems not take longer than necessary to start up, whilst
> > you don't seem to mind. Each to their own.
>   What I dislike are statements like "it's faster to put all vhosts in your
> main configuration file" without anything to back it up.  Noel Butler at
> least provided some numbers (1 second for 400 files) so people have *some*
> benchmark to go by.  
>   So I can live with 5 seconds for 2,000 files if it makes administration
> easier on the rare occasions that Apache needs to be fully restarted (not
> just a graceful restart).  You prefer to save those five seconds, but don't
> mind editing a file with 2,000 vhosts.

I got bored again, using my dev box,
Note, being a dev box, I can afford the luxury of rebooting before each
test to ensure no caching...
The VH segments we use in the real world are twice as big with suexec,
rewrites, php flags and Dir specific options, but this should give you
some sort of idea using a very, very, plain and bare bones config... 

If the OP is that worried, he can use the script to do a dummy run using
all his real world config sections, which likely are two or three times
bigger than the bare test below...

Created 2000 files (see below)

 time /etc/rc.d/rc.httpd start

real    0m7.490s
user    0m1.044s
sys     0m0.584s

ls -la /usr/local/apache/conf/vhosts/ 
-rw-r--r-- 1 root root 524 Feb 15
13:25 /usr/local/apache/conf/vhosts/

Slightly changed the "open" to send to all one conf file

time /etc/rc.d/rc.httpd start

real    0m5.623s
user    0m0.976s
sys     0m0.444s

ls -lah /usr/local/apache/conf/vhosts/hosts.conf 
-rw-r--r-- 1 root root 1.6M Feb 15
13:19 /usr/local/apache/conf/vhosts/hosts.conf

Test script used -

for ($count = 2000; $count >= 1; $count--) {
$DOMAIN = $count ."";
$htroot ="/var/www/vhosts/".$DOMAIN;
open (STUFF, ">/usr/local/apache/conf/vhosts/$DOMAIN.conf");
print STUFF <<EOF;
        ServerName      www.$DOMAIN
        ServerAlias     $DOMAIN
        ServerAdmin     webmaster\@$DOMAIN
        DocumentRoot    $htroot/web
        ScriptAlias     /cgi-bin/ $htroot/cgi/
        CustomLog       $htroot/logs/access_log combined
        ErrorLog        $htroot/logs/error_log
        UserDir disabled

close STUFF;

View raw message