1

I have two VPS servers from two different hosting companies. I want to make some fallback to second VPS if first is not available (preferably automatic). I understand that if I have a single load-balancer with root access I can setup it to switch between different backend servers. But is it possible to make it with VPS from two different hosting companies? Thanks.

6 Answers 6

7
+50

It all depends a bit on the situation. A standard way of achieving higher availability is indeed the loadbalancer. The problem is that you need at least two loadbalancers

A little drawing to make it clear:

                                  +-----------+
                             +--->| Backend 1 |
        +----------------+   |    +-----------+
WAN --->| Loadbalancer 1 |---+
        +----------------+   |    +-----------+
                |            +--->| Backend 2 |
                | Fallback        +-----------+
                v
        + - - - - - - - -+
        | Loadbalancer 2 |
        + - - - - - - - -+

Explanation

The loadbalancer stands before all backend servers ad proxies all request to the backend servers. A secondary loadbalancer stay online as well and checks if the primary balancer is reachable. If in any case the primary loadbalancer will go down, the secondary loadbalancer will take over his IP and start serving.

Advantages (of this confguration)

  • The loadbalancer distributes the traffic without having much load itself and can thereby mostly serve more users than the backend servers [1]
  • The loadbalancer can detect if a backend can't handle the traffic anymore and can stop sending traffic there [2]
  • The loadbalancer can do caching of static files for the backend
  • The loadbalancer can terminate the SSL [3][4]
  • If the loadbalancer fails it can fall back to the secondary balancer without downtime [5][6]

Disadvantages

  • It coasts more money
  • This doesn't help if the network in front of the balancer goes down.

Footnotes

[1] Of course the loadbalancer needs more bandwidth than the sum of the maximum bandwidth of the backend servers (this is not necessarily the maximum bandwidth of the interface depending on the application)

[2] This is not only good. If both backends are at or near their maximum capacity and the loadbalancer takes one down, the other backend will get all the traffic and the whole thing ill fall apart. This requires good tweaking

[3] In fact the loadbalancer must do this if he doesnt want to route the traffic blindly by connection.

[4] Maybe in you have to reestablish a new ssl connection after the beckend if you don't trust the backend network

[5] You have to make sure that when the primary goes down, it stays down until you want it up again to prevent things like toggeling and IPs used twice

[6] You have to make sur that the connection between the loadbalancers is very very very stable

7
  • Christopher, thanks for your comment, looks like I need at least two load balancers for it. Now I'm trying to understand, is it possible to use any service-provided load balancer (like Cloudfare) with my VPSs.
    – dbf
    Aug 8, 2013 at 11:37
  • Cloadflare is a good idea but no loadbalancer in the tradiodional way but more of a caching proxy with anycast. That makes Cloudflare not a bad service but you have to know what this means. Aug 8, 2013 at 11:42
  • Yes I see, also looking in Amazon services. Thanks again for your answer!
    – dbf
    Aug 8, 2013 at 11:46
  • Amazon has a quite good load balancing service. The problem is that it is a bit more complicated to use it with services outside of the Amazon cloud. You need to set up a VPC and include your external services via VPN. This might be quite costly .See aws.amazon.com/de/elasticloadbalancing and aws.amazon.com/de/vpc Aug 8, 2013 at 11:50
  • Yes I see, but according to description "across multiple Amazon EC2 instances" it is for balancing between EC2s, and I don't use it yet.
    – dbf
    Aug 8, 2013 at 11:53
3

If you have single load balancer, it wouldn't help too much in terms of high availability, you would still have a single point of failure. CDN used to be a way to go, but you might want to wait for few more answers...

2

Even if you have a load balancer in a third location (you can configure them in HA active-standby) you're still prone to network issues. Since your two VPS are presumably located in two different datacenters you might end with bad network performance, as your loadbalancer would contact the VPS, make the requests and forward responses to the clients, thus if the datacenter containing the balancer goes offline or experiences network issues your 2 VPS are useless.

2

A rough conf could be:

  • mount a DRBD partition into the both server
  • move conf/web/db in the drbd partition
  • change DNS settings as it round-robins on the two servers

I'm making the following assumptions:

  • you don't have many updates ( you'll probably kill your network throughput )
  • the site's not a shop

Anyway, there's no automatic failure detection and response in this configuration.

1
  • 1
    DRBD over an Internet connection is bad, once you fill the send buffer on the master, it will block any I/O until the buffer is empty (even if using the async mode). Aug 8, 2013 at 10:52
2

Everything what have been posted is fine and correct. However I can see a different approach to reach the described goal (fallback system hosted by a third party hosting company):

DNS Fallback

With this method the DNS provider checks the availability of your main system and switches to a fallback system in case the checked system doesn't respond properly.

There are quite a lot of suppliers on the market providing this type of service (Amazon Route 53, DNS Made Easy ...). Additionally you will get a faster DNS system (world-wide spread, any-cast listening DNS servers).

But - this is not high-availability! In case of an outage it needs some time to recognize the outage and adjust the DNS. But maybe it's already enough for your requirements.

1
  • 1
    Thanks, Jens! Today I see Route53 and looks like it is nice, but, yes, I agree that DNS caching could be a problem (especially for short time outages).
    – dbf
    Aug 8, 2013 at 17:35
1

Probably too late for this to be helpful because you already have your VPS's set up (although I don't know with which providers)

But I was presented with a similar situation a while back. If I remember correctly with Amazon EC2 you can have two nodes in different availability zones (availability zones exist within regions), and Elastic load balance between the two, the odds of two availability zones going down at the same time, while not impossible, are pretty slim and so the risk is spread.

There is a charge for data crossing availability zones, but from what I remember its negligible.

1
  • Yes, I originally used one VPS from Dreamhost for years. Now I have another one for some tests and I want to use them somehow together to provide higher availability. And I don't want to migrate all this stuff to Amazon yet.
    – dbf
    Aug 8, 2013 at 12:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .