views:

524

answers:

7

How can I make that a site automagically show a nice "Currently Offline" page when the server is down (I mean, the full server is down and the request can't reach IIS)

Changing the DNS manually is not an option.

Edit: I'm looking to some kind of DNS trick to redirect to other server in case the main server is down. I can make permanent changes to the DNS, but not manually as the server goes down.

A: 

I believe that if the server is down, there is nothing you can do. The request will send up a 404 network error because when the web address is resolved to an IP, the IP that is being requested does not exist (because the server is down). If you can't change the DNS entry, then the client browser will continue to hit xxx.xxx.xxx.xxx and will never get a response.

If the server is up, but the website is down, you have options.

EDIT

Your edit mentions that you can make a permanent change the IP. But you would still need a two server setup in order to achieve what you are talking about. You can direct the DNS to a load balancer which would be able to direct the request to a server that is currently active. However, this still requires 100% uptime for the server that the DNS points to.

No matter what, if the server that the DNS is pointing to (which you must control, in order to redirect the traffic) is down, then all requests will receive a 404 network error.

EDIT Thanks to brian for pointing out my 404 error error.

I can change the DNS, but the change will be not fast enough if I do it manually when the server is down.
Eduardo Molteni
Any solution requires either changing the DNS, or having a server with 100% uptime.
You will not get a 404. A 404 is an error is generated by the web server. If the server is down, you will get a network error; the exact form of the error depends on your browser.
Brian Campbell
I know I will need two servers. I'm looking for a answer how can I configure them to achieve the result.
Eduardo Molteni
A: 

I'm thinking if the site is load balanced the load balancer itself would detect that the web servers it's trying to redirect clients to are down, therefore it would send the user to a backup server with a message dictating technical problems.

Other than that.....

Peter D
But the problem with a load balanced is I can't balance with the "offline" server in normal conditions, because half of traffic will get the server offline message.
Eduardo Molteni
I'm not 100% sure about this but there definately has to be a way to have a condition. Here is some code that might make it clear:If ( server1.isDown() }
Peter D
+2  A: 

Some server needs to dish out the "currently offline page", so if your server is completely down, there will have to be some other server serving the file(s), so either you can set up a cluster of servers (even if just 2) and while the first one is down, the 2nd is configured only to return the "currently offline page". Once the 1st server is back up, you can take down the 2nd safetly (as server 1 will take all the load).

JonoW
Yes, but, how do you configure your servers or DNS to do it?
Eduardo Molteni
If you're on Windows/IIS you can look at Network Load Balancing (NLB), where you point your DNS at a single IP which balances requests internally onto 2 (or more) internal IPs. So either you can disable one of the machines manually when u take it down, or perhaps investigate if this can be automated
JonoW
+3  A: 

I have used the uptime services at DNSMadeEasy to great success. In effect, they set the DNS TTL to a very low number (5 minutes). They take care of pinging your server.

In the event of outage, DNS queries get directed to the secondary IP. An excellent option for a "warm spare" in small shops with limited DNS requirements. I've used them for 3 years with not a single minute of downtime.

EDIT:

This allows for geographically redundant failover, which the NLB solution proposed does not address. If the network connection is down, both servers in a standard NLB configuration will be unreachable.

Peter J
Not all DNS Servers follow the rules. Your IP could be cached for 24 hours in some ISP's DNS Server.
epochwolf
I tested that exact scenario after deployment, and found that ~98% of traffic was redirected after the TTL expired. The shorter the TTL, the more likely DNS servers will ignore it. 5-10 minutes was the "polite" sweet spot.
Peter J
A: 

The only thing I can think is to control the calling page. Obviously that won't work in all circumstances... but if you know that most of your hits to this server will come from a particular source, then you could add a java script test to the source, and redirect to a "server down" page that is generated on a different server.

But if you are trying to handle all hits, from all sources (some of which you can't control), then I think you are out of luck. As other folks are saying - when a server is down, the browser gets a 404 error when it attempts a connection.

... perhaps there would be a way at a point in between to detect 404 errors being returned by servers and replacing them with a "server is down" web page. You'd need something like an HTML firewall or some other intermediate network gear between the server and the web client.

bethlakshmi
+1  A: 

Seriously, DNS is not the right answer to server load-balancing or fail-over. Too many systems (including stub clients and ISP recursive resolve) will cache records for much longer than the specified TTL.

If both servers are on the same network, use routing protocols to achieve fail-over by having both servers present the same IP address to the network, but where the fail-over server only takes over if it detects that the (supposedly) live server is offline.

If the servers are Unix, this is easily done by running Quagga on each server, and then using OSPF as the local routing protocol. I've personally used this for warm standby servers where the redundant system was actually in another data center, albeit one that was connected via a direct link to the main data center.

Alnitak
A: 

You probably need a second server with 100% uptime and then add some kind of failover load balancer. to it, and if the main server is online redirect to that and if it isn't redirect to itself showing a page saying server is down