SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Central Illinois
    0 Post(s)
    0 Thread(s)

    Good maximum number of virtual hosts?

    I'm starting to resell some hosting. At the moment I'll be pleased if I can come up with ten clients in the next few months, but I have some great marketing opportunities coming up toward the end of this year, and looking down the road, I can imagine getting several hundred customers.

    So in planning for the future, I was wondering what a good maximum number of virtual hosts would be to put on each server. I'm not talking about what the server itself can handle, I know that will depend on the traffic and server load the sites generate. Rather, I'm wondering how many VirtualHost directives is a good maximum in the httpd.conf file.

    I've heard that having too many can result in slow performance, even if the server load is way below capacity.

    Any thoughts, suggestions or ideas?

    Thanks a lot,


  2. #2
    SitePoint Guru MikeBigg's Avatar
    Join Date
    Jun 2004
    Reading, UK
    0 Post(s)
    0 Thread(s)
    Last edited by MikeBigg; Jan 16, 2007 at 11:10.

  3. #3
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    20 Post(s)
    3 Thread(s)

    Apache has that covered here where it states:

    E. Configuration Questions

    1. Why can't I run more than <n> virtual hosts?

    You are probably running into resource limitations in your operating system. The most common limitation is the per-process limit on file descriptors, which is almost always the cause of problems seen when adding virtual hosts. Apache often does not give an intuitive error message because it is normally some library routine (such as gethostbyname()) which needs file descriptors and doesn't complain intelligibly when it can't get them.

    Each log file requires a file descriptor, which means that if you are using separate access and error logs for each virtual host, each virtual host needs two file descriptors. Each Listen directive also needs a file descriptor.

    Typical values for <n> that we've seen are in the neighborhood of 128 or 250. When the server bumps into the file descriptor limit, it may dump core with a SIGSEGV, it might just hang, or it may limp along and you'll see (possibly meaningful) errors in the error log. One common problem that occurs when you run into a file descriptor limit is that CGI scripts stop being executed properly.

    As to what you can do about this:
    1. Reduce the number of Listen directives. If there are no other servers running on the machine on the same port then you normally don't need any Listen directives at all. By default Apache listens to all addresses on port 80.
    2. Reduce the number of log files. You can use mod_log_config to log all requests to a single log file while including the name of the virtual host in the log file. You can then write a script to split the logfile into separate files later if necessary. Such a script is provided with the Apache 1.3 distribution in the src/support/split-logfile file.
    3. Increase the number of file descriptors available to the server (see your system's documentation on the limit or ulimit commands). For some systems, information on how to do this is available in the performance hints page. There is a specific note for FreeBSD below.

    For Windows 95, try modifying your C:\CONFIG.SYS file to include a line like


    Remember that you'll need to reboot your Windows 95 system in order for the new value to take effect.
    4. "Don't do that" - try to run with fewer virtual hosts
    5. Spread your operation across multiple server processes (using Listen for example, but see the first point) and/or ports.

    Since this is an operating-system limitation, there's not much else available in the way of solutions.

    As of 1.2.1 we have made attempts to work around various limitations involving running with many descriptors. More information is available.

    In short, you'll run out of system resources before Apache tires of handling your Virtual Hosts.

    Another problem will be the pipe that you use to service all your domains - got a gigabit connection?


    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts