High Availability, Fault Tolerance, and Reliability
Calculating system availability and downtime, understanding the nines (99.9% vs 99.999%), Mean Time Between Failures, and eliminating single points of failure.
In distributed systems, hardware failures are not anomalies; they are daily mathematical certainties. If you run a small web application on 2 cloud virtual machines with an average hardware lifespan of 3 years, you might experience a server failure once every 18 months. If you scale up to run 10,000 servers across three datacenters, you will experience an average of 9 server failures, 3 disk crashes, and 1 network switch hiccup every single day.
A system designed with the assumption that hardware never fails is inherently fragile. High-Level Design focuses on building High Availability (HA) architectures that keep operating smoothly even when individual underlying components crash, burn, or lose connectivity.
01Defining Availability and Reliability
Although they sound similar, reliability and availability measure different operational characteristics:
Reliability (How long it runs without breaking)
Reliability is the probability that a system will perform its required function without failure over a specified period of time. It is commonly quantified using Mean Time Between Failures (MTBF).
- If a database server runs continuously for 6 months before experiencing a kernel panic, its MTBF is approximately 4,320 hours.
Availability (Percentage of time it is ready to serve)
Availability is the percentage of total time that a system remains operational and accessible to process requests when needed. It accounts for both failure frequency (MTBF) and recovery speed (Mean Time to Recovery, or MTTR).
Availability = Uptime / (Uptime + Downtime) = MTBF / (MTBF + MTTR)Consider two different designs:
- Design A: Crashes once a year, but takes 3 days (72 hours) to restore from tape backups. Availability = 99.18 percent.
- Design B: Crashes 20 times a year, but an automated health checker restarts the node in 3 seconds every time (total downtime = 1 minute). Availability = 99.9998 percent.
Design B has lower reliability (more frequent failures), but vastly superior availability because its recovery time is near zero. In modern cloud architecture, you achieve high availability not by trying to prevent all hardware failures, but by designing automated systems that recover in seconds.
02The "Nines" of Availability
In enterprise Service Level Agreements (SLAs), availability is expressed as a number of "nines":
| Availability | Allowed Downtime per Year | Allowed Downtime per Month | Typical Industry Context |
|---|---|---|---|
| 99% (Two 9s) | 3 days, 15 hours, 36 min | 7 hours, 18 min | Internal prototypes, non-critical batch tools |
| 99.9% (Three 9s) | 8 hours, 45 minutes | 43 minutes, 49 sec | Standard SaaS apps, internal business software |
| 99.95% | 4 hours, 22 minutes | 21 minutes, 54 sec | Standard commercial cloud services (AWS EC2 SLA) |
| 99.99% (Four 9s) | 52 minutes, 35 seconds | 4 minutes, 21 sec | Tier-1 payment platforms, enterprise communication |
| 99.999% (Five 9s) | 5 minutes, 15 seconds | 26.3 seconds | Telecom carrier switches, financial stock exchanges |
Every additional "nine" you add to your system availability increases infrastructure complexity and operational cost exponentially. Moving from 99.9 percent to 99.99 percent requires multi-server redundancy, automated health checks, and database replication. Moving from 99.99 percent to 99.999 percent requires active-active multi-region deployments, automated traffic failover across continents, and zero-downtime deployment pipelines.
03Eliminating Single Points of Failure (SPOF)
A Single Point of Failure (SPOF) is any component in an architecture whose failure will cause the entire system to stop functioning.
To build an HA system, you must audit the end-to-end request path and eliminate every SPOF using redundancy:
SPOF Audit Checklist:
1. Is there only one DNS provider? -> Use dual DNS providers with Anycast.
2. Is there only one Load Balancer? -> Deploy active-passive LB pairs with VRRP.
3. Is there only one Application Server? -> Run at least 3 stateless nodes across AZs.
4. Is there only one Database Primary? -> Set up automated replication with failover.
5. Is power tied to a single grid feed? -> Cloud availability zones use distinct power/water.04Architectural Redundancy Patterns
Redundancy is the practice of duplicating critical system components so that a backup takes over immediately if the primary fails. There are two primary redundancy topologies in system design:
Active-Passive Redundancy (Standby Failover)
In an active-passive setup, one node handles 100 percent of the live production traffic, while an identical standby node sits idle (or in read-only mode).
- A monitoring agent sends periodic heartbeats (e.g. every 1 second) between the two nodes.
- If the active node stops responding to 3 consecutive heartbeats, an automated mechanism promotes the passive node to become the new active primary.
- Trade-offs: Simple to reason about because there are no concurrent write conflicts. However, hardware utilization is inefficient (50 percent of your paid compute sits idle), and failover introduces a momentary latency spike or brief window of dropped in-flight transactions.
- Common use case: Relational database primaries (e.g., PostgreSQL with a standby replica).
Active-Active Redundancy (Clustered Co-Processing)
In an active-active setup, all redundant nodes actively receive, process, and respond to incoming traffic simultaneously.
- A load balancer or Anycast DNS router distributes client requests across all available active nodes (e.g., 50 percent to Node A, 50 percent to Node B).
- If Node A experiences a hardware failure, the load balancer detects the dropped TCP connection and immediately diverts 100 percent of the traffic to Node B.
- Trade-offs: 100 percent hardware utilization with zero wasted standby machines, and near-zero recovery time (sub-second failover). However, keeping state synchronized across active nodes requires sophisticated distributed data replication.
- Common use case: Stateless web application tiers, CDN edge nodes, and distributed NoSQL databases (e.g., Cassandra, DynamoDB).
05Fault Tolerance vs Graceful Degradation
A fault-tolerant system continues operating without any interruption in service when a component fails. However, achieving 100 percent fault tolerance for every feature during a major outage is often cost-prohibitive.
Modern distributed systems employ Graceful Degradation (also called fallback design):
- Core Path Protection: If the recommendation machine learning model goes down on an e-commerce website, the site does not return an HTTP 500 error on the home page. Instead, it falls back to showing a static, hardcoded list of the top 10 best-selling items.
- Read-Only Mode: If the database primary loses write quorum during a network partition, the application dynamically switches to read-only mode. Users can still browse products, read reviews, and view existing orders, but checkout buttons show a temporary maintenance notification.
- Circuit Breakers: Upstream services use circuit breakers to stop calling an unresponsive downstream dependency, preventing thread exhaustion from cascading across the entire datacenter.
06In the interview
When an interviewer asks you to ensure high availability for a design:
- State the SLA Upfront: "Assuming we target 99.99 percent availability (four nines), we have an error budget of approximately 52 minutes of total downtime per year. This mandates automated failover with no manual human intervention in the recovery path."
- Walk Through Failure Modes: Explicitly trace what happens when:
- A single application node dies (the load balancer health check drops it within 5 seconds).
- An entire datacenter / Availability Zone goes offline (traffic shifts to another AZ via global routing).
- The database primary crashes (a replica is automatically promoted via consensus quorum).
- Separate Stateful from Stateless Failures: Emphasize that stateless nodes failover instantly with zero data risk, whereas stateful database failover requires managing replication lag to prevent split-brain scenarios.