Spread servers for uptime

If two copies of a service run on the same physical host, one hardware fault stops both. Spreading them so they never share a host is called anti-affinity. At CheapVPS the simple and reliable way to get it is to put each copy in a different city, for example Frankfurt and Nuremberg or Ashburn and Toronto, and let DNS failover and health checks send visitors to whichever copy is up.

Servers and storage guide, updated 2026-12-03

What is anti-affinity?

Affinity rules tell a scheduler which machines should run close together; anti-affinity rules say which ones must stay apart. In virtual server platforms the term usually means: never place these two virtual machines on the same physical host. Some platforms expose this as a setting called a placement group or spread group.

The idea is simple. Two web servers behind a load balancer do not help much if a single power supply, disk controller or host kernel fault takes both down. Redundancy only counts when the copies fail independently.

How do you spread servers with CheapVPS?

Our console has no placement setting, and you do not need one: servers in different cities are by definition on different hosts, in different buildings, on different networks. That protects against a host fault and against a wider problem in one data centre.

Good pairs that keep latency between them low:

Prices are the same in every city, so the second copy costs the same as the first.

What should each copy contain?

Each server must be able to serve visitors on its own. Keep the application code, configuration and TLS certificates identical on both, ideally deployed from the same Git repository or the same Compose file. Keep state in as few places as possible: one database with a replica, uploads synced or stored outside the web servers, and sessions stored in the database or a shared cache rather than in local files.

A short checklist per server: same OS image, same package versions, firewall open for HTTP, HTTPS and SSH, and a health endpoint such as /healthz that returns 200 only when the app and its database connection work.

How does DNS failover work?

Many DNS providers can run health checks against your servers and change the answer when one fails. You create the record with both addresses, set a short TTL (60~300 seconds) and attach a check to each address. When a check fails, the provider stops handing out that address; when it recovers, the address returns.

Points to keep in mind:

  • Some resolvers and browsers cache longer than the TTL, so a small share of visitors may see the failed server for a few minutes.
  • Both servers can be active at once (round robin), or one can be primary with the other used only on failure.
  • Add AAAA records for the IPv6 addresses too, with their own checks.

Setting up the records themselves is covered in pointing a domain at your server.

How do you write a simple health check?

Expose an endpoint that tests what matters. With Nginx in front of an app, the app route can run a quick database query and return 200 or 503. Test it from outside:

curl -fsS -o /dev/null -w "%{http_code} %{time_total}s\n" https://example.com/healthz

-f makes curl fail on HTTP errors, which suits scripts. On each server you can also run a systemd timer or a cron job that calls the same endpoint on the other server and alerts you by mail or chat. For more structured monitoring, see monitoring basics and the Prometheus and Grafana image.

How do you replicate the database?

Run the primary database in one city and a replica in the other, connected over an encrypted link. WireGuard between the two servers is the usual choice; see a private link with WireGuard.

For PostgreSQL on Ubuntu 24.04 the outline is: create a replication role on the primary, allow it in pg_hba.conf for the WireGuard address, then on the replica stop PostgreSQL, empty the data directory and run:

sudo -u postgres pg_basebackup -h 10.8.0.1 -U replicator -D /var/lib/postgresql/16/main -R -P

The -R flag writes the standby settings, so the replica starts streaming changes when you start the service. MariaDB and MySQL use binary log replication with a similar idea. Promotion of the replica (pg_ctl promote or SELECT pg_promote();) is a deliberate step: practise it before you need it.

How do you keep files in sync?

Uploaded files and generated assets must exist on both servers. Options, from simplest:

  • A one-way rsync -a --delete from the primary to the standby on a timer, when only the primary accepts uploads.
  • Storing uploads in object storage of your choice and serving them through the app.
  • A sync tool such as Syncthing for two-way changes, with care around conflicts.

Back up separately. A replica copies mistakes as quickly as it copies good data; see backups vs snapshots.

What does a two-city setup cost?

Twice the price of one server plus any extra traffic. Two P4 servers at $12.05 each cost twice the 12-month total of $144.60 for a year. Adding the daily backup add-on to the primary costs $2.41 a month for that server. If you only need a cold standby, a smaller plan such as P2 (1 vCPU, 2 GB RAM, 40 GB NVMe) can wait as the second copy, ready to take over at reduced capacity.

Remember that each order is one invoice and each term needs a total of $40 or more.

How do you test that failover really works?

Plan a quiet hour, then shut down the primary from the console with the shut down action. Watch the health check turn red, the DNS answer change (dig +short example.com against your provider name servers), and the standby take the traffic. Promote the replica if the test includes the database. Write down how long each step took and what you had to do by hand. Then power the primary back on and reverse the process.

Questions about this guide

Can I ask for two servers on different hosts in the same city?

The console has no placement option. Use two cities for guaranteed separation; nearby pairs like Frankfurt and Nuremberg keep latency low.

Do you offer floating IPs for failover?

No. Use DNS failover with short TTLs, or a proxy in front of both servers. The failover guide explains the options.

Do you have load balancers?

Not as a product. You can run HAProxy or Nginx on a small server yourself; see HAProxy load balancer.

Is traffic between my servers free?

Incoming traffic is free. Outgoing traffic from each server counts toward its own allowance, such as 20 TB for P4 in Europe.

Is replication a backup?

No. A replica repeats deletions and corruption. Keep scheduled backups as well.

Are there SLA credits for downtime?

No. The two-city design is how you protect uptime with us.