Any problems with having an active/active HAProxy setup with Keepalived

11,013

The important considerations not to have an active/active setup with two virtual IP addresses for the same resource is

  • how do you distribute requests over the two virtual IP's
  • how do you deal with sticky sessions, affinity, persistence and such, i.e. what happens when subsequent requests start off going to virtual IP1 and then go to virtual IP2 and do you need those to go the same back-end server.
  • what happens when the virtual IP-addresses fails over to the other host?
Share:
11,013

Related videos on Youtube

Luke Cousins
Author by

Luke Cousins

Updated on September 18, 2022

Comments

  • Luke Cousins
    Luke Cousins almost 2 years

    Apologies if this has been asked before, but I can't seem to find much on it.

    We're going to be using HAProxy to load balance our MariaDB Galera Cluster. All the articles/tutorials I have seen on this use Keepalived (or something similar) for an active/passive HAProxy setup.

    Is there any good reason why you shouldn't have an active/active setup?

    Each HAProxy node can have a fixed IP and both have a floating IP. Under normal conditions requests are shared between the two HAProxy nodes, if one goes down, the other takes it's floating IP and handles requests under both IPs. When the other comes back up it takes its floating IP and share of load back again.

    I'd appreciate your opinions on this.

    Luke

    • Luke Cousins
      Luke Cousins over 10 years
      I have found this article on the topic huinn.wordpress.com/2012/01/02/keepalived-2-active-servers but I don't understand why not many people seem to do it.
    • Luke Cousins
      Luke Cousins about 9 years
      Just in case anyone is reading this now, we went with this solution over a year ago and have never had any issues with it. I'd recommend it.
  • Luke Cousins
    Luke Cousins over 10 years
    I appreciate your response. In my case I was intending to "randomly" pick one of the two virtual IPs to be the one to use to connect to the database with. If for some reason that fails, try the other (but it shouldn't fail for long if one does go down). In this case of a DB server, sticky sessions, etc are not as issue, but it is a good point with regard to other areas where it may need a work-around, or be a show-stopper. Regarding your third point, will Keepalived not try to bring the IP back when it's main node comes up again?
  • HBruijn
    HBruijn over 10 years
    The MySQL Query Cache may be a good reason in some scenario's to maintain sticky sessions even with load balancing database queries.
  • Luke Cousins
    Luke Cousins over 10 years
    That's an interesting point, that again I hadn't thought of. In our case we have the MySQL Query Cache disabled due it to being a single point of contention and a couple of other reasons (it slows down all selects, even most non-cachable ones, and all writes (invalidating caches)). Do you know of any other reasons why you would want MySQL stickiness? Thanks.
  • Juan Penaloza
    Juan Penaloza over 5 years
    Any reason sourceIP hash stickyness shouldn't be sufficient here? We use this successfully. Of course, if quorum changes, the stickiness will be disrupted once.
  • Luke Cousins
    Luke Cousins about 4 years
    Thanks @user5994461 that's a useful (and interesting) update, but keepalived has been obsolete for a while because it doesn't work in virtual clouds (AWS) is misleading. It's not obsolete, it just doesn't work in all scenarios, like AWS, it would still work just fine in the use case we had 6 years ago. Its last commit on GitHub was today github.com/acassen/keepalived/commits/master
  • Luke Cousins
    Luke Cousins about 4 years
    Additionally, All public websites run behind a CDN... is completely incorrect, lots of websites run behind a CDN. Most don’t. Cloudlfare is the biggest CDN by number of sites by a long way and only have 12.7% of all known sites. w3techs.com/technologies/details/cn-cloudflare
  • user5994461
    user5994461 about 4 years
    It's correct unless one is being pedantic for the last percent. There are hundreds of individual CDN services and managed hosting solutions that act as one out of the box. CloudFlare alone is not outstanding when compared to the whole wide web.
  • user5994461
    user5994461 about 4 years
    I genuinely don't think VRRP is usable anymore except very limited use cases, like a fully physical setup untouched since 2010. And even there it needs support at the OS level (depends on linux and windows versions) that I didn't get into. Modern systems always have some AWS or VMWare or VirtualBox or Docker or god knows what, virtualization is just everywhere, and it doesn't play nice with VRRP.
  • Luke Cousins
    Luke Cousins about 4 years
    I'm not looking for an argument, but you're quoting (misguided) opinions as facts. I'm not being pedantic about the last percent. I'm being realistic about the facts and backing it up with supporting evidence.
  • user5994461
    user5994461 about 4 years
    Fact: A google search for "market share per CDN" shows CloudFlare in second place. Link to the first google result datanyze.com/market-share/cdn--10 (you could say it's dodgy and I would agree. there are no facts anyway, companies do not publish information about their customer base.)