Skip to content
intermediatePhase 43 · System Design Foundations

Reliability

Design systems that perform correctly under various conditions.

45m
0 problems
Topic Progress0%

Reliability Metrics

Reliability is the probability that a system will perform its intended function without failure over a specified period.

Key Metrics

MTBF (Mean Time Between Failures)
= Total Uptime / Number of Failures

MTTR (Mean Time To Repair)
= Total Repair Time / Number of Repairs

Availability = MTBF / (MTBF + MTTR)

Example Calculation

System Uptime: 364 days
Number of Failures: 4
Total Repair Time: 2 hours (0.083 days)

MTBF = 364 / 4 = 91 days between failures
MTTR = 2 / 4 = 0.5 hours per repair

Availability = 91 / (91 + 0.000057) = 99.99994%

Reliability vs Availability

Aspect Reliability Availability
Focus Correct operation Uptime
Metric MTBF, failure rate Uptime percentage
Question Does it work correctly? Is it accessible?
Example Data never corrupted System always reachable

Reliability Metrics by System Type

System MTBF Target MTTR Target
Web App 30 days 1 hour
Database 90 days 30 minutes
Financial 365 days 5 minutes
Medical 1000+ days Immediate

Failure Rate

Failure Rate = Number of Failures / Total Operating Time

Example:
1000 hours of operation, 5 failures
Failure Rate = 5 / 1000 = 0.005 failures/hour

Annual Failure Rate = 0.005 × 8760 = 43.8 failures/year

Reliability Engineering Principles

  1. Redundancy: Backup components
  2. Isolation: Failure containment
  3. Graceful Degradation: Reduce functionality under failure
  4. Self-healing: Automatic recovery
  5. Observability: Monitor and alert

Fault Tolerance

Fault tolerance is the ability of a system to continue operating despite component failures.

Fault Tolerance Patterns

Fault Tolerance
├── Redundancy
│   ├── Active-Active
│   ├── Active-Passive
│   └── N+1 Redundancy
├── Replication
│   ├── Synchronous
│   └── Asynchronous
├── Circuit Breaker
│   ├── Closed (normal)
│   ├── Open (failing)
│   └── Half-Open (testing)
└── Bulkhead
    ├── Separate pools
    └── Isolated failures

Circuit Breaker Pattern

Normal Flow (Closed):
Request → [Circuit Breaker] → Service → Response
                │
                └── Success counter

When failures exceed threshold:
Request → [Circuit Breaker] → ❌ Fail Fast
                │
                └── Open state (no requests to service)

After timeout:
Request → [Circuit Breaker] → Service → Response
                │
                └── Half-Open (test if service recovered)

Bulkhead Pattern

Without Bulkhead:          With Bulkhead:
┌─────────────────┐       ┌─────────────────┐
│   Shared Pool   │       │  Pool A  │ Pool B│
│   (all services)│       │ Service A│ Svc B│
└────────┬────────┘       └────┬─────┴──┬───┘
         │                     │        │
    Service A fails       Svc A fails  Svc B ok
    → Pool exhausted      → Pool A exhausted
    → All services down   → Pool B still works

Graceful Degradation

Full Functionality:
┌─────────────────────────────────┐
│  Full features, all data,      │
│  real-time updates             │
└─────────────────────────────────┘

Degraded Mode (failure):         
┌─────────────────────────────────┐
│  Core features, cached data,   │
│  delayed updates               │
└─────────────────────────────────┘

Minimal Mode (severe failure):   
┌─────────────────────────────────┐
│  Basic read-only access,       │
│  static content only           │
└─────────────────────────────────┘

Fault Tolerance in Practice

Service Fault Tolerance Strategy
Netflix Multiple CDNs, regional failover
Google Geographic redundancy, cell-based architecture
Amazon Microservices isolation, circuit breakers
Stripe Idempotent requests, retry with backoff

Redundancy for Reliability

Redundancy is the foundation of reliable systems. It ensures no single failure causes total system failure.

Levels of Redundancy

Level 1: Component Redundancy
├── Dual power supplies
├── RAID storage
└── Multiple network cards

Level 2: Server Redundancy
├── Active-Active pairs
├── Load balanced clusters
└── Standby replicas

Level 3: Data Redundancy
├── Database replication
├── Cross-region backup
└── Distributed storage

Level 4: Geographic Redundancy
├── Multiple data centers
├── Multi-region deployment
└── CDN distribution

Replication Strategies

Synchronous Replication:
Primary ──── Write ────→ Replica (confirm)
   │                      │
   └── Commit only after replica confirms

