Nextgen Blog
HomeLearnAIQuantumRoboticsSecuritySpaceAbout
Nextgen Blog

By Anubhav — full stack engineer, IIT Mandi CSE. Deep dives into AI, software engineering, and the technologies shaping the next generation of tech.

Navigate

  • Home
  • Learn
  • Blog
  • Archive
  • About

Topics

  • Artificial Intelligence
  • Quantum Computing
  • Robotics
  • Cybersecurity
  • Space Tech

Connect

Built with ❤️ & By - Anubhav

© 2026 Nextgen Blog by Anubhav. All rights reserved.

Privacy PolicyTerms of Service
Phase 06 · Resilience, Security & OperationsChapter 30 of 33
29.
Phase 06Read time ~22 minDifficulty advanced

Fault Tolerance

In this chapter
  • 01Chapter Overview
  • 02Fault Tolerance vs High Availability
  • 03High Availability
  • 04Fault Tolerance
  • 05What Is a Fault?
  • 06Fault vs Error vs Failure
  • 07Fault
  • 08Error
  • 09Failure
  • 10Types of Failures
  • 11Crash Failure
  • 12Omission Failure
  • 13Timing Failure
  • 14Network Failure
  • 15Partial Failure
  • 16Example of Partial Failure
  • 17Failure Containment
  • 18Timeouts
  • 19Timeout Selection
  • 20Deadlines
  • 21Retries
  • 22Retry Storm
  • 23Exponential Backoff
  • 24Jitter
  • 25Idempotency
  • 26Circuit Breaker
  • 27Circuit Breaker Example
  • 28Bulkheads
  • 29Resource Isolation
  • 30Backpressure
  • 31Load Shedding
  • 32Graceful Degradation
  • 33Replication for Fault Tolerance
  • 34Redundancy Is Not Enough
  • 35Failure Domains
  • 36Self-Healing Systems
  • 37Self-Healing Risks
  • 38Retry vs Fail Fast
  • 39Retry Budget
  • 40Fallbacks
  • 41Stale Data as a Fault-Tolerance Tool
  • 42Queue-Based Fault Tolerance
  • 43Dead-Letter Queue
  • 44Poison Messages
  • 45Data Corruption
  • 46Backup vs Replication
  • 47Replication
  • 48Backup
  • 49Recovery Point Objective
  • 50Recovery Time Objective
  • 51Graceful Restart
  • 52Connection Draining
  • 53Fault Injection
  • 54Chaos Engineering
  • 55Chaos Engineering Principles
  • 56Failure Injection Examples
  • 57Application
  • 58Network
  • 59Database
  • 60Queue
  • 61Infrastructure
  • 62Fault Tolerance Testing
  • 63Failure Injection Matrix
  • 64Fault-Tolerant Payment Architecture
  • 65Fault-Tolerant Order Architecture
  • 66Fault-Tolerant API Architecture
  • 67Fault-Tolerant Distributed Storage
  • 68Anti-Entropy
  • 69Self-Healing Replication
  • 70Fault Tolerance and Capacity
  • 71Failure Budget
  • 72Fault-Tolerance Layers
  • 73Do Not Add Every Mechanism Everywhere
  • 74Observability for Fault Tolerance
  • 75Recovery Metrics
  • 76MTTR
  • 77Failover time
  • 78Recovery success rate
  • 79Retry amplification
  • 80Common Misconception #1
  • 81Wrong
  • 82Common Misconception #2
  • 83Wrong
  • 84Common Misconception #3
  • 85Wrong
  • 86Common Misconception #4
  • 87Wrong
  • 88Common Misconception #5
  • 89Wrong
  • 90Common Misconception #6
  • 91Wrong
  • 92Interview Question: Fault Tolerance vs HA
  • 93Answer
  • 94Interview Question: How Do You Design for Partial Failure?
  • 95Interview Question: Why Are Retries Dangerous?
  • 96Interview Question: How Do You Handle a Database Failure?
  • 97Interview Question: How Do You Prevent Cascading Failures?
  • 98Mini Project
  • 99Design a Fault-Tolerant Payment Platform
  • 100Advanced Exercise
  • 101Production Fault-Tolerance Checklist
  • 102Master Mental Model
  • 103Summary
  • 104Exercises
  • 105Exercise 1
  • 106Exercise 2
  • 107Exercise 3
  • 108Exercise 4
  • 109Exercise 5
  • 110Exercise 6
  • 111Exercise 7
  • 112Next Chapter
  • 113Chapter 29 — Disaster Recovery
