views:

218

answers:

2
+1  Q: 

Webserver failover

I will be running a dynamic web site and if the server ever is to stop responding, I'd like to failover to a static website that displays a "We are down for maintenance" page. I have been reading and I found that switching the DNS dynamically may be an option, but how quick will that change take place? And will everyone see the change immediately? Are there any better ways to failover to another server?

A: 

DNS has a TTL (time to live) and gets cached until the TTL expires. So a DNS cutover does not happen immediately. Everyone with a cached DNS lookup of your site still uses the old value. You could set an insanely short TTL but this is crappy for performance. DNS is almost certainly not the right way to accomplish what you are doing.

A load balancer can do this kind of immediate switchover. All traffic always hits the load balancer first which under normal circumstances proxies requests along to your main web server(s). In the event of web server crash, you can just have the load balancer direct all web traffic to your failover web server.

Asaph
Thanks! This is exactly the information I was looking for. I was concerned that a DNS change would take too long. If I have the servers in two seperate locations, would I be able to switch the load to another server using a load balancer if the main server when down?
mike
@yummm: As long as the load balancer handles the request, it directs it whereever you tell it to. BTW, typically a load balancer and the web servers it routes to are physically close together (in the same building). Also, if you don't have access to hardware load balancers eg. F5 (expensive!), have a look at haproxy, a software load balancer (that is used by StackOverflow!).
Asaph
The only issue is I'm on a windows server. haproxy doesn't appear to support windows. Is there anything you know of that is similar and works on a windows operated machine?
mike
@yummm: I'm not aware of a good software load balancer for Windows. BTW: StackOverflow runs on Windows with haproxy in front (probably on a Linux server).
Asaph
A: 

pound, perlbal or other software load-balancer could do that, I believe, yes

perhaps even Apache rewrite rules could allow this? I'm not sure if there's a way to branch when the dynamic server is not available, though. Customize Apache 404 response to your liking?

GeeKieR