Back to Articles

Building High-Availability Infrastructure

Contents

Introduction — The Cost of Downtime

Friday, 2:47 PM. The ERP system stops responding. Users across the plant floor lose access mid-transaction. The support queue explodes. Managers are calling your phone directly. This is the moment every infrastructure team dreads — and high-availability architecture is specifically designed to prevent.

The cost of downtime is service-specific. Measure lost transactions or production, labor, contractual penalties, safety impact, and the work required to recover. That estimate sets the recovery objective and the amount of redundancy the service can justify.

High-availability (HA) infrastructure addresses this directly. It eliminates single points of failure so that when a server crashes, a service hangs, or a network path drops — the application keeps serving traffic without requiring a human to SSH in at 3 AM.

The core principle is disarmingly simple: redundancy with automatic detection and recovery. Every component — server, network path, power supply, storage controller — has a counterpart ready to take over. The hard part is making the handoff seamless, reliable, and safe.

Industry Push for High Availability

The expectation of continuous uptime has shifted from a luxury to a baseline requirement across every vertical. Several forces are driving this change:

  • 24/7 operational demands: Enterprise applications no longer have "off hours." Remote workers, global teams, and connected devices expect continuous access. A batch-window approach to maintenance belongs to a previous era.
  • Regulatory compliance: Standards like NERC-CIP, SOC 2, HIPAA, and PCI-DSS all mandate documented HA and disaster recovery capabilities. In regulated industries, an auditor will ask for your failover test results — not your intentions.
  • Cloud-native expectations: Self-healing infrastructure — auto-scaling groups, health-check-driven replacement, rolling deployments — has become the baseline expectation, even for on-premises environments. Users no longer distinguish between "the cloud is down" and "our servers are down."
  • Ransomware recovery: High availability does not replace isolated backups. Replication can copy destructive changes, so recovery paths must include protected copies and tested restoration.
  • Operational load: Automatic recovery can reduce emergency intervention, but only when the cluster, monitoring, and escalation paths are maintained and tested.

Technology Vendors and Packages

The HA tooling landscape spans from lightweight open-source utilities to full enterprise suites. The right choice depends on your application's statefulness, your team's skill set, and your tolerance for complexity.

Open-Source Solutions

  • Keepalived — The standard VRRP (Virtual Router Redundancy Protocol) implementation for Linux. Provides virtual IP failover between two or more nodes. Keepalived handles simple active-passive failover well, but the VRRP advertisement interval and election timeout mean failover takes 3-10 seconds minimum. For sub-second failover needs, consider hardware load balancers or an active-active Linux Virtual Server (LVS) setup, where both nodes are already carrying traffic — losing one costs you capacity rather than requiring a handover at all. Works with any application that listens on an IP:port.
  • Pacemaker + Corosync — Enterprise-grade cluster resource manager. Pacemaker handles resource orchestration (start, stop, monitor, relocate); Corosync provides the membership and messaging layer. Ideal for stateful applications like PostgreSQL, MariaDB, and SAP. The learning curve is steep — the configuration is XML-based and the resource agent ecosystem has quirks — but for database HA, it is the gold standard in open source.
  • HAProxy — High-performance TCP/HTTP load balancer with application-layer health checks. HAProxy excels at stateless load balancing where session stickiness is optional. Its health-check system supports multiple methods (HTTP status, layer-4 connect, script-based) and configurable rise/fall thresholds that prevent flapping.

Commercial Solutions

  • VMware vSphere HA — Host-level HA for virtualized environments. Automatically restarts VMs on healthy hosts after hardware failure. Simple to configure but recovery is VM-restart time (1-5 minutes), not sub-second. Best paired with application-level HA inside the guest for critical workloads.
  • Microsoft Failover Clustering — Native HA for Windows applications including SQL Server Always On Availability Groups and file server clusters. Tight integration with Active Directory and Windows Update. Quorum models (node majority, file share witness, cloud witness) are well-documented but misconfiguration is a common source of split-brain incidents.
  • Veritas Cluster Server (VCS) — Enterprise application HA supporting Oracle, SAP, and custom applications. VCS has been deployed in production for over two decades and is battle-tested at scale. The trade-off is cost and operational overhead — VCS typically requires dedicated administrators in large deployments.

Vendor Comparison

Product Type Max Nodes Failover Speed Best For
Keepalived Open Source (VRRP) 255 3-10 s Stateless VIP failover, simple pairs
Pacemaker + Corosync Open Source (CRM) 32 5-30 s Stateful apps, databases
HAProxy Open Source (LB) N+1 (active-active) Sub-second TCP/HTTP load balancing, TLS termination
VMware vSphere HA Commercial 64+ hosts 1-5 min Virtualized environments, host-level HA
Microsoft Failover Clustering Commercial (Windows) 64 10-30 s SQL Server, file shares, Exchange
Veritas Cluster Server Commercial 32 5-20 s Oracle, SAP, custom enterprise apps