In this chapter (113 sections)
01Chapter Overview02Fault Tolerance vs High Availability03High Availability04Fault Tolerance05What Is a Fault?06Fault vs Error vs Failure07Fault08Error09Failure10Types of Failures11Crash Failure12Omission Failure13Timing Failure14Network Failure15Partial Failure16Example of Partial Failure17Failure Containment18Timeouts19Timeout Selection20Deadlines21Retries22Retry Storm23Exponential Backoff24Jitter25Idempotency26Circuit Breaker27Circuit Breaker Example28Bulkheads29Resource Isolation30Backpressure31Load Shedding32Graceful Degradation33Replication for Fault Tolerance34Redundancy Is Not Enough35Failure Domains36Self-Healing Systems37Self-Healing Risks38Retry vs Fail Fast39Retry Budget40Fallbacks41Stale Data as a Fault-Tolerance Tool42Queue-Based Fault Tolerance43Dead-Letter Queue44Poison Messages45Data Corruption46Backup vs Replication47Replication48Backup49Recovery Point Objective50Recovery Time Objective51Graceful Restart52Connection Draining53Fault Injection54Chaos Engineering55Chaos Engineering Principles56Failure Injection Examples57Application58Network59Database60Queue61Infrastructure62Fault Tolerance Testing63Failure Injection Matrix64Fault-Tolerant Payment Architecture65Fault-Tolerant Order Architecture66Fault-Tolerant API Architecture67Fault-Tolerant Distributed Storage68Anti-Entropy69Self-Healing Replication70Fault Tolerance and Capacity71Failure Budget72Fault-Tolerance Layers73Do Not Add Every Mechanism Everywhere74Observability for Fault Tolerance75Recovery Metrics76MTTR77Failover time78Recovery success rate79Retry amplification80Common Misconception #181Wrong82Common Misconception #283Wrong84Common Misconception #385Wrong86Common Misconception #487Wrong88Common Misconception #589Wrong90Common Misconception #691Wrong92Interview Question: Fault Tolerance vs HA93Answer94Interview Question: How Do You Design for Partial Failure?95Interview Question: Why Are Retries Dangerous?96Interview Question: How Do You Handle a Database Failure?97Interview Question: How Do You Prevent Cascading Failures?98Mini Project99Design a Fault-Tolerant Payment Platform100Advanced Exercise101Production Fault-Tolerance Checklist102Master Mental Model103Summary104Exercises105Exercise 1106Exercise 2107Exercise 3108Exercise 4109Exercise 5110Exercise 6111Exercise 7112Next Chapter113Chapter 29 — Disaster Recovery

1. Chapter Overview#

In the previous chapter, we learned High Availability.

High availability asks:

How do we keep the service available when components fail?

Fault tolerance goes one level deeper:

How should the system continue operating correctly when failures occur?

A fault-tolerant system assumes that failures are normal possibilities.

Examples:

Server crashes
Database becomes unavailable
Network packet is lost
Service becomes slow
Message is duplicated
Message arrives late
A dependency times out
A zone disappears
A process becomes unhealthy

The goal is not to pretend failures do not exist.

The goal is:

Failure
  ↓
Detection
  ↓
Isolation
  ↓
Fallback / Recovery
  ↓
Continue safely

2. Fault Tolerance vs High Availability#

These concepts overlap but are not identical.

High Availability#

Focuses on:

Keeping service available

Fault Tolerance#

Focuses on:

Continuing correct operation despite faults

A system can have multiple servers for availability but still behave incorrectly when one server becomes stale.

Therefore:

HA
+
Correct failure handling
+
Recovery
=
Strong fault-tolerant architecture

3. What Is a Fault?#

A fault is a problem in a component that can cause incorrect behavior.

Examples:

Hardware failure
Software bug
Network failure
Configuration error
Database failure
Human error
Dependency failure

A fault may produce a visible failure.


4. Fault vs Error vs Failure#

These terms are useful.

Fault#

The underlying problem.

Database process crashes

Error#

The incorrect internal state caused by the fault.

Application loses database connection

Failure#

The externally visible incorrect behavior.

User receives HTTP 500

