HTTP load balancer with header-based routing?

6,618

Solution 1

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:

ProxyPassReverse / http://host1:80/
ProxyPassReverse / http://host2:80/

<Proxy balancer://cluster>
  BalancerMember http://host1:80 route=LB1
  BalancerMember http://host2:80 route=LB2
  ProxySet stickysession=MYSESSIONID
</Proxy>

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.

Solution 2

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.

Solution 3

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

Solution 4

Check out Pound Load Balancer which does the HTTP Header based LB:

Share:
6,618

Related videos on Youtube

Anders Sandvig
Author by

Anders Sandvig

Updated on September 17, 2022

Comments

  • Anders Sandvig
    Anders Sandvig over 1 year

    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.

    • rkthkr
      rkthkr almost 15 years
      I was about to recommend Varnish it can do everything you ask for but no Windows version...
    • Anders Sandvig
      Anders Sandvig almost 15 years
      @dan As noted, 4) is not that important. It can always be solved with a tunnel or another proxy in front. :)
    • Toby
      Toby almost 15 years
      I guess the point is not that option (4) is a problem but rather what follows option (4) namely that the software must run under Win2k. Someone tag this please Windows.
    • Dan Carley
      Dan Carley almost 15 years
      Sorry, I meant #5 :)
  • Jeremy Stein
    Jeremy Stein over 14 years
    There are now Windows builds for nginx.
  • fission
    fission over 11 years
  • Steve Townsend
    Steve Townsend over 6 years
    Of course, 9 years later you can do TONS of SSL on anything. So unless you're talking about 10+Gbps of SSL traffic or higher, you're good.