Jake29
04-15-2002, 06:03 PM
Is there a great performance penalty for configuring 600 name based virtual hosts in apache.conf, as opposed to using mod_dynvhost? I don't have any experience hosting this many sites w/ apache. I want to keep all logs seperate, etc, so a big apache.conf seems like it's actually more conveinent for me. Any comments?
Jake
cperciva
04-15-2002, 06:20 PM
There is a major penalty associated with holding a large number of log files open at once. Quite apart from the management overhead, there is an increase in required buffers and an increase in disk seeks.
Is there a problem with using a single logfile and splitting it daily?
Jake29
04-15-2002, 08:44 PM
Well, I was hoping to deliver/monitor stats in real time. Is using "tail -f " piped to a perl script against a single tranfer and log file (where the script writes seperate log files) any more efficient then opening the seperate log files directly through apache? Do you have another approach that occurs to you that would be superior?
Jake
cperciva
04-15-2002, 08:54 PM
How "real time" does it have to be? Even splitting the log file every five minutes would be better than holding many files open at once. (Having a perl script hold many files open is no better than having Apache do so.)
The important point is that when you batch the log splitting, you can sort the lines and then append an entire block to each split logfile at once.
Jake29
04-15-2002, 09:17 PM
Thanks for the explanation! I guess I'll set up a log splitter as a cron job.
Jake
I believe that in the Apache docs they tell how to format the logfile to be able to use one log.
Jake29
04-15-2002, 10:18 PM
Thanks JTY! Here's the relevant exerpt of the Apache docs, for posterties' sake:
Virtual Hosts
When running a server with many virtual hosts, there are several options for dealing with log files. First, it is possible to use logs exactly as in a single-host server. Simply by placing the logging directives outside the <VirtualHost> sections in the main server context, it is possible to log all requests in the same access log and error log. This technique does not allow for easy collection of statistics on individual virtual hosts.
If CustomLog or ErrorLog directives are placed inside a <VirtualHost> section, all requests or errors for that virtual host will be logged only to the specified file. Any virtual host which does not have logging directives will still have its requests sent to the main server logs. This technique is very useful for a small number of virtual hosts, but if the number of hosts is very large, it can be complicated to manage. In addition, it can often create problems with insufficient file descriptors.
For the access log, there is a very good compromise. By adding information on the virtual host to the log format string, it is possible to log all hosts to the same log, and later split the log into individual files. For example, consider the following directives.
LogFormat "%v %l %u %t \"%r\" %>s %b" comonvhost
CustomLog logs/access_log comonvhost
The %v is used to log the name of the virtual host that is serving the request. Then a program like split-logfile can be used to post-process the access log in order to split it into one file per virtual host.
Unfortunately, no similar technique is available for the error log, so you must choose between mixing all virtual hosts in the same error log and using one error log per virtual host.
Jake29
04-15-2002, 10:25 PM
Not trying to beat a dead horse here, but the docs say that error logs can not be parsed per vhost. I know that cpanel-based resellers offer individual error logs. Does this mean that their configuration must open an error log for each vhost in apache.conf? Or is there some clever work-around?
Jake
-just tryin' to understand this stuff