Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to load balance + failover backup multiple vps webservers hosted on different providers.

I heard that for HAProxy you need multiple server under the same subnet, plus a shared (virtual) ip address between load balancers.

But it's not possible in my case cause every VPS is on different node/network.

  1. Is there a way to use HAProxy in this kind of setup ? ( Please explain how briefly, I don't want to hear your "YES" answer )
  2. What about NginX? Is it possible to achieve same result with Nginx ? (when servers are located on different nets)

I know about Round Rubin DNS, but it doesn't provide a real failover solution, neither a load balance between servers.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

Load balance and HA are two different things.
Yes, you can configure load balance, using NginX, for two or more nodes, regardless where are they located.

For Load Balance you have:
DNS -> service IP -> Load balancer -> AppSrv1,AppSrv2,...,AppSrvn -> One or more Backends

For HA you have:

  • Active/Passive:
    Normal work situation:
    DNS -> Virtual Service IP (assigned on LB1) -> AppSrv1,AppSrv2,...,AppSrvn -> One or more Backends If LoadBalancer1 (LB1) breaks:
    Hartbeat assigns VirtualIP to LB2
    DNS -> Virtual Service IP (assigned on LB2) -> AppSrv1,AppSrv2,...,AppSrvn -> One or more Backends
  • Active/Active:
    DNS -> VirtIP1 (LB1),VirtIP2 (LB2), VirtIPn (LBn) -> AppSrv1,AppSrv2,...,AppSrvn -> One or more Backends

Basically, Load Balancer creates hashes, based on client IP, and forwards all traffic with this hash to the same AppSrv (in order to preserve sessions, etc). You can configure preferred AppSrv, failover AppSrv, etc

You can make a configuration with LB on all of your VPSs, which forwards traffic to the local AppSrv(same VPS), and if that AppSrv is unreachable, then forward to the "backup" VPS. But there are problems with such implementation on so many levels...

share|improve this answer
    
What I am trying to achieve is, Redirect user's download request to a server that is available(not down) and free on resource compared to other servers (in term of CPU usage, RAM, Traffic, Number of alive connection ). Is this same as Load Balance or HA ? What should I look for actually. –  xperator Nov 8 '12 at 10:24
    
What you are trying to achieve is Load Balance. It's easy to do it for "server that is available(not down)". I'm not sure if NgineX can collect server metrics and make a decision upon them. You probably have to look for external solution. –  fireto Nov 8 '12 at 11:18
    
Thank you for clearing up my thoughts. I looked for load balance using nginx and It was super EASY to implement. –  xperator Nov 8 '12 at 14:32

You have confused HSRP/VRRP/LVS with HAProxy. The virtual IP part is completely separate to HAProxy.

If you want a single shared IP between two different VPS providers, you can't. The best you can do is get two VPS's from the same provider, run heartbeat+haproxy on both, then they can have IPs within the same subnet.

share|improve this answer
    
You mean there is no way to Load Balance 2 or more servers over a global network ? They have to be on same network ? This doesn't make sense. There should be a way to use a server to load balance different located servers. –  xperator Nov 8 '12 at 9:40
    
It makes sense - you just don't understand. With MPLS or BGP - yes. With a bunch of VPS's from different providers - no. You would never be able to "float" a virtual IP between different providers. The best you could get is DNS to balance between those, then each of those balance between the backends - but then you're reliant on DNS - which isn't remotely appropriate for load balancing. –  Ben Lessani - Sonassi Nov 8 '12 at 19:47
    
sonnasi, you're mistaking HA with load balance. LB starts with LB proxy server, which distributes client's request between active/active servers. This means, those servers can be anywhere in the net, as long as they're accessible from the LB proxy. Performance and efficiency are another matter. –  fireto Nov 9 '12 at 16:39
    
I'm not mistaking either. The OP was looking for a way to use multiple VPS's to load balance –  Ben Lessani - Sonassi Nov 9 '12 at 23:49
    
I'm not mistaking either. The OP was looking for a way to use multiple VPS's to load balance amongst multiple back ends. But was mentioning the use of a virtual IP, which means they were looking at UltraMonkey/Heartbeat or otherwise, in conjunction with HAProxy. The OP asked for load balancing plus failover - something you wouldn't get with a single load balancer, nor would you get with "DNS load balancing". You can't be highly available using a single load balancer, nor using DNS to load balance. –  Ben Lessani - Sonassi Nov 9 '12 at 23:55

You mean different farms located in different areas?

Then you would route them through DNS to the specific geographic farm where HAProxy can load balance:

webfarm1 -> HAProxy -> appsrv..

webfarm2 -> HAProxy -> appsrv..

You can also load balance between vps spread across geographical areas but the end result would not be that good: this kind of setup servers usually static content such as CDN's.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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