Conceptually:

Fault
  ↓
Error
  ↓
Failure

Not every fault necessarily becomes a visible failure.


5. Types of Failures#

Distributed systems encounter many failure types:

  • crash failures
  • omission failures
  • timing failures
  • network failures
  • Byzantine failures
  • dependency failures
  • data corruption
  • resource exhaustion
  • software bugs

Understanding the type of failure helps determine the correct recovery mechanism.


6. Crash Failure#

A crash failure occurs when a process stops functioning.

Example:

Server A
   ↓
CRASH

The server no longer processes requests.

A basic recovery strategy:

Detect
  ↓
Remove from traffic
  ↓
Restart / replace

This is one of the easiest failure types to reason about.


7. Omission Failure#

An omission failure occurs when a system fails to send or receive something it should have.

Example:

A ───── message ─────► B
          X
      lost/dropped

The message never arrives.

This can occur due to:

  • network loss
  • buffer overflow
  • process failure
  • queue failure

Retries and acknowledgements can help, but retries introduce duplicate-processing risks.


8. Timing Failure#

A timing failure occurs when an operation happens outside the expected time bound.

Example:

Expected:
response < 200 ms
 
Actual:
response = 10 seconds

The service may technically be functioning, but from the application's perspective it failed its timing requirement.

Timeouts are therefore critical.


9. Network Failure#

Networks can:

  • drop packets
  • delay packets
  • reorder packets
  • duplicate packets
  • partition nodes
  • lose responses

This means distributed applications must never assume:

Request sent = request received

or:

Timeout = operation failed

10. Partial Failure#

Partial failure is one of the defining challenges of distributed systems.

A centralized application may fail:

Everything fails

A distributed system can fail partially:

Service A ✓
Service B ✓
Service C ✗
Service D ✓

The application must decide:

Continue?
Retry?
Fallback?
Degrade?
Reject?

This is much harder than handling total failure.


11. Example of Partial Failure#

Suppose:

Checkout
   │
   ├── Payment ✓
   ├── Inventory ✓
   ├── Recommendations ✗
   └── Analytics ✗

Should checkout fail?

If recommendations and analytics are non-critical:

Checkout → continue

This is fault isolation.


12. Failure Containment#

A key principle:

Prevent one component's failure from spreading to unrelated components.

Example:

Service A
   │
   X
Dependency fails
 
Without isolation:
A → B → C → entire system fails
 
With isolation:
A → fallback
B → unaffected
C → unaffected

Common mechanisms:

  • timeouts
  • circuit breakers
  • bulkheads
  • rate limits
  • queues
  • load shedding
  • bounded resource pools

13. Timeouts#

Never wait forever for a dependency.

Bad:

request
   ↓
wait indefinitely

Better:

request
   ↓
timeout
   ↓
fallback / retry / failure

Timeouts prevent a slow dependency from consuming resources indefinitely.


14. Timeout Selection#

Suppose a dependency normally responds in:

50 ms

with occasional:

150 ms

A timeout of:

1 second

may be reasonable for that operation.

But timeout selection should consider:

  • latency distribution
  • percentile targets
  • downstream capacity
  • user experience
  • retry budget
  • total request deadline

Do not blindly choose a timeout such as:

30 seconds

for every service.


15. Deadlines#

Instead of every service choosing its own independent timeout, propagate a request deadline.

Example:

User request
deadline = 2 seconds
 
Service A
remaining = 1.8 sec
 
Service B
remaining = 1.2 sec
 
Service C
remaining = 0.4 sec

This prevents downstream operations from continuing after the overall request can no longer succeed.


16. Retries#

Retries are useful for transient failures.

Example:

Request
  ↓
timeout
  ↓
retry
  ↓
success

But retries are dangerous when uncontrolled.


17. Retry Storm#

Suppose:

10,000 clients

all retry a failing service.

Traffic can become:

Original traffic
+
Retries
+
Retry retries

The dependency may become even more overloaded.

This is a feedback loop.


18. Exponential Backoff#

Instead of retrying immediately:

retry after:
1s
2s
4s
8s

This gives the dependency time to recover.


19. Jitter#

If every client waits exactly:

1 second

they may retry simultaneously.

Use randomness:

0.8s
1.1s
1.4s
0.9s

This spreads retry traffic over time.

A practical retry strategy often combines:

