I'm trying to work out a solution in my head where two backend linux-servers run HTTP, SMTP, XMPP mirrored and should load balance connections between them.

My current solution is an OpenBSD box infront, that can of course be extended with carp to add more in the future to avoid single point of failure. Using PF I could have a pool of servers to send traffic to, using random or round-robin methods.

And using relayd I can remove non-functioning pool-servers from it.

But I would value the opinions of the community on this matter, so please tell me your best Unix load balancing solution for this type of environment.

One goal would be that a single server should be allowed to fail with minimal service interruption.

6 Answers
6

I'm only familiar with a pure Linux combination of heartbeat and ldirector (both part of the linux virtual server project to IP tunnel traffic from a pair of front-ends to N back-ends, and to share/swap a front-end IP between two front-ends when one dies. It worked very well in the environment I used, but I'm not sure whether it is vulnerable to split-brain issues.

HAProxy has been compiled on a bunch of *nix platforms, including the BSDs and Solaris (and of course Linux). If your load balancer isn't running Linux, it's a very convenient and configurable piece of software. It knows about HTTP but can also balance any TCP service it knows nothing about. It can check servers and will remove from service any that aren't responsive (or aren't responsive enough).

There's one drawback to it: it only talks to the internal (back-end) servers via IPv4 (incoming IPv6 connections are load balanced fine, it's just the internal connection that's limited to IPv4). If your server farm is on a dual-stack setup, that's not an issue.

To answer the question, Yes you can use Linux to load balance two other linux servers ( their services actually). I use Piranha to be more specific for this. Piranha is a managing layer on the top of LVS clustering system. The nice and detailed howto by Redhat is at http://www.redhat.com/support/resources/howto/piranha/

LVS is short for Linux Virtual Server. Lots of info can be found at linux-ha.org
Basically the linux kernel has a built in load balancer called IPVS. As such is is extremely well tested and supported. Its also been around for a looong time, (Kernel 2.0 days I believe).
There are numerous utilities for managing the load balancer such as ldirector and piranha. Ldirector is probably the most prominant one. What these utilities are responsible for doing is periodically health checking your back end servers and making sure theyre still there and operating properly. Should it find that the server is gone, it will remove that server from the kernel's IPVS table and effectively remove it from the pool. These utilities are by no means required, as you can interface directly with the IPVS table using ipvsadm.

Pacemaker is the successor to Heartbeat which has been the standard utility for clustering for a long time. Heartbeat has been deprecated in favor of Pacemaker (heartbeat is no longer being maintained), so while you can still use Heartbeat if you wish (it is definitely simpler to configure), its end is coming.
The reason I mention this utility is that without a pair of load balancers in the front, youre really just moving the single-point-of-failure somewhere else. Instead of a single backend server being able to fail, now a single load balancer can fail and youre in the same boat. Pacemaker will ensure that a load balancer is always running. Should the currently active load balancer fail, the other one will take over. An additional benefit of pacemaker is that it allows you to run both load balancers in an active/active setup if you have multiple IPs (heartbeat cannot do this).