12

I'm about to convert a single-server single-database web application into a physically distributed high-available configuration with servers on two physical locations (for now). Now, obviously, I need a load balancer (more like a reverse proxy in this case, but I'll call it "load balancer" for simplicity), which would route requests for mywebsite to either node1.mywebsite or node2.mywebsite. However, I assume that high-available servers are no use if my load balancer goes down. Therefore, so my train of thought, I'd actually need two load balancers, one on each location. However, I'd still want a single external point of access, therefore I'd need a load balancer for the load balancers, which in turn would need to be balanced across locations... this goes on and on.

So what's wrong with my reasoning? How would I ensure high availability of my load balancers in practice, assuming each of the physical locations could be disconnected from power for a long period of time?

PS: I'm aware of the fact that my understanding of the distinction between HA and load-balancing is mediocre at best. What I want is an available server even when the power on one location goes down. Thank you for your understanding.

  • 1
    Have you investigated IP failover? If both datacenters are the same provider it should be reasonably straight forward – Smudge Nov 30 '11 at 14:14
  • You must have your nodes on separate networks ? - When it's on the same LAN, HA is easier to setup. – Sandman4 Nov 30 '11 at 18:43
  • What is your main goal - you want load-balancing meaning you want to handle loads higher than those that are ok for single server, or you want HA meaning that you want your site work even if single node fails ? – Sandman4 Nov 30 '11 at 18:52

3 Answers3

5

You can't, which is why load-balancing has nothing to do with availability.

adaptr
  • 16,479
  • 21
  • 33
2

Two load balancers should be enough. You will be using only one load balancer at a time. The name mywebsite should resolve to the VIP assigned to one of the load balancers.

Khaled
  • 35,688
  • 8
  • 69
  • 98
  • is VIP = virtual IP? Which part of infrastructure would be hosting the VIP routing, i.e. detect that one LB is down and route to the other? If it's on one of the locations, it could be down as well... – Nikolai Prokoschenko Nov 30 '11 at 14:22
  • With a VIP the requests go to both LBs and one of them decides to respond based on whether it thinks the other one is up. This would suggest they arn't geographically seperated though which is a whole other level of availability. – JamesRyan Nov 30 '11 at 15:51
2

You can do coarse HA and balancing with round robin dns by sticking it in front of your load balancers.

JamesRyan
  • 8,138
  • 2
  • 24
  • 36
  • 1
    Round robin will do load-balancing, but as for HA - NO. Basically browser will choose one of the nodes and stick to it. It have 50% chances to hit a good one or a bad one. – Sandman4 Nov 30 '11 at 18:48
  • No, this is not what happens. Most modern browsers will take all the IPs including the bad one and transparently retry from the good ones. It is not foolproof but will work for the vast majority of users. – JamesRyan Dec 01 '11 at 11:32
  • 1
    what makes you think so ? I also hoped so until I actually tested it myself. Both firefox and chrome will try 1-st IP for *180 seconds*, then switch to next IP. Once you go to next page, they will start with 1-st (non-responsive) IP again and wait another 180 seconds and so on. ( http://serverfault.com/questions/327708/how-browsers-handle-multiple-ips ) – Sandman4 Dec 01 '11 at 14:42
  • Yes you have a 50% chance that the very first request will timeout but as soon as it does or you refresh it will go to the good ip and fetch ok. From 2nd request onwards it does not go back to the bad IP again, it sticks to the good one. – JamesRyan Dec 01 '11 at 16:20
  • 1
    Yuck. We can go on saying "it does" or "it doesn't". Just TRY it and see. And clicking refresh changes nothing (at least in chrome) - you wait 180 seconds even if you click stop and open the page again. – Sandman4 Dec 01 '11 at 18:58
  • I have just tried it in chrome, IE and firefox, have you? There is only a wait for the very first request, once it moved on to the good IP all page resources came in and all subsequent page requests have no delay. It appears to only be chrome that makes you wait for the full timeout length on that first request. – JamesRyan Dec 02 '11 at 12:52
  • @Sandman4 "just try it and see" is not a very good way of designing any sort of HA. – Cylindric Dec 07 '11 at 11:12
  • 1
    @Cylindric I did NOT suggest using DNS for HA. – Sandman4 Dec 07 '11 at 13:16
  • I suggested that it is better than no HA – JamesRyan Dec 07 '11 at 14:16