What is the maximum number of virtualhosts Apache can handle?

16,746

Solution 1

I would read over the Virtual Hosts Documentation.

If each virtual host has its own log, the limit is likely 64 due to file descriptor limits. However, you can configure Apache to run more using this guide.

Solution 2

At our company we have about 7000 vhosts on a Plesk VPS. In a nutshell, we create single product marketing websites for customers, where each website has it's own unique TLD. In itself this never triggered any issue for performance of Apache, but we did run into other challenges.

Because we create about a 100 new websites each day, Apache needs to restart very often to enable the newly added vhost files. To cover for this, we implemented a caching layer to prevent timeouts on the website each time the server restarts. The real problem comes with handling the large amount of DNS records on the VPS, which pushes the limits of a Plesk server. We are now planning to use an external DNS service like Amazon route 53 to handle the DNS records instead of Plesk.

Share:
16,746

Related videos on Youtube

Vladislav Rastrusny
Author by

Vladislav Rastrusny

Updated on September 17, 2022

Comments

  • Vladislav Rastrusny
    Vladislav Rastrusny almost 2 years

    What is the maximum number of VirtualHosts Apache can handle on a single machine (I don't mean anything related to load, let's suppose it's irrelevant for the question). And we take only Apache without any proxifying things like nginx.

    I am asking because on one forum one guy reported that his Apache works unstable with the number of sites more than 400 on a single machine.

    If you have a config, that handles more than 400, please tell me here.

    Thanks.

    • Stefan Lasiewski
      Stefan Lasiewski about 14 years
      If someone claims that Apache is unstable when running 400 hosts on a single machine, it's probably because he's running into load and resource limits on that machine. You say that load is irrelevant for the question, but then you reference someone who is likely running into load issues.
    • JDS
      JDS over 12 years
      We have upwards of 1800 vhosts so far and no issues. I don't know what the maximum is though.
    • MrWhite
      MrWhite almost 4 years
      "...his Apache works unstable with..." - Don't you mean "stable"?
  • Vladislav Rastrusny
    Vladislav Rastrusny about 14 years
    BTW, in docs there is nothing about limits other than fds
  • Stefan Lasiewski
    Stefan Lasiewski about 14 years
    An easy solution to the FD limits would be to remove the log configuration from your VirtualHost sections, and instead use the global logging configuration in httpd.conf. This way everything is logged to one access log and one error log. Just be sure to log the VirtualHost name in the logfile. Why have 64 Access Logs plus 64 Error logs when you could simply have 2 logfiles, and then parse out the VirtualHost name afterwards (Hopefully after you ship them to a non-webserver host).