We've got one server running our company's website. Unfortunately, it sometimes experiences problems. Is there a way to set up another server to serve the static websites, in case the original server doesn't respond to pings?
You will need to setup a load balancer after setting up another server. You can setup software based load balancer with apache's mod_proxy_balancer, buy a dedicate load balancer, or consult your webhosting company/data center for load balancer service.
There are multiple solutions to this. The key decision is how much downtime can you tolerate.
There are DNS services (such as DNS Made Easy) that do DNS fail-over. If they detect a server is down, they will change your DNS record to point to the other location.
Pros: Simple to setup. Just replicate files between the two locations with something like rsync/ftp.
Cons: Even with short TTLs values in DNS, there will always be a lag.
This is a good short-term fix. Many web site acceleration & CDN providers (Cloudflare, Yotta) allow you to set a cache period for when the backend is not available. They will serve up a cached version of the site while you fix the problem. Retention usually varies from minutes to days depending on the plan and vendor.
Pros: Easy to setup and avoids DNS issues. May also speed up your site.
Cons: Can be costly if you have high bandwidth. Still requires you to fix the backend quickly.
Load Balancing/High Availability Solutions
There are multiple approaches to this but generally this involves a load balancer and one ore more servers.
Pros: Can be fully automated to provide 99.9% and above. Instant fail over in most cases.
Cons: Cost and complexity depending on setup.
This is a newer approach I've recommend to some businesses. Some providers such as SoftLayer & Amazon Web Services can assign you a IP ranges that can be re-mapped to alternate locations. The strategy is to setup the site in two locations and then re-map your IP when needed.
Pros: Simple setup for simple sites and little lag time for failures.
Cons: Limited provider choice.
Assumption: Backup site serving static pages is hosted on different server.
You can handle this at DNS Zone level itself, by adding two SRV records as
When server with priority 10 is unavailable, the record with next highest priority value will be chosen, which is backupbox.example.com. Please note, The weight value is relevant only in relation to other weight values for the service, and only among records with the same priority value.
Further, ensure that the target in SRV records must point to hostname with an address record (A or AAAA record).
A detailed explanation could be found here.