Forum Moderators: phranque

Message Too Old, No Replies

Virtual hosts

Performance question

         

chrisjoha

1:44 pm on Aug 23, 2005 (gmt 0)

10+ Year Member



I'm hosting quite a few domains on my local server. I like to offer my forgetful users the ability to do typos (ie ww.domain.com will still get them the page). With many sites and some typo-insurance I end up with alot of VirtualHosts and I was wondering if that will have an impact on my servers performance? And if it does - how many VirtualHosts are too many?

encyclo

1:49 pm on Aug 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You shouldn't be making extra VirtualHosts for each variation or typo, you should be using the
ServerAlias
directive within the main
VirtualHost
for each domain:

[httpd.apache.org...]

chrisjoha

5:27 am on Aug 24, 2005 (gmt 0)

10+ Year Member



thanks! That's great. But my question is still valid. Will a big number of VirtualHost and/or ServerAlias affect performance? And what's too many (as I asked before) :)

chrisjoha

5:01 am on Aug 25, 2005 (gmt 0)

10+ Year Member



Anyone?

Romeo

10:48 am on Aug 25, 2005 (gmt 0)

10+ Year Member



Will a big number of VirtualHost and/or ServerAlias affect performance? And what's too many?

The answer to all this is: "It depends".

Most work is done by the webserver in taking HTTP requests, looking for the desired files in the filesystem, reading them and sending them out to the internet, additionally firing up interpreters for various PHP and CGI-BIN scripting stuff and sending SQL requests to database systems, where -- depending on the scripting logic -- even more (more as in "much more") performance will be needed.

Given this picture, it does not matter, if a vhost's alias list is longer or shorter -- ("if alias1 or alias2 or alias3 then the config of vhost1 apply").

And as to the number of vhosts, although the webserver has to memorize its vhosts definitons somewhere, this may be totally neglectable compared to the machines total memory and the overall workload.

Performance-wise, it is only important, how much traffic and how much scripting is going through the webserver in total.
It does not matter much, if you have
-- 10 vhosts being targeted with 1000 requests each, or 100 lame vhosts each being targeted with 100 requests, or one vhost being targeted with 10000 requests and 999 vhosts sitting idle: it is both 10000 requests the webserver would have to handle over the same given period.

Although I personally do not run such scenarios, cheap web hosters are said to put up to 1000 customer vhosts or more on one cheap Intel Linux box, in the strong hope that most vhosts are just some small greeting pages like "Hi I am Willie, and I don't know why you want to see my stuff" on 'small' web plans.

So the overall answer is: the number of vhosts does not really matter. Just go ahead and start. If a given sum of vhosts start to produce too much overall load, get an additional box to add all further vhosts there.

Regards,
R.