High availability: HAProxy, Keepalived, Pacemaker and Corosync
Exit

Lesson 1 of 12 · Fundamentals

Putting numbers on availability: SLA, MTTR, RTO, RPO and single points of failure

40 min Debian 12 Versions Debian 12, Rocky 9, Ubuntu 24.04

Objective

Before installing HAProxy or Pacemaker, know what you must guarantee: measure the real availability of a service, understand what lowers it, and find the components whose failure stops everything.

Key points

  • Availability is computed from real incidents, following the rules of the contract (what is excluded, how it is measured).
  • A = MTBF ÷ (MTBF + MTTR): you gain as much by repairing faster (MTTR) as by failing less often (MTBF).
  • RTO (acceptable downtime) and RPO (acceptable data loss) translate directly into technologies: automatic or manual failover, synchronous or asynchronous replication, backups.
  • A single point of failure (SPOF) is any element present only once on the path of a request: a server, but also a switch, a power supply, a certificate, an administrator.
  • Adding redundancy adds complexity: every failover mechanism becomes a source of outages itself if it is not tested.

The basics (table of “nines”, cloud provider SLAs, the 3-2-1 rule) are in the Cloud fundamentals course; SLOs and error budgets in Observability. Here, we move on to calculations for a platform you run yourself.


1. Measuring availability as the contract defines it

A service level agreement (SLA) always states:

Clause Example Effect on the calculation
Measurement period calendar month 30 days = 43,200 min, 31 days = 44,640 min
Exclusions maintenance announced 48 h in advance, force majeure these minutes do not count
Definition of “unavailable” the home page does not answer within 5 s from two probes slowness can count as an outage
Penalty 10% credit below 99.9%, 25% below 99% what missing the target costs

The calculation from an incident log:

# date;type;minutes;description
awk -F';' '$2=="imprevu" {s += $3} END {printf "%.2f %%\n", 100 * (1 - s/43200)}' incidents.csv

The “contractual” figure is not what customers experienced: a planned one-hour maintenance on a Saturday evening does not count in the SLA, but the shop was still closed. Track both: contractual availability (for penalties) and real availability (to decide on investments).

2. MTBF, MTTR: repairing fast matters as much as not failing

  • MTBF (mean time between failures): average time between two failures.
  • MTTR (mean time to repair/restore): average time to restore the service.
A = MTBF / (MTBF + MTTR)

Une panne par mois (MTBF ≈ 720 h) réparée en 4 h  : 720 / 724   = 99,45 %
La même panne réparée en 30 min                    : 720 / 720,5 = 99,93 %

MTTR breaks down into: detecting (monitoring), diagnosing (logs, procedures), repairing (access, spare parts, backups), checking. Automatic failover mostly shortens the repair; a good alert shortens detection. An on-call team in Casablanca that gets the alert in 1 minute instead of 20 gains more than with a badly configured second server.

3. RTO and RPO: from business need to technology

Stated need RTO RPO Typical technical answer
“The showcase site can wait until tomorrow” 24 h 24 h nightly backup, manual restore
“The shop must not be closed for more than 15 min” 15 min 5 min two servers, guided manual failover, asynchronous replication
“Payments must never be lost” 1 min 0 cluster with automatic failover, synchronous replication, fencing

Points to remember:

  • RPO = 0 requires synchronous replication (DRBD protocol C, PostgreSQL synchronous_commit): every write waits for the second server, so latency goes up.
  • The real RPO of a daily backup is 24 h in the worst case (failure just before the next backup), not “a few hours”.
  • The real RTO is measured during a failover test, stopwatch in hand. An RTO that was never tested is an assumption.

4. Inventorying single points of failure

Follow the path of a request, from the client to the disk, and note each step:

client ─► DNS ─► lien Internet ─► pare-feu ─► ml-lb-01 ─► ml-web-0[1-3] ─► ml-app-0[1-2] ─► ml-db-0[1-2]
                                                    │
                                              ml-nfs-01 (fichiers clients)
# Un inventaire simple : composant;rôle;exemplaires
awk -F';' 'NR > 1 && $3 == 1 {print "SPOF :", $1, "(" $2 ")"}' architecture.txt

The SPOFs most often forgotten:

Category Examples
Network a single core switch, a single carrier link, two links… from the same carrier
Power two power supplies on the same power strip, a single UPS
Shared services internal DNS, NTP, LDAP directory, NFS server, image registry
Logical items a TLS certificate, an expiring domain name, a licence key
People only one person knows the procedure or holds the access

For each SPOF, three possible answers: duplicate it, reduce its MTTR (spare part, written procedure, expiry monitoring), or accept the risk and put it in writing.

5. The cost of redundancy

Duplicating a component does not double reliability if:

  • both instances share a common cause (same rack, same buggy software version, same wrong configuration pushed everywhere);
  • the failover mechanism is never tested;
  • nobody notices that one of the two has already failed (“dormant” redundancy: you discover the second one is broken the day the first one fails).

Operating rule: all redundancy must be monitored. A load balancer serving traffic with only one server out of three alive must raise an alert, even if customers see nothing.