Failover speeds are typical ranges under normal conditions. Actual performance varies with application startup time, health-check complexity, and network latency.

Choosing the right approach: For stateless applications (web servers, API gateways, reverse proxies), Keepalived plus HAProxy is lightweight and proven — you can set it up in an afternoon. For stateful applications (databases, ERP systems), Pacemaker or a commercial clustering solution provides the application-aware failover needed to prevent data corruption. Do not use a generic VIP failover tool for a database without understanding write-ordering and replication lag. A tool like Keepalived only moves an IP address from one machine to another — it has no idea whether the standby database actually received the most recent committed transactions. Move the VIP to a replica that is a few seconds behind and those transactions are gone, and if the original node later comes back still holding writes the standby never saw, you now have two copies of the database that disagree and no automatic way to reconcile them.

Reference Architecture

The most common HA pattern for enterprise applications is active-passive with a floating virtual IP (VIP). Node A runs the application and owns the VIP. Node B stands by with the application installed and configured, monitoring Node A's health. When Node A fails — whether by hardware fault, kernel panic, or a service crash — the health check fails, Node B takes ownership of the VIP, starts its application services, and continues serving traffic.

This pattern works because the VIP decouples the service endpoint from the physical server. Clients connect to the VIP (e.g., 192.168.1.100). Which server actually holds that IP is transparent to them. A DNS TTL issue never enters the picture because no DNS change is needed.

For higher throughput or zero-downtime during maintenance, an active-active pattern spreads traffic across both nodes using a load balancer. This doubles capacity but requires the application to handle concurrent writes or provide session stickiness. Active-active should not be attempted without testing for race conditions, write conflicts, and cache invalidation across nodes.

Example Configuration

Below is a generic Keepalived configuration for an active-passive application server pair. All addresses and interface names are placeholders — adapt them to your environment.

File: /etc/keepalived/keepalived.conf — MASTER node

global_defs {
    router_id APP-MASTER-01
}

vrrp_script check_app {
    # This script runs every 3 seconds. It must exit 0 for healthy.
    script "/usr/local/bin/check_app.sh"
    interval 3
    fall 3    # Declare dead after 3 consecutive failures
    rise 2    # Declare alive after 2 consecutive successes
}

vrrp_instance VI_APP {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100               # Higher priority wins the VIP
    advert_int 1               # VRRP advertisement every 1 second

    authentication {
        auth_type PASS
        auth_pass GENERIC_HA   # Change this in production
    }

    virtual_ipaddress {
        192.168.1.100/24 dev eth0
    }

    track_script {
        check_app
    }

    notify_master "/usr/local/bin/ha_notify.sh master"
    notify_backup "/usr/local/bin/ha_notify.sh backup"
    notify_fault "/usr/local/bin/ha_notify.sh fault"
}

File: /etc/keepalived/keepalived.conf — BACKUP node

global_defs {
    router_id APP-BACKUP-01
}

vrrp_script check_app {
    script "/usr/local/bin/check_app.sh"
    interval 3; fall 3; rise 2
}

vrrp_instance VI_APP {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 99                # Slightly lower than MASTER
    advert_int 1

    authentication {
        auth_type PASS
        auth_pass GENERIC_HA
    }

    virtual_ipaddress {
        192.168.1.100/24 dev eth0
    }

    track_script {
        check_app
    }
}

Application health check script:

#!/bin/bash
# /usr/local/bin/check_app.sh
# Returns 0 if the application is healthy, 1 otherwise.

curl -sf http://127.0.0.1:8080/health || exit 1
exit 0
Production tip: The health check script should test more than TCP connectivity. A port can be open while the application is serving stale data or running in a degraded state. A good health endpoint returns a 200 OK only after confirming database connectivity, cache reachability, and that the last replication cycle completed successfully.

How It Helps

  • Automated failover in seconds — no human needs to wake up, SSH in, diagnose, and restart services. The cluster handles it.
  • Maintenance without downtime — patch the MASTER during business hours while the VIP floats to BACKUP. Upgrade the OS, apply kernel patches, swap hardware — all without a maintenance window.
  • Application-agnostic — works with any application that binds to an IP:port. The same pattern applies to Nginx, Apache, Tomcat, Node.js, Python WSGI servers, and custom binaries.
  • No DNS changes needed — the virtual IP does not change during failover. Clients reconnect on the same address. No TTL propagation delay. No stale DNS caches.
  • Predictable recovery time — because failover is automated and tested, recovery time is measurable and repeatable. You can commit to a recovery time objective (RTO) — the maximum outage duration you promise a service will not exceed — in your SLA and have the test data to back the promise up.

