I'm about to deploy two distinct systems: A MySQL cluster and a cluster of Jetty web-servers.


I can get more linux servers for the HA/LB, but which software should I use? I'm with CentOS.

I've heard of HAProxy, LVS and UltraMonkey.
I've read much of their documentation but it's not clear if they support MySQL AND HTTP/S (both).
I want one solution that takes care of both, for simplicity (instead of dealing with two).

  • The solution should be open-source as the three above.
  • SSL (MySQL & HTTPS) should be possible.
  • "Sticky Sessions" are NOT a requirement, as I intend to have Jetty's sessions shared at the MySQL database.


I've read that the load-balancing can be done in three ways:
- Direct Routing << LAN switch dependant?
- IP-IP Encapsulation (Tunnelling) << sounds best. not bound to LAN, as opposed to "Direct Routing"
- Network Address Translation << extremely limiting (replies from app service go through the LB)

The bottom line regarding performance, which worries me, is that eventually it's possible (and I don't want it) that all the data between internet users and my cluster is going through one server (the balancer), which makes the balancer a bottle-neck.
If it's connected with a 100MBit connection then the whole system is limited to that.
Is it possible to avoid that, yet get balancing and high availability? What is the "cost" to that? Do I need a special switch on the network or not?

  • Mind the "Sticky Sessions" note, as I just realized it relates to the load-balancer forwarding requests from a client to the same service node.. – Poni Nov 10 '11 at 21:10

Good that you do not have to rely on the LB (load-balancer) for the session-information.

Your need for speed leads IMHO to LVS and the "direct routing" approach. You CAN do direct routing without using the ip_forward mechanism. I set this up by using a dedicated lvs-network from the LBs to the real-servers.

Now for the "need for speed": with direct routing the LB takes the incoming requests, changes their destination MAC and put them on the line to the RS. Now the RS has to have the logical IP on the LVS-network (but should not answer to arp-requests for that IP). The RS will serve the request and will answer DIRECTLY to the client - the the back-answer will not go back through the LB, thus minimizing the load on the LB.

Additionally your ingoing traffic is most propably much lower than the outgoing traffic - so that suits your needs.

The last weak point is the availabilty of the LB itselv. You can cluster the LB with another machine that takes over the logical IP (and lvs). Since session stickyness is no problem in your setup - that`s all you have to do.

I found lvs-kiss to be a good possibility to dynamically reconfigure lvs - but there are other working solutions for this.

BTW - most of the servers where we use LVS are CentOS 5.

Update 2011-11-11: heartbeat-ldirectord is an addon for heartbeat and then you do not need lvs-kiss - if you want to cluster anyway.

  • Nils your answer made me smile :) Thank you! So you're saying that LVS "Direct Routing" is good for me (direct answer from the RS). Ok. Question ONE: Correct me if I'm wrong, but that means that all the servers should be connected with the same switch/router, no? That's because MAC address should be known, or something? Again, correct me if I'm wrong. Question TWO: You say: "You can cluster the LB with another machine that takes over the logical IP (and lvs)". I know I can simply install another instance of LVS, but how do I instruct it to "take-over" when the other one dies? – Poni Nov 10 '11 at 22:09
  • 1. No - the machines do not have to be connected to the same switch/router. Your can use routed networks for LVS and "live" networks. They just have to be the same networks (lvs will propably even work on different networks). Just make sure the lvs-networks are different from the live ones. The only known MAC-Address is that of the Director. And the director has to know the IPs for the RS on the lvs-network. 2. Cluster the machines with heartbeat. Use the V1-Syntax in the haresources-file and define the logical IP as resource. Or use heartbeat-ldirector - that works well with lvs. – Nils Nov 11 '11 at 21:51

Load balancing:

  • for Mysql LB you can use Mysql Proxy (or better do it in the application layer);
  • for LB web server I suggest nginx.

For HA I suggest look at the pacemaker It's robust, scalable and flexible solution for clustering and high availability.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.