I am looking for a HTTP load balancing solution that will provide the following:
1) Accept HTTP connections on port X and forward them to one of multiple other hosts (and/or ports), either randomly or in a round-robin manner.
2) If the server reply contains a certain HTTP header with a certain value (i.e. 'Magic-Number: 12345'), remember it and forward all following requests containing the same header to this server.
3) At certain intervals, perform a keep-alive test by sending a specified HTTP request to all destination servers. If either server does not reply, stop forwarding to it until it comes online again.
4) (Not crucial, but nice to have) Accept HTTPS connections from clients and translate them to HTTP connections to the servers.
The solution must consist of free and/or open source software and run under Windows 200x Server.
Any suggestions?
Update: Cygwin or Portable Ubuntu (or other Colinux distribution) are also viable options, if they are able to run the appropriate *nix solutions.
I know this is not for Windows, but I am going to answer anyways because I think that it would be really interesting in your setup to look at this aternative.
HAProxy is an HTTP Proxy (and can proxy anything else but that will be on layer 4 and below). It does just about everything you want it to do. The documentation is not very pretty, but if you actually take the time to read it, you will find it has all the info you need.
It runs on pretty much anything, so unless you're doing a lot of SSL, you won't need to buy a big, expensive machine.
I'm using nginx for a couple of years now and very satisfied with it.
nginx (pronounced as "engine X") is a lightweight, high performance web server/reverse proxy and e-mail (IMAP/POP3) proxy, licensed under a BSD-like license.
It's good at load-balancing and reverse-proxing. Check out examples here
I'm writting this out of my head/memory as I don't have anything at hand to verify whether it works correctly or not, but I hope this might be some hint for you.
So, my answer is:
Of course you can do this with Apache's
mod_proxy_balancer
. You should be able to acomplish this with something like that:So, regarding point 1, read
mod_proxy_balancer
's "Request Counting Algorithm" section.Regarding point 2: I really don't know about HTTP header parsing. Above example uses additional URL parameter
MYSESSIONID
to proxy traffic being part of the same connection to the same host. I guess you can also use cookies. Eitherway this should be handled by application identied as LB1 or LB2 (these are added as part of session id or cookie).Re 3: load balancer monitors all it's members and disables them when they're unresponsive. You can also enable/disable nodes through web interface (
mod_status
, see "Enabling Balancer Manager Support").As for the point 4, you can setup SSL enabled VirtualHost listening on port 443 that proxies all the trafic to balancer members port 80.
Check out Pound Load Balancer which does the HTTP Header based LB:
I used in the past Apache with mod_cache on a Unix environment. It worked fine with low user load, but days with heavy load the system went down all the day.
After some tests we moved to Varnish Cache and now everything works better.
The problem is that only Unix environment is supported, a new varnish windows cygwin-based version exists, but I don't now if is suitable for production environment:
I would say this is possible with IIS 7 as well, using URL Rewrite in combination with Network Load Balancing. The basics are