ROI Analysis

A useful HA business case starts with the service being protected. Generic downtime averages hide more than they explain.

Model HA per service. Use that service's measured incident frequency, minutes to recover without failover, and business cost per minute. Compare the annual exposure with the second node, licenses, implementation, monitoring, and failover-test labor. Exclude failures HA does not solve—bad deployments, corrupted shared data, and dependency outages—so the model credits only the downtime this design can prevent.

What to Watch Out For

HA infrastructure is not a set-it-and-forget-it solution. Several failure modes can turn a well-intentioned HA deployment into a source of downtime rather than a cure.

Split-Brain Scenarios

A split-brain occurs when the cluster membership protocol loses communication between nodes, and each node believes the other is dead — so both attempt to take over the VIP and start serving. For stateless applications, this means duplicate traffic and confusing logs. For databases, split-brain can cause data corruption that is difficult or impossible to repair without restoring from a backup taken before the event.

VRRP-based solutions like Keepalived mitigate this through the VRRP election mechanism — a BACKUP node will not preempt an active MASTER without seeing advertisements time out. However, a true network partition can still trigger a brief window where both nodes believe they hold the VIP. The fix: configure a separate management network for cluster traffic (a dedicated VLAN or a direct crossover cable), and set firewall rules that prevent VIP advertisement packets from arriving on unexpected interfaces.

Quorum and Fencing (STONITH)

Pacemaker clusters use a quorum-based decision model: a partition with fewer than half the expected nodes cedes control. In a two-node cluster, a tie means neither node can achieve quorum. This is where a quorum device (a third node, a shared disk witness, or an external vote) becomes necessary.

STONITH — "Shoot The Other Node In The Head" — is the fencing mechanism that ensures a failed node cannot continue accessing shared resources (disk, LUNs, cluster filesystem). Without fencing, a node that has hung but not fully powered off might continue writing to shared storage, corrupting data when the healthy node takes over. STONITH works through whatever can cut power to a node from outside its operating system: the server's out-of-band management processor (IPMI, HP iLO, Dell iDRAC) or a managed power distribution unit (PDU) that can switch off the outlet the node is plugged into. The distinction that matters is that the surviving node never asks the failed node to stop — a hung node cannot honor a request — it removes the failed node's ability to keep writing. Never deploy a shared-storage Pacemaker cluster without STONITH configured and tested.

Stateful vs. Stateless Failover

The distinction between stateful and stateless applications is the single most important factor in HA design:

  • Stateless applications (web servers, API gateways, reverse proxies): Any node can serve any request. Failover is simple — just redirect traffic. No data consistency concerns.
  • Stateful applications (databases, message queues, session stores): Failover must preserve data integrity. The standby must have a consistent copy of the state before it can take over. This requires synchronous replication, write-ahead logs, and careful handling of in-flight transactions. Replication lag is not just a performance metric — it is a data-loss risk window.

If your application maintains in-memory state (user sessions, cache, websocket connections), a simple VIP failover will drop that state. Introduce a shared session store (Redis, Memcached with replication) or design the application to recover gracefully from connection drops.

Monitoring the Cluster Itself

An HA cluster is itself a system that can fail. Who monitors the monitor?

  • Cluster health: Monitor the cluster management daemon (keepalived, pacemaker, corosync) independently. A keepalived process crash on both nodes means no one is watching — and no one will fail over.
  • Split-brain detection: Add an external monitoring check that validates only one node holds the VIP at any time. A Nagios/Icinga/PRTG check that curls the VIP and verifies the responding hostname is a low-effort safeguard.
  • Failover test automation: Run a scheduled failover test monthly. A cluster that has never failed over in production will fail in unexpected ways when it finally has to. Automate the test — scripted VIP movement, application health validation, and automatic failback — so it can run outside business hours without an engineer watching.
  • Alert routing: Cluster notifications (state transitions, script failures, STONITH events) should route to a separate alerting pipeline from the application itself. If the application is down and the cluster monitoring shares its infrastructure, you cannot receive the alert that tells you why.

The Bottom Line

High availability is justified when the service's recovery-time objective cannot be met reliably with manual recovery. The design must include the dependencies that can still fail independently: data, network paths, name resolution, identity, monitoring, and the people and procedures used during an incident.

Select active-passive, active-active, or manual recovery from measured service requirements. Test failure and restoration often enough to detect configuration drift, record the achieved recovery time, and revise the design when the test misses the target.

Define availability and recovery targets from business impact, then verify the system against them. Record the user-visible interruption, data loss, manual actions, and time to restore normal redundancy during each exercise.

← Back to Articles Next: Zero Trust Network Security →