TWO-SERVER REDUNDANCY

When a second dedicated server helps, when it does not, and how to build a warm standby you can promote in minutes with DNS failover.

High availability with two dedicated servers

 

Two-server high availability: practical redundancy on dedicated servers

Two-server high availability is one of the most misunderstood things a small team can build. A second dedicated server does not make your service unbreakable; it buys you recovery speed, and only if you have rehearsed the failover. This guide is about practical redundancy: a primary that serves traffic, a warm standby that can take over in minutes, and a DNS failover setup that works on any provider, without assuming network features a rented dedicated server may not have.

Most of what takes a service down is not hardware. It is a bad deploy, a full disk, an expired certificate, or a fat-fingered command. A second server does nothing for those, and can make them worse if it faithfully replicates the mistake. So the honest framing first: failover dedicated servers are a recovery tool for the machine dying, not a substitute for good backups, careful deploys and monitoring.

Everything here runs on Ubuntu 24.04 LTS and assumes you have already done the first-hour hardening on both boxes: root password changed, SSH keys only, firewall default-deny, automatic security updates. Server.Biz sells unmanaged dedicated servers, so you are the operator of both machines. Follow this top to bottom and you end with two boxes in step, a written promotion runbook, and a drill on the calendar.

What a second server actually buys you

Start by naming what you are buying, in plain words. RTO, the recovery time objective, is how long your service is down after something breaks: minutes, hours, or a day. RPO, the recovery point objective, is how much recent data you are willing to lose: the last few seconds of writes, or the last hour. Every redundancy decision is a trade between those two numbers and the money you spend on machines.

A second server moves your RTO from hours to minutes, because the replacement is already running and already holds your data. It does almost nothing for your RPO on its own; that is set by how you replicate data, which is a separate choice covered below. And it does nothing at all for the failures that are not hardware. Hold that distinction firmly, because it decides whether the second box is worth its cost.

Redundancy is a spectrum, not a switch. At one end is backups only: one machine, and a restore when it dies. Then cold standby, a second box you provision and restore onto after a failure. Then warm standby, the pattern in this guide, where the second box runs your stack and receives data continuously, waiting to be promoted. At the far end is active-active, where both boxes serve traffic at once and losing one is a non-event. Each step up cuts your RTO and adds cost and complexity.

Typical RTO Typical RPO Machines you pay for
Backups only Hours to a day Since last backup 1, plus a backup target
Cold standby 1 to 4 hours Since last backup 2, one idle
Warm standby (this guide) 5 to 15 minutes, manual Seconds to minutes 2, both running
Hot standby, auto failover Seconds to minutes Seconds 2 to 3, plus an arbiter
Active-active Near zero Seconds 3 or more, plus orchestration

Most teams overreach on this table. They reach for automatic failover, build something fragile, and discover during the first real incident that the automation failed over to a broken standby, or flapped back and forth, or split the brain in two. A rehearsed 10-minute manual failover is more reliable than a clever automatic one that fires at the wrong moment. Aim for warm standby first, and earn the right to automate later.

The two-box architecture that works anywhere

The pattern is deliberately boring. One server, the primary, serves all traffic. A second server, the standby, runs the identical stack: same containers, same versions, same config. It is not idle; it is up and warm, receiving a continuous copy of the primary's data, so at any moment it is minutes of promotion away from taking over. Nothing about this depends on a special network feature, a floating IP, or provider cooperation, which is exactly why it works on any dedicated server anywhere.

Run the stack the same way on both boxes. If you already run your services as containers behind a compose file, our production Docker host guide is the baseline both machines should match. The standby is a second host running the same compose project, pulling the same images. The only difference between the two is which one DNS currently points at and, for the database, which one is the writable primary.

Failover is a documented manual runbook, not a black box. When the primary dies, a human confirms it is really dead, promotes the standby's database, repoints DNS, and watches the service come back. Done well that is a 5 to 15 minute procedure any on-call engineer can run from a checklist. Choosing manual over automatic here is not laziness; it is the honest recognition that at two-server scale, a human deciding to fail over is more reliable than a script guessing.

Keeping the standby identical

A standby that has quietly drifted from the primary is a standby that fails when you need it. The defence is to make sameness a habit rather than a chore: keep the compose files and their .env in git, deploy to both hosts from one script, and check for drift on a schedule. The examples assume the two boxes are joined by a private WireGuard link, primary on 10.9.0.1 and standby on 10.9.0.2, which our WireGuard guide sets up.

One deploy script targets both hosts in turn, so they can never receive different releases. It syncs the compose project and brings the stack up on each.

deploy.sh
#!/usr/bin/env bash
set -euo pipefail

# Primary first, then standby, over the private link.
HOSTS=(10.9.0.1 10.9.0.2)

