How many domains on a single Apache server?

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.


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.


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 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.