Nginx – How to achieve high availability active-active application server

domain-name-systemhaproxyhigh-availabilityload balancingnginx

I need to setup my application is such a way that it gives me near 0 downtime. One of my data center is there in TX and another one is in Vegas. Now if my server at TX which is considered to be PR goes down all the traffic will be diverted to Vegas server which is DR (Disaster Recovery) in my case.

If we use software load balancer like HAProxy or NginX, using Keepalived (to check heartbeat between the DR site load balancer and PR site load balancer) we will end up with Active-Passive load balancing setup to overcome failover. Here our application will be in Active-Active mode.

enter image description here

The above diagram shows, all the incoming traffics will reach to the virtual IP of the load balancers (Active PR load balancer and Passive DR load balancer, heartbeat enabled between them). If PR site load balancer is active then it will route the load to PR site Portal application instances as well as DR site Portal instances (as both site is active), at that time DR site load balancer will be idle and constantly monitoring the performance of the Active load balancer. If PR site goes down, then the DR site will become active and point to the DR site Portal application instances automatically.

But I have heard that, the problem with Active-Passive load balancer setup with Keepalived is, it works in LAN but fails to work in WAN setup. As in our case Active PR load balancer will be in TX and Passive DR load balancer will be in Vegas.

So, to achieve HA with failover setup how can I use software load balancer?

Best Answer

You won't be able to do that. The reason it works in the same LAN is because of the shared IP that floats between the two. You'd need to do complicated BPG routing and own your IP space.

You are trying to complicate things way too much. Its better to make things as simple as possible and fail quickly and not worry about 0 downtime.

What you should be doing is using a DNS service to manage the traffic. You have a DNS service like route53 from AWS or from dyn.com setup health checks. So they are always checking both sites via a health check to make sure they are up. It sends all the traffic to the primary. Once the health check on the primary fails it will begin to give DNS responses for the failover site.

This isn't also something very easy because you have to keep the failover site active till you can verify the primary is fully in sync with the failover.