for h in "${HOSTS[@]}"; do
  echo "== deploying to $h =="
  rsync -aH --delete ./compose/ "root@$h:/srv/app/"
  ssh "root@$h" 'cd /srv/app && docker compose pull && docker compose up -d'
done

A drift check you can run any time, and on a cron. The first command compares the resolved compose config on both boxes; the second is a dry run (the -n flag) that reports file differences under /srv without changing anything.

shell
# Compare the fully resolved compose config on both hosts.
diff <(ssh root@10.9.0.1 'cd /srv/app && docker compose config') \
     <(ssh root@10.9.0.2 'cd /srv/app && docker compose config')

# Report what a sync would change, without changing it.
rsync -aHn --delete /srv/ root@10.9.0.2:/srv/

If either check prints differences you did not expect, reconcile them before you need the standby, not during an incident. Patch both boxes on the same cadence too: an unattended-upgrades reboot that lands on only one of them is its own kind of drift. Do the OS updates together and confirm both come back healthy.

The data replication layer

Sameness of code is the easy half. The hard half is data, and it splits into two problems: the database and the files. Get the direction right and both are straightforward. Get it wrong, specifically by syncing in both directions, and you build a machine for corrupting data.

For the database, use the engine's own replication rather than copying files underneath it. PostgreSQL streaming replication keeps the standby continuously in step with the primary; our production database server guide covers the full setup. The two-box specifics are these: run the replication over the private link, not the public internet, so the traffic is encrypted and off the open network, and watch the replication lag, because lag is your real RPO. If the standby is two seconds behind when the primary dies, you lose those two seconds of writes.

For files, pick one of three patterns and keep it strictly one-directional, primary to standby. Continuous sync with lsyncd copies changes within seconds of them landing, which keeps RPO low for user uploads and similar state. Scheduled rsync from cron is simpler and cheaper, but your RPO becomes the interval between runs. Shared object storage sidesteps the problem entirely: if both boxes read and write the same bucket, there is nothing to sync, at the cost of a dependency on that storage. Choose one; do not run two file-sync mechanisms at once.

On the standby, this is your live RPO. It reports how far behind the primary the replica is right now.

shell (standby)
sudo -u postgres psql -x -c \
  "SELECT now() - pg_last_xact_replay_timestamp() AS replication_lag;"

On the primary, this lists every connected replica with its send, flush and replay lag. Alert if state is not streaming or the lag climbs.

shell (primary)
sudo -u postgres psql -x -c \
  "SELECT client_addr, state, write_lag, flush_lag, replay_lag
   FROM pg_stat_replication;"

Continuous file sync with lsyncd, one direction only. Install it with "sudo apt install -y lsyncd", then this config mirrors /srv from the primary to the standby within seconds. It runs on the primary; the standby is the target.

/etc/lsyncd/lsyncd.conf.lua
settings {
    logfile   = "/var/log/lsyncd/lsyncd.log",
    statusFile = "/var/log/lsyncd/lsyncd.status",
    nodaemon  = false,
}

sync {
    default.rsyncssh,
    source    = "/srv/data",
    host      = "10.9.0.2",
    targetdir = "/srv/data",
    delay     = 5,
    rsync = {
        archive  = true,
        compress = true,
        _extra   = { "--delete" },
    },
    ssh = { port = 22 },
}

The simpler alternative: scheduled rsync from cron on the primary. Your RPO is then five minutes, the interval below. Use this or lsyncd, not both.

/etc/cron.d/srv-sync
*/5 * * * * root rsync -aH --delete /srv/data/ root@10.9.0.2:/srv/data/ >/dev/null 2>&1

One rule overrides all of this: sync in one direction only. The moment both boxes write to the same paths and sync back to each other, a file changed on each side at the same time has no correct resolution, and rsync --delete will happily erase data. The primary is the source of truth for files until you promote the standby, at which point you reverse the direction deliberately, as a step in the runbook.

DNS-based failover that works everywhere

DNS failover is the one mechanism that works on every provider, because it needs nothing from the network except the ability to change your own records. The idea is simple: your service name points at the primary's IP, and to fail over you change it to point at the standby's IP. The whole game is making that change take effect quickly, which is entirely about TTL.

Set a low TTL on the service records well in advance, and leave it low. A TTL of 300 seconds tells resolvers to re-check the record every five minutes, so a failover reaches most of the internet within that window. Do this now, in normal times. A record still cached at 3600 seconds when you need to move it turns five minutes of planning into an hour of downtime.

Keep the service records at a 300-second TTL. This is the primary's IP in normal operation; 203.0.113.10 is a placeholder for it.

zone file (records)
; TTL of 300s so a failover propagates within about five minutes.
@       300   IN  A       203.0.113.10
www     300   IN  A       203.0.113.10
@       300   IN  AAAA    2001:db8::10
www     300   IN  AAAA    2001:db8::10

