7

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.

Vladislav Rastrusny
  • 2,671
  • 12
  • 42
  • 56
  • 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. – Stefan Lasiewski Jun 15 '10 at 00:42
  • # ls |wc -l 956 though, needed to update the number of filehandles for it to work. – user6738237482 Jun 15 '10 at 01:40
  • We have upwards of 1800 vhosts so far and no issues. I don't know what the maximum is though. – JDS Dec 20 '11 at 21:48
  • "...his Apache works **unstable** with..." - Don't you mean "stable"? – MrWhite Sep 19 '20 at 15:22

2 Answers2

8

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.

splattne
  • 28,508
  • 20
  • 98
  • 148
Ben S
  • 632
  • 3
  • 7
  • BTW, in docs there is nothing about limits other than fds – Vladislav Rastrusny Jun 14 '10 at 18:37
  • 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). – Stefan Lasiewski Jun 15 '10 at 00:40
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.

SdeWijs
  • 21
  • 2