Version differences

Item Debian 12 / Ubuntu 24.04 Rocky 9
High-availability packages main repository (haproxy, keepalived, pacemaker, pcs, drbd-utils) haproxy, keepalived in AppStream; pacemaker, pcs in the HighAvailability repository, to enable (dnf config-manager --set-enabled highavailability)
Cluster management tool pcs or crmsh pcs
DRBD module drbd-utils package + kernel module (DRBD 9 from the project's repository) ELRepo repository or the project's packages

Common pitfalls

  • Counting planned maintenance in an SLA calculation that excludes it, or the other way round: read the contract before computing.
  • Confusing RPO with backup frequency: a backup every 24 h gives an RPO of 24 h, not 12 h “on average”.
  • Forgetting dependencies: two redundant web servers mounting the same single NFS server still depend on that NFS server.
  • Promising 99.99% (4 min per month) with a manual failover procedure that takes 20 minutes.

Lab

On a Debian 12 machine, you have the September incident log of the MasterLinux shop and an inventory of its architecture. You will:

  1. compute availability as the contract defines it;
  2. say whether the 99.9% SLA was met;
  3. compute the MTTR;
  4. extract the list of single points of failure;
  5. give the real RPO of a single nightly backup.

Quiz

  1. Why can two teams report two different availability figures for the same month?
  2. One failure per month, repaired in 30 minutes instead of 4 hours: which indicator improves?
  3. Which replication is needed for an RPO of zero, and what does it cost?
  4. Name three single points of failure that are not servers.
  5. What is “dormant” redundancy and how do you avoid it?
Answers
  1. They do not apply the same rules: exclusions (planned maintenance), definition of unavailability, measurement period.
  2. MTTR, and therefore availability: A = MTBF ÷ (MTBF + MTTR) goes from about 99.45% to 99.93%.
  3. Synchronous replication (DRBD protocol C, synchronous PostgreSQL replica); every write waits for confirmation from the second server, so latency increases.
  4. A single switch, a carrier link, a power supply, a TLS certificate, a domain name, the internal DNS, a single person who knows the procedure.
  5. A backup instance that has already failed without anyone knowing; you avoid it by monitoring each member, not only the overall service.

Practical exercises

To do on Debian 12

Do this lab on your own machine

The terminal is yours: a Linux VM (VirtualBox, VMware, Hyper-V, WSL…) or Docker/Podman. The ml tool prepares the exercise and checks your work; the lesson is validated here automatically.

Create a free account to get your personal command and have your labs checked automatically.

Create my account

Tasks

  1. The SLA of the MasterLinux shop excludes planned maintenance. Using /root/ha/incidents.csv (September, 30 days), compute the availability as defined by the contract and write it with two decimals (e.g. 99.95) to /root/ha/dispo.txt.
    Show a hint30 days = 43,200 minutes. Count only the “imprevu” (unplanned) lines: 38 + 21 + 27.4.
    Show the solution
    awk -F";" '$2=="imprevu"{s+=$3} END{printf "%.2f\n", 100*(1-s/43200)}' /root/ha/incidents.csv > /root/ha/dispo.txt

    Check : grep -Eqx " *99[.,]80 *%? *" /root/ha/dispo.txt

  2. The SLA promises 99.9%. Was it met this month? Write oui (yes) or non (no) to /root/ha/sla.txt.
    Show a hintCompare your result with 99.90.
    Show the solution
    echo non > /root/ha/sla.txt

    Check : grep -Eqix " *non *" /root/ha/sla.txt

  3. Compute the mean time to restore (MTTR) of the unplanned incidents, in minutes, and write the number to /root/ha/mttr.txt.
    Show a hintMTTR = total duration of unplanned outages ÷ number of unplanned outages.
    Show the solution
    awk -F";" '$2=="imprevu"{s+=$3;n++} END{print s/n}' /root/ha/incidents.csv > /root/ha/mttr.txt

    Check : grep -Eqx " *28([.,]8)? *" /root/ha/mttr.txt

  4. In /root/ha/architecture.txt, the third column gives the number of instances of each component. Write to /root/ha/spof.txt the name of each single point of failure, one per line.
    Show a hintA component with a single instance is a single point of failure: awk -F';' '$3==1{print $1}'
    Show the solution
    awk -F";" '$3==1{print $1}' /root/ha/architecture.txt > /root/ha/spof.txt

    Check : test -s /root/ha/spof.txt && test "$(tr -d ' \r' < /root/ha/spof.txt | grep -v '^$' | sort | paste -sd, -)" = "ml-lb,ml-nfs,sw-coeur"

  5. The database has no replica: one full backup per night, at 02:00. What is the maximum possible data loss (real RPO), in hours? Write the number to /root/ha/rpo.txt.
    Show a hintPicture the worst-timed failure: just before the next backup.
    Show the solution
    echo 24 > /root/ha/rpo.txt

    Check : grep -Eqx " *24 *(h|heures)? *" /root/ha/rpo.txt