0

I've hosted two VMs on the same machine, one is active in nature i.e. hosting a service and is connected to a client (client is running directly on the host machine). I've to implement a fault tolerance service, i.e. on the failure of primary VM, the client is automatically gets connected to the secondary VM given that both VMs are hosting the same service.

I somewhere read about floating IPs, but when I checked, I found that it is a paid service. Is there any simple way i can achieve this which doesn't require any money to spend?

The machine is Linux-based, specifically, the host is ubuntu 20.* and VMs have ubuntu 18.*.

y_159
  • 121
  • 6

2 Answers2

2

you can achieve "floating IPs" also known as VIP or virtual IP with either:

FYI: you can also achieve redundancy in the client by letting him choose the healthy server(s) from a list.

note that implementing redundancy between VMs on the same host is not recommended. (the host is the Single Point Of Failure)

exeral
  • 1,787
  • 11
  • 21
  • Hi, can you explain more about VRRP, how to set it up and use it? – y_159 Dec 16 '20 at 10:09
  • VRRP is a network protocol. you need a software on each server that will emit and receive VRRP packets. this software can be keepalived or vrrpd for example. unfortunately, I won't be able to write a configuration tutorial in comments ! – exeral Dec 16 '20 at 10:36
  • Hi, Please look at this question: https://serverfault.com/questions/1046745/setting-keepalived-for-ha – y_159 Dec 18 '20 at 11:55
0

I suggest you use a reverse-proxy as a load balancer in front of your applications/VMs. You can use something like nginx or haproxy

nginx config would be something like below:

http {
    upstream backend {
        server backend1.example.com;
        server backend2.example.com;
        server 192.0.0.1 backup;
    }
    
    server {
        location / {
            proxy_pass http://backend;
        }
    }
}

it automatically implements health-checks for upstream hosts, so if any upstream host goes down, it will automatically be detected by nginx, which will stop sending requests to unhealthy hosts.

You can read more at: https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/

surfingonthenet
  • 715
  • 3
  • 7