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.
- 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 )
- 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.
Load balance and High Availability(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 High Availability(HA) you have:
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
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...
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.
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.