I'm hosting about 300 domains for my clients on a single Apache server. They all don't have much traffic, so the server load is not a problem.

Theoretically there should be no limit how many of such low traffic domains I can have on the server, but I'm worried that if I have too many domains on the server, the sheer list of domains to check for each incoming request will slow Apache down.

Is there a rule of thumb how long an Apache config can be and how many different domains it can handle without an issue? Are 500 ok? 5000?

Clarifying: I'm not asking about how much traffic a server can handle. I know this specific server can handle at least twice the amount of its current traffic. I want to know if the number of domains is a critical factor or not.


I've seen servers with literally thousands of domains running without problems. Performance does not significantly degrade just by the number of sites you're running.

It's the overall number of requests and how much CPU (and other resources like bandwidth, disk IO, database calls etc.) is required per request that influence the server's responsiveness.

  • +1 - the amount of CPU time taken to even do a serial scan of a 10,000 entry array stored in RAM is negligible. – Mark Henderson May 14 '11 at 11:06

There's no magic rule of thumb for this kind of thing. It's all based on hardware specs and software tuning. You're not going to add one new site and then see your server tip over and choke to death (unless it's a really high usage site right out of the gate and you're not prepared for it). As with most things, you need to monitor your server performance, and when you start to see it slow down, evaluate at that point and see about hardware upgrades or a new server to handle new domain hosting. And so to answer your clarifying point, it's not about number of domains, it's about what each domain is bringing individually as load to the server. No magic number.

  • As specific an answer can be to this question... – Software Mechanic May 14 '11 at 9:58
  • 3
    Gene, to backup what Holocryptic says, imagine the workload generated by 500 (or 5000) websites with one or two static pages in them. Now imagine the workload generated if you host just one website. But what if that website happens to be google.com or facebook.com - number of domains isn't the issue, its the work those domains are asking the server to do. – Rob Moir May 14 '11 at 10:13
  • @Robert Moir: I'm not asking about the traffic the server can handle. I want to know if the number of domains or length of the config file is a factor. – Gene Vincent May 14 '11 at 10:16

You may find http://httpd.apache.org/docs/2.2/vhosts/details.html#hostmatching informative. Apache uses a hash table to handle VHosts that aren't mapped to *:80, then iterates over a linked list of all the VHosts assigned to that IP:port in order to find the matching Server(Name|Alias). You'd probably need to host millions of domains before that process got noticeably expensive.

You may also want to take a look at http://httpd.apache.org/docs/2.2/vhosts/mass.html and benchmark this against your current approach; once you get enough VHosts that the linked-list traversal takes more time than an lstat(), VirtualDocumentRoot will end up being faster than individually-specified VHosts.

  • I'm using name-based virtual hosts and it seems Apache only uses the hash table for IP-based virtual hosts, resulting in a linear search. – Gene Vincent May 14 '11 at 16:13
  • Correct. Sorry if my answer wasn't as clear as it could have been on this point: the hash table is used to select which linked list to iterate over, not (directly) to select which VHost should serve a given request (except when not running NameVirtualHost). – BMDan May 15 '11 at 2:55

I have some VPS servers which host about 8000+ domains. The server is running fine, average load always at 0.xx level. I guess it can handle more without problem. It will need longer time to re-compile Apache when adding or deleting a domain. Also, the httpd.conf file is quite big, around 60M. It's safer to limit the number of domains to around 5000.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.