Failover and floating IPs explained

A floating IP is an address that can be moved from a failed server to a standby one, so clients keep using the same IP while a different machine answers. CheapVPS does not sell floating or extra IPv4 addresses, so failover here is built at a different layer: DNS records with a short TTL that a health check script switches to the standby server, ideally in a second city.

Networking and security guide, updated 2026-12-03

What problem does failover solve?

Any single server can stop answering: a kernel panic after an update, a full disk, a broken config, a hardware fault on the host, or a network incident in one data centre. Failover means a second machine takes over the job with little or no manual work, so visitors see a short hiccup instead of an outage that lasts until someone wakes up.

Every failover design answers three questions:

  • Detection: who decides the primary is down, and how quickly?
  • Redirection: how do clients end up at the standby: a moved IP, a changed DNS record, or a proxy that picks a different backend?
  • State: does the standby have current data? Without replicated data, failing over only moves the outage from "site down" to "site up with yesterday's content".

The third question is usually the hardest one, and it is independent of the provider. Plan it first.

What is a floating IP?

A floating IP (also called a virtual IP or failover IP) is a public address that is not tied to one machine. In a data centre that offers them, you ask the network to route that address to server A today and to server B after a failure. Clients keep connecting to the same IP and never notice the switch, apart from connections that were open at the moment it happened.

The move happens in one of two ways. Either the provider network changes its routing when you call an API or press a button, or the servers announce the address themselves on a shared network segment by sending gratuitous ARP replies, which tells the local switch that the IP now lives at a new MAC address.

On CheapVPS each server has exactly its own IPv4 and IPv6 /64, and the console has no button to move an address to another server. The approaches below reach a similar result without one.

How do keepalived and VRRP work?

keepalived is the usual Linux tool for the second method. It speaks VRRP, the Virtual Router Redundancy Protocol: two or more servers share a virtual IP, the one with the highest priority holds it as MASTER, and the others listen as BACKUP. The MASTER sends an advertisement every second; when the backups stop hearing it for about three intervals, the next in line claims the address and announces it with gratuitous ARP.

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 150
    advert_int 1
    virtual_ipaddress {
        192.0.2.50/24
    }
}

keepalived can also run a check script and lower its own priority when, say, Nginx stops answering, so a server with a dead service gives the IP away even though the machine itself is up.

All of this needs a shared layer 2 segment and an address that the network will accept from either server. Separate VPS machines with their own routed public IPs do not have that, so keepalived is not the tool here. It is worth understanding, though, because DNS failover borrows the same ideas: priorities, health checks and a clear rule for who is active.

How does DNS-based failover work?

Instead of moving an IP, you move the name. www.example.com points at the primary server 203.0.113.10 with a short time to live, for example 60 seconds. A health check runs somewhere else, every 30 seconds or so. When the primary fails several checks in a row, the checker updates the record through your DNS provider's API to point at the standby 198.51.100.20. Resolvers drop the old answer once its TTL runs out and fetch the new one.

Many DNS providers include health checked failover records as a feature, in which case you set two addresses, a check URL and a priority in their panel. If yours does not, a small script does the same job:

#!/bin/sh
# /usr/local/bin/failcheck.sh, run every 30 s from a systemd timer
fails=0
for i in 1 2 3; do
  curl -fsS -m 5 https://203.0.113.10/health -H "Host: www.example.com" -k >/dev/null || fails=$((fails+1))
  sleep 5
done
[ "$fails" -eq 3 ] && /usr/local/bin/dns-set-a www.example.com 198.51.100.20

dns-set-a stands for whatever call your DNS provider documents. Run the checker on a third machine, not on either server being checked, or it may fail together with the primary.

What are the limits of DNS failover?

DNS failover is simple and works across cities and providers, but it is not instant:

  • TTL is a request, not a rule. Most resolvers respect a 60 second TTL; a few hold answers longer. Browsers and apps also cache lookups. Expect most traffic to move within a couple of minutes and a small tail to take longer.
  • Detection adds time. Three failed checks at 30 second intervals means about a minute and a half before the switch even starts.
  • Switching back needs care. Fail back automatically and a flapping primary bounces traffic all day. Many teams fail over automatically and fail back by hand.
  • Open connections break. Users mid-upload or on a WebSocket reconnect. That is true of floating IPs too.