Confirm the TTL that resolvers actually see. The number before the record type is the remaining TTL; it should read 300 or less.

shell
dig +noall +answer www.YOUR_DOMAIN A @1.1.1.1
dig +noall +answer www.YOUR_DOMAIN A @8.8.8.8

Be honest about what a low TTL does and does not guarantee. Some resolvers ignore your TTL and cache longer, some clients pin a connection to an IP for the life of a process, and some corporate networks are slow to expire records. So DNS failover is measured in minutes, not seconds, and a small tail of users takes longer still. That is acceptable for the failure this defends against, a server dying, and it is why anyone needing sub-second failover should read the automation and active-active sections rather than lean on DNS.

If your provider does offer an additional IP you can move between servers, you have a faster option than DNS, covered under automation. Ask the datacenter partner what is available before you design around either path.

The promotion runbook

This is the procedure a human runs when the primary dies. Keep it written down, keep it short, and keep it where the on-call engineer can reach it without the primary being up. Every step below has a reason next to it.

  1. Confirm the primary is really dead

    Check from two vantage points outside the primary, not just your own connection: your monitoring, a phone on mobile data, or the standby's own probe. A network blip or a DNS issue on your side is not a reason to fail over. The customer portal shows the power state of the server, so look there whether the machine is actually down or just off the network.

  2. Promote the database

    On the standby, promote its replica to a writable primary with one command: sudo pg_ctlcluster 16 main promote. The standby is now the source of truth. Do this before repointing traffic, so the first request after failover lands on a database that accepts writes.

  3. Reverse the file sync direction

    The primary-to-standby sync is now dead. Stop it, or point any continuous sync the other way, so the promoted box is not overwritten by a stale source when the old primary is worked on.

  4. Repoint DNS at the standby

    Change the service A and AAAA records to the standby's IP addresses. Because the TTL was already low, most resolvers pick up the change within a few minutes. Watch propagation with dig against a couple of public resolvers.

  5. Watch it come back

    Tail the application logs, hit the health endpoint, and confirm real writes are landing. Only when the service is demonstrably serving from the standby is the failover complete. Then tell your users, and start planning a fresh standby rebuilt from the new primary.

Health checks and the decision to fail over

Failover starts with knowing the primary is down, and the trap is checking from the wrong place. A health check that runs on the primary itself tells you nothing when the primary is unreachable. Check from outside: an external uptime service, or your own small probe running on the standby and on a third vantage point, so a single failed network path does not look like a dead server.

At two-server scale, keep the decision to fail over in human hands. This is the single most effective defence against split-brain, the state where both boxes think they are the primary and both accept writes, which is far more damaging than a few extra minutes of downtime. A probe that alerts a human, who then confirms and runs the runbook, will not split your brain. A script that promotes automatically on a failed ping eventually will.

A probe you run on the standby (or a third box). It checks the primary from outside and only alerts; it never promotes anything. Two failures a few seconds apart, not one, keep a single dropped packet from paging anyone.

/usr/local/bin/check-primary.sh
#!/usr/bin/env bash
set -euo pipefail

PRIMARY_URL="https://YOUR_DOMAIN/healthz"

check() { curl -fsS --max-time 5 "$PRIMARY_URL" >/dev/null; }

if ! check; then
  sleep 10
  if ! check; then
    /usr/local/bin/alert.sh "primary healthcheck failed twice, human decision needed"
  fi
fi

Run the probe every minute from cron. Make the script executable first with "sudo chmod +x /usr/local/bin/check-primary.sh".

/etc/cron.d/check-primary
* * * * * root /usr/local/bin/check-primary.sh

Wire the alert into whatever you already run. Our self-hosted monitoring guide sets up alerting you can point this at; the probe's only job is to page a human, never to act. The human confirms with the runbook's first step, then decides.

Optional automation, with the caveats

Automatic failover is worth reaching for eventually, but every layer of automation is new failure surface, and it earns its place only after the manual version is rehearsed and boring. Two paths are worth knowing, with clear caveats on each.

The first is a load balancer on a third node. A small box running HAProxy sits in front, health-checks both servers, and sends traffic to the standby automatically when the primary fails its check. This is genuinely automatic and provider-agnostic, but it moves the single point of failure to the load balancer, so for real resilience that node itself has to be made redundant, and now you are running at least three machines.

HAProxy on the third node. The standby is marked "backup", so it takes traffic only when the primary fails its health check. Point the frontend at your public IP and the servers at the private addresses.

/etc/haproxy/haproxy.cfg
global
    log /dev/log local0
    maxconn 4096

defaults
    mode    http
    log     global
    option  httplog
    timeout connect 5s
    timeout client  30s
    timeout server  30s

