This is quite a vast and contentious topic :)
Among the many ways of doing it you can do some clever multi-site stuff with BGP, you can use
basic DNS services with low TTLs (which lose a few percent of traffic at failover because of
Proxy Caching etc) or my preferred approach is to have a "static" connection between both
sites. This could be using a leased line, a LES circuit, two DSL connections or a form of
connectivity that's otherwise unrelated to how you're serving to the users over the
Internet.
You simply sync data over your private circuit and run something like
keepalived
or script something yourself to alter DNS if one site can't reach the Internet. If this
private link (it could be a VPN even but should be provisioned from a different provider than
the Internet connectivity) goes down then you simply sync over the Internet until it's back
online.
The BGP dual-site approaches can get expensive so really you're relying on DNS to one extent
or another.
There is also this (but I'm reluctant to recommend it without knowing more):
http://www.autofailover.com