Point the TTL low only on the records that fail over. A 60 second TTL on every record in a zone mostly adds load on resolvers without benefit. Basics are in DNS explained and Point a domain at your server.

Why put the standby in a second city?

A standby in the same data centre protects against a failed server, a bad update or a full disk. It does not protect against a network incident or power event that affects the whole site. With 15 cities at the same price, placing the standby elsewhere costs nothing extra in the plan itself.

Pairs that work well keep latency modest for replication: Frankfurt with Amsterdam or Nuremberg, Ashburn with Toronto, Singapore with Tokyo. Replication between continents works too, but the delay makes synchronous database replication painful, so asynchronous replication with a small lag is the usual choice. See Spread servers for uptime and the locations list.

Remember the transfer side: the primary sends every change to the standby, and that is outgoing traffic for the primary. File sync and database streams are normally modest, but measure them.

Can a reverse proxy in front give faster failover?

Yes, for the application tier. One small server running HAProxy or Nginx receives all traffic and forwards it to two app servers. The proxy checks both every few seconds and stops sending requests to one that fails, usually within seconds and without any DNS change. Visitors never see the switch beyond a retried request.

The trade-off is obvious: the proxy is now the single point of failure. Common answers are to keep it very simple (a proxy rarely crashes on its own), to keep a second proxy in another city behind DNS failover, or both. That gives fast failover inside a city and slower, DNS-based failover between cities. Setup is covered in HAProxy load balancer.

How do the options compare?

MethodSwitch timeWorks across citiesMain weakness
Floating IP with VRRPSecondsNo, one network segmentNeeds a movable address (not sold here)
DNS failoverAbout 1~5 minutesYesClient caching, slow tail
Reverse proxy with health checksSecondsBackends can be anywhereThe proxy itself
Proxy pair plus DNS failoverSeconds inside, minutes betweenYesMore moving parts

For most small projects, one proxy with two app servers plus a nightly tested backup is a large step up from a single server. Add DNS failover to a second city when an outage of a few minutes really costs you money.

How do you keep data in sync for a standby?

Pick a method per kind of data:

  • Databases: PostgreSQL streaming replication or MariaDB replication to the standby over a WireGuard tunnel. Promote the replica during failover.
  • Uploaded files: rsync -a --delete on a timer, or lsyncd for near real time copies.
  • Config and code: deploy both servers from the same Git repository or CI job, never by hand on one of them.

Then test. Stop Nginx on the primary on a quiet afternoon, watch the record change, load the site, and switch back. A failover that has never been tried is a hope, not a plan. Optional daily backups ($2.41 per month on P4) are a separate safety net and do not replace a live standby.

Questions about this guide

Can I buy a floating or extra IPv4 address?

No. Each server comes with one IPv4 address and an IPv6 /64, and addresses cannot be moved between servers. Use DNS failover or a reverse proxy in front for the same goal.

Will keepalived work between two CheapVPS servers?

VRRP needs a shared network segment and a movable address, which separate servers here do not have. keepalived can still run health check scripts, but the IP switch itself will not work.

What TTL should a failover record have?

Between 30 and 120 seconds is the usual range. Lower values add resolver traffic with little extra gain, because client caches and detection time dominate.

Does a standby server cost the full plan price?

Yes, it is a normal server billed like any other. Many people run a smaller plan as the standby and accept slower service during a failover, then order a larger replacement if the outage lasts.

How do I test failover safely?

Stop the web server on the primary with systemctl stop nginx at a quiet time, check that the checker switches the record, load the site from a phone network, then start Nginx again and switch back by hand.

Is DDoS filtering a form of failover?

No. Network DDoS filtering removes attack traffic before it reaches your server. Failover handles a server or site that stops answering for any reason.