How to configure apache with mod_cache and mod_proxybalance for massive virtual hosting

apache-2.2load-balancemod-cachevirtualhost

I have a farm of IIS servers which provides something akin to domain parking sites, with thousands of domains assigned to the system, and content generated dynamically. I need a load balancing and cacheing solution. My intention is to use Apache 2.2 with mod_cache and mod_proxybalance to accomplish this.

My previous experience with Apache has been rather limited, and usually dealing with only a few name based virtual hosts. I've never implemented load balancing or proxying with it before.

While researching a configuration, i'm left scratching my head over some basic configuration directives that i'm not certain how to configure for this environment. In particular, the apache docs give dire warnings about not configuring ServerName directives properly. In this situation, I'm not sure how to handle this.

The site isn't serving it's own content, but rather cached and proxied content. I can't put every domain name into seperate virutalhost directives. Are directives like ServerName (or other directives that seem to require domain names) even necessary in this situation?

EDIT:

If you would like to propose other solutions, i'm open to them. So far, ngnix has been proposed, but ngnix cannot proxy name based virtual hosts due to it's proxy code only using http 1.0 to the backend servers. I'm also uncertain if it can cache name based virtual hosts.

Varnish looks like a possible cacheing solution, but i would really like something I can host on the same server so I don't need multiple servers for each function.

Best Answer

If you intend to replace the backend, mod_vhost_alias

Otherwise, if you are just putting caching in front of your existing solution, Varnish or Squid would be better suited. Varnish has built-in support for backend load balancing, health checks, etc. You could also run a pair of ipvs servers in front to load balance and provide 100% uptime to a pair (or more) Varnish servers.