frontend web
    bind :80
    default_backend app

backend app
    option httpchk GET /healthz
    server primary 10.9.0.1:80 check inter 2s fall 3 rise 2
    server standby 10.9.0.2:80 check inter 2s fall 3 rise 2 backup

The second path is keepalived with a VRRP floating IP. Read the caveat above the block before you use it: it depends entirely on your provider's network. On many dedicated-server networks this simply does not work, so treat this snippet as conditional.

/etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 200
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass CHANGE_ME
    }
    virtual_ipaddress {
        203.0.113.100/32
    }
}

Keepalived and VRRP are the classic datacenter answer, fast and needing no DNS change, but they rest on assumptions a rented dedicated server often does not meet: that the two boxes share a layer-2 segment, that the provider will route an additional IP you can move between them, and that gratuitous ARP is honored so the move takes effect. Do not design around VRRP until you have asked the datacenter partner directly whether floating or additional IPs and that ARP behaviour are supported. Where they are not, DNS failover is your path.

Whichever you choose, add it after the two-box manual setup already works, not instead of it. Automation that fails over to an unrehearsed standby just fails faster. Rehearse first, automate second.

The quarterly failover drill

A failover you have never performed is a hypothesis. Prove it on a schedule, quarterly is a sensible default, in a planned window rather than during a real outage. The goal is a runbook any on-call engineer can follow and a team that has felt the procedure at least once.

  1. Schedule and announce

    Pick a low-traffic window and tell the team. This is a drill, so a short, expected blip is fine; surprising your users is not the point.

  2. Fail over by the runbook, and time it

    Follow the written promotion runbook exactly, step by step, and record how long each step takes. If a step is unclear or an assumed access is missing, that is the drill doing its job.

  3. Verify the standby serves real traffic

    Run genuine checks against the promoted box: log in, place an order, write and read data. A standby that answers a health check but cannot serve the real app has proven nothing.

  4. Fail back cleanly

    Restore the original direction: rebuild replication from the promoted box back to the original primary, resync files the right way, and repoint DNS. Failing back is as much a skill as failing over, and it is where half-finished setups reveal themselves.

  5. Update the runbook with what surprised you

    Every drill turns up something: a stale credential, a missing DNS permission, a command that changed between versions. Fix the runbook while it is fresh, so the next drill, or the next real incident, is smoother.

When two servers are not enough

Two boxes are the right amount of redundancy for a lot of services, and the wrong amount for some. Know which you are running.

If you genuinely need active-active, where both servers take traffic at once and any single loss is invisible, you have outgrown a hand-managed pair. That is the job of an orchestrator that schedules across nodes and moves work off a dead one on its own. A small Kubernetes cluster on bare metal, k3s across three or more nodes, is the honest next step, and our Kubernetes on bare metal guide covers it. It is more moving parts, so adopt it because you need active-active, not because it sounds modern.

If your risk is the whole site going dark, a power or network event at one location, then two servers in the same building do not help, however well replicated. That is a case for a second location: a standby in the datacenter partner's other region, or a different provider entirely, with the same replication and DNS failover stretched across the distance. The mechanics in this guide still apply; the link between the boxes is just longer and slower.

And for many small teams the honest answer is neither. One larger, well-run server with excellent, tested backups will out-serve a fragile two-box setup nobody rehearses. If your tolerance is a few hours of RTO and you actually restore-test your backups, spend the money on one good machine and a solid backup regime, covered in our backup strategy guide, before you take on the cost and complexity of a standby. Redundancy you do not maintain is theatre.

What each failure costs you

The point of the whole exercise, in one table. A two-box setup answers exactly one class of failure well and does nothing for the others, and being clear-eyed about that is what keeps it honest.

What the two-box setup does What it still costs you
Primary hardware or disk dies Promote the standby, repoint DNS, back in minutes A manual runbook and a rehearsed on-call
A bad deploy breaks the app Nothing: the standby runs the same broken release Roll back on the primary; keep good backups
Data deleted or corrupted by mistake Nothing: replication copied the mistake in seconds Point-in-time backups, not a standby
The whole site loses power or network Nothing, unless the standby is in a second location A second site, with its own cost
You lock yourself out with a firewall rule Not a failover case at all Console access on request, through support

The honest bottom line

A second dedicated server is a recovery tool for one specific failure: the machine dying. It buys you minutes instead of hours, and only if you have replicated data correctly and rehearsed the promotion. It does nothing for bad deploys, deletions, or a whole-site outage, and it is not a backup. Build the warm standby if that failure and that RTO matter to you, keep the runbook current, drill it quarterly, and keep your backups just as sharp. Pick the two machines from the dedicated server range and you have both halves of a pair that can actually save you.

Continue reading

Need help choosing?

Our experts can help you find the perfect server for your needs.

Contact us »