Asynchronous Replication:
Primary ──── Write ────→ Replica (fire & forget)
   │                      │
   └── Commit immediately, replica catches up

Semi-synchronous:
Primary ──── Write ────→ At least 1 replica confirms
   │                      │
   └── Commit after 1 replica confirms

Consensus Algorithms

Raft/Paxos:
- Leader election
- Log replication
- Safety guarantees
- Used in: etcd, Consul, ZooKeeper

Quorum:
- Write: W nodes must acknowledge
- Read: R nodes must respond
- W + R > N ensures consistency

Redundancy Tradeoffs

Factor No Redundancy Some Redundancy Full Redundancy
Cost Low Medium High
Complexity Low Medium High
Reliability Low Medium High
Consistency Strong Varies Eventual

Best Practices

  1. Automate failover: Don't rely on manual intervention
  2. Test redundancy: Regularly simulate failures
  3. Monitor replication lag: Ensure replicas are current
  4. Use quorum: Balance consistency and availability
  5. Document recovery procedures: Know how to recover from each failure

Practice Problems

0/3solved
Design Reliability System

Design a scalable Reliability system. Cover high-level architecture, data model, and API design.

Solution
// Complete system design:
// - Functional + Non-functional requirements
// - Capacity estimation
// - Data model (SQL/NoSQL choice)
// - API endpoints
// - Component architecture
// - Scaling strategy
// - Monitoring & reliability
Reliability Scaling

How would you scale Reliability to handle 10x the current load? Identify bottlenecks and solutions.

Solution
// Scaling approach:
// 1. Load balancing
// 2. Database sharding/replication
// 3. Cache layer (Redis)
// 4. CDN for static assets
// 5. Async processing (queues)
// 6. Microservices decomposition
Reliability Failure Modes

Analyze potential failure modes for Reliability and design mitigation strategies.

Solution
// Failure mitigation:
// 1. Redundancy (multi-AZ)
// 2. Circuit breakers
// 3. Retry with backoff
// 4. Dead letter queues
// 5. Health checks
// 6. Graceful degradation

Quiz

1. What is MTBF?

Question 1 options

2. What is the circuit breaker pattern?

Question 2 options

3. What is the difference between reliability and availability?

Question 3 options

4. What is graceful degradation?

Question 4 options

Flashcards

Question

What is MTBF and how is it calculated?

Answer

MTBF (Mean Time Between Failures) = Total Uptime / Number of Failures. It measures average time between system failures.

Question

What is the circuit breaker pattern?

Answer

A pattern that stops sending requests to a failing service to prevent cascading failures. It has three states: Closed (normal), Open (failing), Half-Open (testing recovery).

Question

What is the bulkhead pattern?

Answer

A pattern that isolates components into separate pools so failure in one doesn't affect others. Like bulkheads on a ship preventing water from flooding the entire vessel.

Question

What are the levels of redundancy?

Answer

Level 1: Component (dual power supplies), Level 2: Server (active-active pairs), Level 3: Data (replication), Level 4: Geographic (multiple data centers).

Question

What is Reliability?

Answer

Reliability is a key concept in system design.

Revision Notes

Key Takeaways

  • 1.Reliability is about correct operation, not just uptime
  • 2.MTBF and MTTR are key reliability metrics
  • 3.Circuit breaker and bulkhead patterns prevent cascading failures
  • 4.Redundancy at multiple levels ensures no single point of failure
  • 5.Test redundancy regularly - don't assume it works

Interview Tips

  • Discuss MTBF and MTTR targets when talking about reliability
  • Mention circuit breaker pattern for microservices architectures
  • Always consider what happens when each component fails
  • Discuss tradeoffs between synchronous and asynchronous replication

Cheat Sheet

Reliability - Cheat Sheet

Key Metrics:

  • MTBF = Total Uptime / Number of Failures
  • MTTR = Total Repair Time / Number of Repairs
  • Availability = MTBF / (MTBF + MTTR)

Fault Tolerance Patterns:

  1. Circuit Breaker: Stop requests to failing service
  2. Bulkhead: Isolate components into pools
  3. Graceful Degradation: Reduce functionality under failure

Redundancy Levels:

  1. Component: Dual power, RAID
  2. Server: Active-Active, Active-Passive
  3. Data: Replication (sync/async)
  4. Geographic: Multiple data centers

Replication Types:

  • Synchronous: Strong consistency
  • Asynchronous: Better performance
  • Semi-synchronous: Balance of both