bounded retries
+
exponential backoff
+
jitter
+
deadline

20. Idempotency#

Retries can create duplicates.

Example:

POST /payment

First request:

Payment succeeds

Response is lost.

Client retries:

Payment succeeds again

Potentially:

₹1,000 charged twice

Use an idempotency key:

payment_request_id = abc123

The service records the result.

Retry:

abc123

returns the original result instead of creating another charge.


21. Circuit Breaker#

A circuit breaker prevents repeated calls to an unhealthy dependency.

States:

CLOSED
   │
   │ failures exceed threshold
   ▼
OPEN
   │
   │ wait
   ▼
HALF-OPEN
   │
   ├── success → CLOSED
   │
   └── failure → OPEN

This protects both sides.


22. Circuit Breaker Example#

Without circuit breaker:

Service A
   │
   ├──► B fails
   ├──► B fails
   ├──► B fails
   ├──► B fails
   └──► B fails

With circuit breaker:

A
│
├──► B fails
├──► B fails
│
└── circuit OPEN
        ↓
    fail fast

A can use a fallback instead.


23. Bulkheads#

Bulkheads isolate resources.

Suppose a service has:

100 worker threads

Dependency A consumes all 100.

Then requests to:

Dependency B

also fail.

Instead:

Pool A = 50
Pool B = 50

If A becomes unhealthy:

Pool A exhausted
Pool B still available

This limits blast radius.


24. Resource Isolation#

Bulkheads can isolate:

  • threads
  • connections
  • CPU
  • memory
  • queue capacity
  • worker pools
  • rate limits

Example:

Payment dependency → 30 connections
Search dependency  → 20 connections
Profile dependency → 20 connections
Other work         → 30 connections

One dependency cannot consume the entire connection pool.


25. Backpressure#

Backpressure prevents producers from overwhelming consumers.

Example:

Producer
  │
  ▼
Queue
  │
  ▼
Consumer

Producer:

10,000 events/sec

Consumer:

2,000 events/sec

Without controls:

Queue → grows indefinitely

With backpressure:

Throttle producer
or
shed lower-priority work

26. Load Shedding#

When the system reaches unsafe capacity:

Reject some work

rather than allowing:

Everything → fail

Example:

Critical checkout → accept
Recommendations → reject/defer
Analytics → delay

Load shedding is a deliberate availability strategy.


27. Graceful Degradation#

A system should define what happens when optional dependencies fail.

Example:

E-commerce
 
Payment       → critical
Inventory     → critical
Search        → important
Recommendations → optional
Reviews       → optional

If recommendations fail:

Use trending products

If reviews fail:

Hide reviews

The core purchase flow remains functional.


28. Replication for Fault Tolerance#

Replication creates redundant copies.

Example:

Primary
 /    \
R1    R2

If primary fails:

R1 / R2

can potentially provide recovery.

Replication strategies include:

  • synchronous
  • asynchronous
  • leader/follower
  • multi-leader
  • leaderless

Each has different consistency and failure characteristics.


29. Redundancy Is Not Enough#

Consider:

Server A ─┐
Server B ─┼── same availability zone
Server C ─┘

If the zone fails:

A ✗
B ✗
C ✗

All replicas are lost simultaneously.

Fault tolerance requires considering independent failure domains.


30. Failure Domains#

Typical hierarchy:

Process
  ↓
Server
  ↓
Rack
  ↓
Availability Zone
  ↓
Region
  ↓
Provider

A resilient architecture decides which levels it must survive.


31. Self-Healing Systems#

A self-healing system automatically responds to failures.

Example:

Instance crashes
     ↓
Health check detects failure
     ↓
Remove instance
     ↓
Launch replacement
     ↓
Register replacement
     ↓
Traffic resumes

This reduces MTTR.

But automation must be safe.


32. Self-Healing Risks#

Poor automation can create:

Failure
 ↓
Automatic restart
 ↓
Restart loop
 ↓
More resource consumption
 ↓
System overload

Therefore self-healing needs:

  • rate limits
  • restart limits
  • health checks
  • alerts
  • escalation
  • rollback mechanisms

33. Retry vs Fail Fast#

Use retries for:

Transient failure

Use fail-fast behavior for:

Permanent failure
Invalid request
Dependency clearly unavailable
Deadline exceeded

Example:

HTTP 400
→ do not retry
 
Temporary network timeout
→ retry may be appropriate

34. Retry Budget#

Retries consume capacity.

Suppose:

Normal traffic = 10,000 req/sec

If each request can retry 3 times, worst-case work can become much larger.

Therefore define:

Maximum retries
Maximum retry time
Maximum total request deadline

Retries should be part of capacity planning.


35. Fallbacks#

A fallback provides an alternate response when the preferred path fails.

Example:

Primary recommendation service
          ↓
       failure
          ↓
Trending products

Another example:

Live exchange rate
      ↓
failure
      ↓
recent cached rate

Fallbacks should be explicitly designed, not accidentally created.


36. Stale Data as a Fault-Tolerance Tool#

Sometimes stale data is better than no data.

Example:

Current product description unavailable
       ↓
Use cached description

This is useful when:

staleness is acceptable

It should not be used for data where stale values can cause serious harm.


37. Queue-Based Fault Tolerance#

Queues decouple producers and consumers.

Example:

API
 ↓
Queue
 ↓
Worker

If workers temporarily fail:

Messages remain queued

When workers recover:

Process backlog

This improves resilience for asynchronous workloads.


38. Dead-Letter Queue#

Some messages repeatedly fail.

Instead of retrying forever:

Queue
 ↓
retry
 ↓
retry
 ↓
retry
 ↓
DLQ

A Dead-Letter Queue allows operators to inspect problematic messages.


39. Poison Messages#

A poison message is a message that repeatedly causes processing failure.

Example:

Malformed payload

Retrying forever wastes resources.

Better:

attempt 1 → fail
attempt 2 → fail
attempt 3 → fail
       ↓
DLQ

Then investigate or repair the message.


40. Data Corruption#

Fault tolerance is not only about service availability.

Suppose:

Database value becomes corrupted

Replication can spread the corrupted value.

Therefore systems may need:

  • checksums
  • validation
  • backups
  • snapshots
  • point-in-time recovery
  • audit logs
  • immutable records

Replication and backup solve different problems.


41. Backup vs Replication#

Replication#

Provides additional copies for availability.

Primary → Replica

Backup#

Provides historical recovery.

Database
   ↓
Snapshot
   ↓
Historical copy

If bad data is replicated:

Primary corrupted
     ↓
Replica corrupted

A backup can provide an older clean state.


42. Recovery Point Objective#

Suppose backups run:

every 1 hour

A failure may cause up to approximately:

1 hour

of data loss depending on the backup and recovery design.

Therefore backup frequency influences RPO.


43. Recovery Time Objective#

Suppose recovery requires:

30 minutes

Then:

RTO ≈ 30 minutes

To reduce RTO, use:

  • automation
  • warm replicas
  • tested recovery procedures
  • infrastructure-as-code
  • pre-provisioned capacity

44. Graceful Restart#

A service should not simply terminate all active requests during deployment.

Instead:

Stop accepting new traffic
       ↓
Finish active requests
       ↓
Close connections
       ↓
Shutdown

This reduces user-visible failures.


45. Connection Draining#

During failover or deployment:

Load Balancer
    │
    X
Stop new requests

Existing requests are allowed to complete.

This is called connection draining.

It prevents sudden termination of active work.


46. Fault Injection#

Fault injection deliberately creates failures.

Examples:

Kill process
Add 500 ms latency
Drop packets
Fill disk
Exhaust connections
Return HTTP 500
Disconnect database

The goal is to test assumptions.


47. Chaos Engineering#

Chaos engineering is a structured approach to testing resilience.

Process:

Hypothesis
   ↓
Controlled experiment
   ↓
Inject failure
   ↓
Observe system
   ↓
Compare against expected behavior
   ↓
Improve

Example hypothesis:

If one application instance fails, user-facing availability remains within the SLO.


48. Chaos Engineering Principles#

A good experiment should:

  • have a clear hypothesis
  • have controlled scope
  • define abort conditions
  • monitor impact
  • start small
  • increase complexity gradually
  • document findings

Do not randomly destroy production systems without safeguards.


49. Failure Injection Examples#

Application#

Kill 1 instance

Network#

Add latency
Drop packets

Database#

Simulate connection failures

Queue#

Delay consumers

Infrastructure#

Remove an availability zone

Each tests a different failure assumption.


50. Fault Tolerance Testing#

A production resilience test might look like:

Scenario:
One app server fails
 
Expected:
Traffic moves to healthy instances
No significant user impact
SLO remains satisfied

Then:

Scenario:
Database primary fails
 
Expected:
Replica promotion
Connections reconnect
Writes resume

Then:

Scenario:
Payment service unavailable
 
Expected:
Checkout handles failure safely
No duplicate payment

51. Failure Injection Matrix#

Failure Detection Response
App crash Health check Replace instance
DB failure Connection/health monitoring Failover
Network timeout Timeout Retry/fallback
Dependency overload Metrics Circuit breaker
Queue backlog Queue depth Scale/throttle
Poison message Retry count DLQ
Region failure Global health Traffic failover
Data corruption Validation/monitoring Restore backup

52. Fault-Tolerant Payment Architecture#

Consider:

Client
  │
  ▼
Payment API
  │
  ├── Idempotency
  │
  ├── Durable transaction record
  │
  └── Payment Provider

Failure:

Payment provider timeout

Do not blindly retry the charge.

Instead:

Check idempotency key
        ↓
Query payment status
        ↓
Retry safely if necessary

This prevents duplicate charges.


53. Fault-Tolerant Order Architecture#

Order Service
     │
     ├── Order DB
     │
     └── Outbox
            │
            ▼
        Message Bus
        /        \
       ▼          ▼
 Inventory      Payment

Failures are handled with:

Retries
Idempotency
Saga
Compensation
DLQ
Reconciliation

54. Fault-Tolerant API Architecture#

A robust API layer may use:

Client
  ↓
Load Balancer
  ↓
API Servers
  ↓
Timeouts
  ↓
Circuit Breakers
  ↓
Dependencies

Add:

Rate limiting
Bulkheads
Caching
Fallbacks
Observability

55. Fault-Tolerant Distributed Storage#

A storage system may use:

Data
 │
 ├── Replica A
 ├── Replica B
 └── Replica C

With:

Quorum
Checksums
Versioning
Repair
Snapshots

If one replica fails:

Read from healthy replicas

Then repair:

Healthy state
    ↓
Replica repair
    ↓
Restored redundancy

56. Anti-Entropy#

Some replicated systems periodically compare replicas and repair differences.

Conceptually:

Replica A
   ↕
compare
   ↕
Replica B

Differences are detected and repaired.

This helps replicas converge after failures.


57. Self-Healing Replication#

A replicated storage system can follow:

Replica failure
      ↓
Detect
      ↓
Continue with remaining replicas
      ↓
Create replacement
      ↓
Copy missing data
      ↓
Restore redundancy

The system should also monitor:

repair progress

because a system with one remaining replica is more vulnerable to another failure.


58. Fault Tolerance and Capacity#

Suppose:

4 servers

each supports:

25,000 req/sec

Total:

100,000 req/sec

If one fails:

75,000 req/sec

If normal traffic is:

80,000 req/sec

the system is overloaded after a failure.

Therefore fault tolerance requires:

Enough spare capacity to continue operating under expected failures.


59. Failure Budget#

You can define expected failure assumptions:

Survive:
1 application server failure
1 cache node failure
1 availability zone failure

Then design capacity and redundancy accordingly.

This is more concrete than saying:

"Make it fault tolerant."

60. Fault-Tolerance Layers#

A useful layered model:

Application
   ↓
Timeouts
   ↓
Retries
   ↓
Circuit Breakers
   ↓
Queues
   ↓
Replication
   ↓
Failover
   ↓
Backups
   ↓
Disaster Recovery

Each layer protects against different failure classes.


61. Do Not Add Every Mechanism Everywhere#

More resilience mechanisms also create complexity.

For example:

Retry
+
Queue
+
Circuit breaker
+
Cache
+
Fallback
+
Replication

can create unexpected interactions.

A good design uses the smallest set of mechanisms needed to meet the reliability requirement.


62. Observability for Fault Tolerance#

You cannot operate a fault-tolerant system without visibility.

Monitor:

  • error rate
  • latency
  • timeouts
  • retry count
  • circuit state
  • queue depth
  • consumer lag
  • replication lag
  • failed health checks
  • failovers
  • recovery duration
  • resource saturation

63. Recovery Metrics#

Important metrics include:

MTTR#

Mean time to recovery.

Failover time#

Failure detected
     ↓
Traffic restored

Recovery success rate#

How often automated recovery succeeds.

Retry amplification#

How much additional traffic retries generate.

These metrics reveal whether resilience mechanisms are actually helping.


64. Common Misconception #1#

Wrong#

Fault tolerance means the system never fails.

No.

Fault tolerance means the system is designed to continue safely despite defined failures.


65. Common Misconception #2#

Wrong#

More retries make a system more reliable.

Not necessarily.

Excessive retries can create retry storms and make an outage worse.


66. Common Misconception #3#

Wrong#

Replication is the same as backup.

No.

Replication primarily supports availability and redundancy.

Backups provide historical recovery from corruption, deletion, or other failures.


67. Common Misconception #4#

Wrong#

A timeout means the operation failed.

No.

A timeout means the caller did not receive the expected response in time.

The operation may have succeeded.


68. Common Misconception #5#

Wrong#

Circuit breakers fix the failed dependency.

No.

They protect the caller and broader system from repeatedly depending on an unhealthy component.


69. Common Misconception #6#

Wrong#

Chaos engineering means randomly breaking production.

No.

Good chaos experiments are controlled, hypothesis-driven, observable, and bounded by safety mechanisms.


70. Interview Question: Fault Tolerance vs HA#

Answer#

High availability focuses on keeping a service accessible despite failures. Fault tolerance focuses more broadly on continuing correct operation when faults occur. HA is one important outcome of fault-tolerant design, but fault tolerance also includes safe handling of partial failures, retries, corruption, recovery, and failure isolation.


71. Interview Question: How Do You Design for Partial Failure?#

A strong answer includes:

Timeouts
Circuit breakers
Retries with backoff
Idempotency
Bulkheads
Fallbacks
Queues
Load shedding
Replication
Graceful degradation
Observability
Recovery

Then explain which mechanism protects which dependency.


72. Interview Question: Why Are Retries Dangerous?#

Because retries can amplify traffic during an outage.

For example:

Dependency slows
    ↓
Requests timeout
    ↓
Clients retry
    ↓
More traffic
    ↓
Dependency becomes slower
    ↓
More retries

This feedback loop can cause cascading failure.


73. Interview Question: How Do You Handle a Database Failure?#

Possible answer:

Detect failure
     ↓
Stop sending traffic
     ↓
Fail over according to DB architecture
     ↓
Reconnect clients
     ↓
Verify consistency
     ↓
Restore redundancy
     ↓
Monitor recovery

Then discuss:

  • synchronous/asynchronous replication
  • RPO
  • RTO
  • stale replicas
  • split brain
  • backups

74. Interview Question: How Do You Prevent Cascading Failures?#

Mention:

Timeouts
+
Circuit breakers
+
Bulkheads
+
Backpressure
+
Rate limiting
+
Load shedding
+
Bounded queues
+
Graceful degradation
+
Retry limits

75. Mini Project#

Design a Fault-Tolerant Payment Platform#

Requirements:

  • Multiple API servers
  • Payment provider can become unavailable
  • Requests can timeout
  • Duplicate requests can occur
  • Database can fail
  • Network partitions can happen
  • Users must not be double-charged
  • Payment state must be recoverable

Design:

                  Client
                    │
                    ▼
                Load Balancer
                    │
              ┌─────┴─────┐
              ▼           ▼
          Payment A    Payment B
              │           │
              └─────┬─────┘
                    │
                Payment DB
                    │
                Outbox/Events
                    │
                    ▼
              Payment Provider

Include:

Idempotency
Timeouts
Retries
Status reconciliation
Circuit breaker
Database failover
Audit log
Backups
Monitoring

76. Advanced Exercise#

Suppose:

Payment provider latency:
normal = 100 ms
degraded = 10 seconds

Your API timeout is:

2 seconds

Questions:

  1. What happens after 2 seconds?
  2. Should the payment be retried?
  3. How do you determine whether the original payment succeeded?
  4. How do you prevent duplicate charging?
  5. When should the circuit breaker open?
  6. What status should the user see?
  7. How can reconciliation recover unknown outcomes?

A strong solution should identify the distinction between:

FAILURE
vs
UNKNOWN OUTCOME

77. Production Fault-Tolerance Checklist#

Before production, verify:

  • Failure modes are documented.
  • Timeouts exist.
  • Deadlines are propagated where appropriate.
  • Retries are bounded.
  • Exponential backoff is used.
  • Jitter is used.
  • Retryable operations are idempotent.
  • Circuit breakers protect unstable dependencies.
  • Bulkheads isolate resource pools.
  • Backpressure exists.
  • Load shedding protects critical operations.
  • Fallbacks are defined.
  • Replication is configured.
  • Failure domains are separated.
  • Backups are tested.
  • RPO is defined.
  • RTO is defined.
  • Recovery procedures are automated where appropriate.
  • DLQs handle poison messages.
  • Reconciliation exists for uncertain workflows.
  • Observability covers failure behavior.
  • Fault injection has been performed.
  • Disaster recovery has been tested.

78. Master Mental Model#

Remember fault tolerance as:

                  FAILURE
                     │
                     ▼
                  DETECT
                     │
          ┌──────────┴──────────┐
          │                     │
       TRANSIENT             PERMANENT
          │                     │
       RETRY                  FAIL FAST
       BACKOFF                FALLBACK
          │                     │
          └──────────┬──────────┘
                     ▼
                  ISOLATE
                     │
          ┌──────────┼──────────┐
          │          │          │
       Circuit     Bulkhead   Load Shed
       Breaker
          │
          ▼
                 RECOVER
                     │
          ┌──────────┼──────────┐
          │          │          │
       Failover   Replay     Reconcile
          │
          ▼
                RESTORE
                REDUNDANCY

The core principle:

A fault-tolerant system does not merely detect failure; it prevents failure from propagating, preserves correctness where required, and restores normal capacity safely.


79. Summary#

You learned:

  • Fault tolerance
  • HA vs fault tolerance
  • Fault / error / failure
  • Crash failures
  • Omission failures
  • Timing failures
  • Network failures
  • Partial failure
  • Failure containment
  • Timeouts
  • Deadlines
  • Retries
  • Exponential backoff
  • Jitter
  • Idempotency
  • Circuit breakers
  • Bulkheads
  • Backpressure
  • Load shedding
  • Graceful degradation
  • Replication
  • Failure domains
  • Self-healing
  • Fallbacks
  • Queues
  • Dead-letter queues
  • Poison messages
  • Data corruption
  • Backup vs replication
  • RPO / RTO
  • Connection draining
  • Fault injection
  • Chaos engineering
  • Anti-entropy
  • Recovery
  • Capacity planning
  • Observability
  • Failure budgets
  • Fault-tolerant payment architecture
  • Interview questions
  • Production checklist

The most important takeaway:

Distributed systems must be designed around partial failure. Assume that components will fail independently, responses can be lost, messages can be duplicated, and networks can become unreliable. Then explicitly design detection, isolation, fallback, recovery, and reconciliation.


80. Exercises#

Exercise 1#

Explain:

Fault
Error
Failure

with a database example.

Exercise 2#

Explain why retries can make an outage worse.

Exercise 3#

Design a circuit breaker for a payment service.

Exercise 4#

Design bulkheads for:

Payment
Search
Recommendations

Exercise 5#

Explain:

Replication vs Backup

Exercise 6#

Design fault tolerance for a message-processing system.

Include:

  • retries
  • DLQ
  • idempotency
  • deduplication

Exercise 7#

Explain why a timeout does not necessarily mean an operation failed.


81. Next Chapter#

Chapter 29 — Disaster Recovery#

Next we will move from component-level fault tolerance to large-scale disaster recovery.

We will cover:

  • Disaster recovery fundamentals
  • Disaster types
  • Regional outages
  • Data-center failures
  • Data corruption
  • Backup strategies
  • Full vs incremental backups
  • Snapshots
  • Point-in-time recovery
  • RPO
  • RTO
  • Backup retention
  • Restore testing
  • Cold / warm / hot standby
  • Active-passive DR
  • Active-active DR
  • Cross-region replication
  • DNS and global traffic failover
  • Disaster recovery runbooks
  • Business continuity
  • Disaster recovery testing
  • Recovery exercises
  • Real-world DR architecture
  • Interview questions
  • DR design exercise

Finished this chapter?

Mark it as complete to track your mastery.

Previous ChapterChapter 27 — High AvailabilityNext ChapterChapter 29 — Disaster Recovery
PrevNext