SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
  • Scalability
  • Availability
  • Reliability
  • Single Point of Failure (SPOF)
  • Latency vs Throughput vs Bandwidth
  • Consistent Hashing
  • CAP Theorem
  • Fault Tolerance and Redundancy
  • Failover
  • Stateless vs Stateful
  • Concurrency vs Parallelism
  • Capacity Planning
  • Back Pressure
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Foundations/Core Concepts

Fault Tolerance and Redundancy

Keep working when parts break, by having spare copies of everything important.

⏱ 13 min readBeginnerMust KnowInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

Fault tolerance means a system keeps working even when some of its parts break. Redundancy is the main way to get it: keep spare copies of the important parts.

  • Things will fail: disks, servers, networks, even whole data centres. The question is what happens next.
  • With a spare ready, a failure becomes a small event instead of an outage.
  • Spares only help if they do not fail together. Put them in different racks, zones or regions.
  • Every spare costs money and adds complexity, so protect what matters most.

02Concept: What is it?

A fault is when something breaks. A failure is when users notice. A fault-tolerant system has fewer failures than faults, because it hides faults from users.

Redundancy means having more than you need: two servers when one is enough, three copies of the data, two network links. If one fails, another carries on.

One path vs two paths
No redundancy
πŸ“¨Request
→↓
πŸ’₯Serverfailed
With redundancy
πŸ“¨Request
→↓
πŸ’₯Server Afailed
πŸ“¨Retry
→↓
πŸ–₯️Server Banswers
With one path, one break stops everything. With two, the second one carries the load.

The maths of copies

If one copy is up 99% of the time, the chance that both of two independent copies are down at once is 1% Γ— 1% = 0.01%. So two copies give 99.99%. Three copies give 99.9999%. This is why redundancy is so powerful.

🧠The catch: independence
The maths only works if the copies fail separately. Two servers on the same power strip, in the same rack, or running the same buggy code fail together. Always ask: β€œwhat do these copies share?”

03Real-Life Example

🍡The spare tyre and the hospital generator
A car has a spare tyre. A flat tyre is a fault, but you change it and keep driving, so the trip does not fail. A hospital has a backup generator. When the city power fails, the generator starts and operations continue. Both have a spare ready before the failure. But if the spare tyre is also flat, or the generator was never tested, the spare did not help. That is why spares must be kept healthy and checked.
Spare tyre / generator
Software system
Flat tyre or power cut
A fault: a disk, server or network breaks
Spare tyre in the boot
A standby server or a copy of the data
Changing the tyre
Failover to the spare
Checking the spare’s pressure
Health checks and testing the backups
Spare stored in the same flooded garage
Copies in the same zone fail together
Generator tested every month
Regular failure drills

04Why Do We Need It?

πŸ”ŒEverything fails
At large scale, disks and servers fail every day. You must plan for it, not hope.
⏱️High availability
Redundancy is the main way to reach 99.9% and above.
πŸ’ΎNo data loss
Copies of data mean one lost disk does not mean lost customers’ data.
πŸ› οΈEasier maintenance
You can update or repair one copy while others serve users.
🌍Disaster recovery
Copies in another region survive a fire, flood or provider outage.
🀝Trust
Users do not notice a failure that you handled quietly.
You cannot stop parts from breaking. You can make sure that one broken part is not the end of the service.

05Where Do We Use It?

πŸ–₯️App servers
Run several copies behind a load balancer. A dead one is removed from rotation.
πŸ—„οΈDatabases
Replicas keep copies of the data and can take over if the primary fails.
πŸ’½Storage
RAID, replication and erasure coding survive disk failures.
🌐Network
Two links, two routers and two providers, so one cut cable is not the end.
⚑Power and cooling
Data centres use two power feeds, batteries and generators.
πŸ—ΊοΈRegions and zones
Cloud providers offer separate zones and regions to keep copies far apart.

06Types / Parts / How It Works

Kinds of redundancy

KindWhat is duplicatedExample
HardwareMachines, disks, power, network linksTwo power supplies, RAID disks
Software / serviceRunning copies of a serviceFive app servers behind a load balancer
DataCopies of stored dataDatabase replicas, object storage copies
GeographicWhole sites in different placesA second region with its own copy
Time (retry)Trying the same thing againRetry a failed request on another server
InformationExtra data to rebuild lost dataParity, checksums, erasure coding

Standby styles

StyleHow it worksGood and bad
Active-activeAll copies serve traffic at the same timeNo wasted capacity, fast recovery. But you need the capacity and sync to cope when one is lost.
Active-passiveOne copy serves, a standby waitsSimple. The standby may be idle (wasteful) and take time to start.
N+1N copies are needed, plus one spareA cheap way to survive one failure
N+M / 2NMore spares, up to a full duplicateSurvives more failures, but costs much more

Failure domains: keep copies apart

Spread copies across failure domains
Zone 1
πŸ–₯️Copy 1
πŸ—„οΈData 1
Zone 2
πŸ–₯️Copy 2
πŸ—„οΈData 2
Zone 3
πŸ–₯️Copy 3
πŸ—„οΈData 3
Zone 1 Zone 2 Zone 3
A failure domain is a set of things that can fail together. Copies should live in different ones.
Chance of being down at the same time
1 copy1% down
2 copies0.01% down
3 copies0.0001% down
Illustrative: copies that each fail 1% of the time, and fail independently.
VisualizerHow many copies, and where do they run?Raise the number of copies and watch downtime fall. Then keep every copy in one zone and raise the zone failure chance: the extra copies stop helping. Spread them over three zones to get the benefit back.
Where do the copies run?
3 copies in 1 zone (each box is a zone, each square is a copy)
Zone 1
Downtime per month for 1 to 6 copies (bars are relative to the biggest bar)
1 copy
10.8 hours
2 copies
3.7 hours
3 copies
3.6 hours
4 copies
3.6 hours
5 copies
3.6 hours
6 copies
3.6 hours
One copy
98.5050%
no redundancy
Ideal (independent)
99.9999%
1 βˆ’ (1 βˆ’ a)^3
Real
99.4999%
with the zone risk
Down per month
3.6 hours
ideal 2.6 sec
All 3 copies sit in one zone. If independent, downtime would be about 2.6 sec a month, but the real figure is 3.6 hours, 5001 times worse. When the zone fails, every copy fails with it, so extra copies stop helping.

Model: the service is up if at least one copy works. A whole zone fails with the chance you set, and inside a working zone each copy fails alone. It assumes failover is perfect and instant, which real systems only approach. The default numbers are made up for teaching (illustrative).

07How to Use It / Steps / Implementation

Building fault tolerance step by step

  1. 1
    List what can fail
    Go through the request path: a server, a disk, a database, a network link, a dependency, even a deploy. Mark the ones with no spare (single points of failure).
  2. 2
    Decide how much you need
    Use your availability target. 99.9% may need two copies. 99.99% usually needs several copies in different zones, plus automatic failover.
  3. 3
    Add copies and spread them
    Run at least two of everything critical, in different racks and zones, so they do not share a failure.
  4. 4
    Detect failure quickly
    Use health checks and heartbeats. A spare is useless if nobody notices the main one died.
  5. 5
    Switch over automatically
    Use a load balancer or failover tool to move traffic. Human reaction at 3 a.m. is slow.
  6. 6
    Make the work safe to repeat
    Retries and replays must not cause damage. Use idempotent operations.
  7. 7
    Test the spares
    Practise failure on purpose: stop a server, cut a link, fail over a database. A backup that was never tested is a hope, not a plan.
πŸ’‘Plan for the loss of a whole zone
If you have three zones, make sure two of them can carry all the traffic. Otherwise losing one zone moves the overload onto the others, and they fail too.
⚠️Do not let the fix create the failure
Retries from many clients can pile onto a service that is already struggling. Use limits, backoff and circuit breakers.

08Key Terms to Know

TermMeaning in easy words
FaultSomething breaks, such as a disk or a process
FailureThe system stops giving correct service to users
Fault toleranceThe ability to keep working correctly when parts fault
RedundancyExtra copies or capacity that are not needed when everything works
Single point of failureA part with no backup. If it fails, everything stops.
Failure domainA group of things that can fail together, such as a rack, a zone or a region
FailoverMoving work from a failed part to a spare
Active-activeAll copies serve traffic at the same time
Active-passiveOne copy serves while another waits as a standby
N+1Enough for the load, plus one spare
Graceful degradationKeep the most important features working when something is broken

09Pros, Cons and Trade-offs

βœ… Pros
  • Much higher availability
  • A single failure is no longer an outage
  • Safer data
  • Maintenance without downtime
  • Survives bigger disasters when spread out
⚠️ Cons
  • Costs more hardware and money
  • More parts to run and keep in sync
  • Copies in the same domain give a false feeling of safety
  • Failover code itself can have bugs
  • Untested spares may not work when needed

Trade-offs

ChoiceWe gainWe lose
More copiesHigher availabilityHigher cost and more to keep in sync
Copies far apart (regions)Survive big disastersHigher latency and harder data sync
Copies close together (one rack)Fast and cheapThey fail together
Active-activeUse all capacity, fast recoveryHarder to build, needs spare room for the survivors
Active-passiveSimpleIdle spare and slower failover
Automatic failoverFast recoveryA risk of wrong switches (for example split brain)

10Common Problems and Mistakes

Common mistakes

  1. Copies that fail together. Two servers in the same rack, on the same power, or on the same release can all go down at once.
  2. Untested failover. The first real failure is also the first test, and it does not work.
  3. No spare capacity. When one copy dies, the others receive its load and also overload.
  4. Hidden single points. The load balancer, the DNS, the config store or the one database behind a redundant web tier.
  5. Bad software on every copy. A bug or bad config on all copies is a common-mode failure. Roll out changes slowly.
  6. Stale standby. A standby with old data or old code cannot take over correctly.
  7. Retry storms. Clients retrying together can crush a recovering service.

Things to watch

πŸ”—Common-mode failures
One cause hits all copies: a bad deploy, an expired certificate, a full disk, a shared dependency.
🧠Split brain
A wrong failover leaves two parts both acting as the leader.
🐒Slow failures
A copy that is slow but not dead is harder than one that is clearly dead. Use timeouts.
πŸ“‰Silent loss of redundancy
A failed copy that nobody replaces. You are now running with no spare. Alert on it.

11Real-World Examples

☁️Cloud zones
Cloud providers let you run copies across several zones in a region, so one data-centre problem does not take you down.
πŸ—„οΈDatabase replicas
A primary with replicas lets a database survive the loss of a machine. Managed databases often automate the switch.
πŸ“¦Object storage
Large object stores keep several copies or coded pieces of each object across devices and sites.
πŸ’Chaos testing
Some companies stop machines on purpose, in controlled ways, to prove that the system still works.
✈️Aircraft
Planes carry duplicate or triple systems for critical controls, a classic example outside software.
πŸ’ΎRAID
Disk arrays keep extra data so that a failed disk can be rebuilt.
πŸ“Note
Exact guarantees depend on the product, the plan and the configuration. Read what your provider and database actually promise.
Mini case: a web tier and a database
🌐Load balancer pair
→↓3 zones
πŸ–₯️App servers x3
→↓
πŸ—„οΈPrimary + replicas
Every layer has a spare, so one machine or zone can fail without an outage.

12Related Topics to Read Next

Single Point of Failure (SPOF)β†’

The thing redundancy removes.

Failover→

How traffic moves to the spare.

Availability→

The number redundancy helps you reach.

Replication→

How data copies are kept.

Health Checks→

How a failed copy is noticed.

Handling Failures→

Retries, timeouts and fallbacks for when things break.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • βœ”Fault tolerance: keep working when parts break.
  • βœ”Redundancy: spare copies of servers, data and links.
  • βœ”Maths: independent copies, down only if all are down. Availability = 1 βˆ’ (1 βˆ’ a)^N.
  • βœ”Catch: copies must fail independently. Spread them over racks, zones and regions.
  • βœ”Styles: active-active, active-passive, N+1.
  • βœ”Must have: health checks, automatic failover and spare capacity.
  • βœ”Test it: an untested backup is only a hope.
  • βœ”One line: β€œHave a spare, keep it away from the main one, and prove it works.”
← Previous
CAP Theorem
Next β†’
Failover