LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-28-2022, 01:23 AM   #1
Sponge_Bob
LQ Newbie
 
Registered: May 2018
Distribution: Devuan
Posts: 24

Rep: Reputation: 1
Question Failover for webserver


Hi everyone,

I would to provide a failover mechanism for a simple website that I created that is hosted trough Gunicorn --> Nginx.

So I would like if the main server (A) is not responding that the requested/visitor be redirected to the (B)

What would be the easiest solution ?
or where could I look to found some documentation about it ?

Thanks
 
Old 09-28-2022, 04:44 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Use your favourite search engine and look for keepalived and haproxy
 
Old 09-29-2022, 05:32 AM   #3
Sponge_Bob
LQ Newbie
 
Registered: May 2018
Distribution: Devuan
Posts: 24

Original Poster
Rep: Reputation: 1
Thank @TenTenths,

If I understand correctly keepalived work on the Network layer (IP) ny sending a ping ?
if the ping is unsuccessful redirect to another server

On the other-hand if I setup a failover trough nginx HTTP_upstream_module
the check will happen on the Application layer.

in both scenario I need a "intermediary" see
https://i.imgur.com/j2pZktl.png

is there a possibility to act on the DNS to make an "alive/responding" check ?

I know the Round-robin DNS exist, but I'm afraid that it's limited to load balancing, I don't want load balancing, I just want the failover. (meaning always the same main server with one or more backup)

Thanks.
 
Old 09-29-2022, 05:50 AM   #4
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by Sponge_Bob View Post
If I understand correctly keepalived work on the Network layer (IP) ny sending a ping ?
if the ping is unsuccessful redirect to another server
Honestly, it was like 6 years ago I last used it, do my memory is a tiny bit vague over what did what. I think we used keepalived between two instances of haproxy to ensure that one of them always had the "public" IP address and then used haproxy to check the backends via http/s

Quote:
Originally Posted by Sponge_Bob View Post
On the other-hand if I setup a failover trough nginx HTTP_upstream_module
the check will happen on the Application layer.
Probably, there's several ways to achieve this kind of result.

Quote:
Originally Posted by Sponge_Bob View Post
is there a possibility to act on the DNS to make an "alive/responding" check ?
If you're talking about using checks and then doing a public facing DNS change to reflect the IP then this is the WORST IDEA EVER! Why? Because you have zero control over the TTL and record propagation times. I know some ISPs don't necessarily respect short TTL times and even today it's still recommended to allow "up to 24hrs" for public DNS changes to propagate.

Quote:
Originally Posted by Sponge_Bob View Post
I know the Round-robin DNS exist, but I'm afraid that it's limited to load balancing, I don't want load balancing, I just want the failover. (meaning always the same main server with one or more backup)
Yeah, Round Robin is the poor mans / last resort load balancing.

As you understand (although many don't!) there's differences between HA - High Availability and LB - Load Balancing. Ultimately both rely on something, somewhere, doing a check to see if one or more backends are still responding.

Ok, I just found my network diagram from "back in the day", we used two haproxy instances and had keepalived running between them to ensure that one of those instances had a specific IP address. Those two instances had multiple inbound listener ports configured in haproxy, each of those listeners had multiple (up to 6!) backends. The backend checks in haproxy made calls to the relevant service, not relying on ping, to ensure the listener service was functioning. If the backend didn't respond correctly, or quick enough, then haproxy would start using a different backend. There was backend preferences, so if the "primary" backend started responding properly then haproxy would start using that again over preference to any currently active backends.
 
Old 09-29-2022, 06:06 AM   #5
Sponge_Bob
LQ Newbie
 
Registered: May 2018
Distribution: Devuan
Posts: 24

Original Poster
Rep: Reputation: 1
Lightbulb

Thank you very much @TenTenths , for your fast reaction and complete answer

Actually I've might found something pretty interesting --> https://ns1.com/resources/dns-failov...nd-limitations

and this is done server (dns) side

Quote:
DNS caching and TTL is still an issue, but setting a TTL value of 30 seconds will allow 50% of users to be redirected within 25 seconds of failure, and 100% of users within a minute
Quite amazing, but it seem proprietary :/ Does anyone know if something similar exist as FOSS ?
 
Old 09-29-2022, 06:24 AM   #6
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by Sponge_Bob View Post
Actually I've might found something pretty interesting --> https://ns1.com/resources/dns-failov...nd-limitations
Yeah, we had something like that for failover between datacenters, we found it sometimes took certain users up to an hour to be redirected. We found certain ISPs that provided their own DNS servers to clients via DHCP didn't necessarily respect short TTLs.
 
Old 09-29-2022, 06:27 AM   #7
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Just as an aside, I've made changes to DNS where the A record has a short (60 second) TTL and it has taken up to 5 minutes for Google's DNS servers on 8.8.8.8 to consistently return the new A record value.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Webserver failover (over WAN) lp449 Linux - Server 8 03-05-2013 10:49 AM
Failover with webserver with private SSL certs svancouw Linux - Server 2 10-23-2007 05:00 PM
Webserver Failover using RH5 Jimerson Red Hat 3 08-14-2007 12:57 PM
webserver failover imi@tux Linux - Networking 1 05-23-2006 02:47 AM
Can't see WebServer from outside... Can see WebServer locally as http://localhost friddick Linux - Networking 13 08-19-2003 06:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration