Search code examples
azureazure-virtual-networkinternal-load-balancerazure-application-gateway

Configure active-passive web app server in Azure


I have an application which I need to set up in active-passive mode behind the load balancer such that all connections should go to the active instance. If the active instance go down, it should start sessions from passive one.

The only info I gather was that we could only set up active instances behind the load balancer and it will distribute the load across them.

Appreciate any leads here.


Solution

  • As Gaurav say, we can use Azure Traffic Manager to achieve active-passive module. Traffic Manager is a DNS level load balancer.

    For now, we can't set active-passive module behind Azure Load Balancer.
    As a workaround, we can deploy Haproxy, and set node1 as master and node2 used as backup:

    -------------
     |  HAProxy  |
     -------------
      |         `
      |active    ` backup
      |           `
    ------       ------
    | node1 |       | node2 |
    ------       ------
    

    The configuration below makes HAProxy to use node1 when available, otherwise fail over to node2 if available (automatic failover and failback):

    global
       log /dev/log local0
       log /dev/log local1 notice
       chroot /var/lib/haproxy
       stats socket /run/haproxy/admin.sock mode 660 level admin
       stats timeout 30s
       user haproxy
       group haproxy
       daemon
    
    defaults
       log global
       mode http
       option httplog
       option http-server-close
       timeout connect 4s
       timeout client 20s
       timeout server 20s
    
    frontend ft_app
       bind 10.0.0.6:80
       default_backend bk_app
    
    backend bk_app
       server node1 10.0.0.4:80 check
       server node2 10.0.0.5:80 check backup
    

    In this way, we can achieve active-passive module.