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

Reliability

Giving the right answer, every time, even when parts fail.

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

01Quick Summary

Reliability means a system does what it should, correctly, and keeps doing it over time, even when some parts fail.

  • A reliable system gives the right answer, not just an answer.
  • Parts will fail. Reliable systems are built to handle that.
  • Tools: redundancy, retries, timeouts, backups, testing and monitoring.
  • Available is not the same as reliable. A system can be up and still give wrong answers.

02Concept: What is it?

Reliability is the chance that a system works correctly for a given time. We design for fault tolerance: the system keeps working even when a part breaks.

Fault, error, failure

Three different words
πŸ”©Faulta part goes wrong (disk breaks)
→↓if not handled
⚠️Errorwrong state inside
→↓if it reaches the user
πŸ’₯Failureuser sees a problem
🧠The goal
We cannot stop all faults. We design so that a fault does not become a failure.

Reliability vs availability

Available
β€œIs it up?”
  • Measured as % of time up
  • A server that answers wrongly is still β€œup”
  • Fixed by redundancy and failover
Reliable
β€œCan I trust it?”
  • Right results, with no data loss
  • Works over a long time
  • Needs redundancy plus correctness, testing and backups

03Real-Life Example

🍡The train and the clock
A train always runs, but it arrives at the wrong station half the time. It is available but not reliable. Another train sometimes stops for an hour but always reaches the right station with your bag. Which one would you trust? Reliability is about trust.
Up but not reliable
Available, not reliable
πŸ’³Bank app is up
↓
🧾Shows wrong balance
Reliable
πŸ’³Bank app is up
↓
🧾Shows right balance
Train journey
Software system
Spare engine ready
Redundancy
Try another track if blocked
Retry and failover
Bag always reaches you
No data loss
Safety checks before leaving
Testing and monitoring

04Why Do We Need It?

Parts fail all the time. At large scale, something is failing somewhere every day.

🧾Right data
A wrong balance or a lost order breaks trust fast.
πŸ’ΎNo data loss
Lost photos, messages or payments cannot be undone.
😌Calm users
Users forgive slowness more than wrong results.
πŸ›‘οΈSafe systems
Health, money and travel systems must be right.
If you cannot trust the answer, speed and uptime do not matter.

05Where Do We Use It?

πŸ’³Payments
No money lost or taken twice.
🏦Banking
Balances must always be right.
πŸ₯Healthcare
Records and doses must be correct.
✈️Travel booking
One seat must not be sold to two people.
πŸ’¬Messaging
Messages must not vanish or repeat.
πŸ“¦Cloud storage
Your files must still be there tomorrow.

06Types / Parts / How It Works

Ways to build reliability

Layers of protection
πŸ‘―Redundancyspare copies
πŸ”Retriestry again for glitches
⏱️Timeoutsdo not wait forever
πŸ’ΎBackupsrestore after disaster
πŸ§ͺTestingfind bugs early
πŸ“ŸMonitoringspot trouble fast

Common kinds of faults

KindExampleProtection
HardwareDisk dies, power cut, bad network cableRedundancy, RAID, many data centres
SoftwareA bug, memory leak, bad releaseTesting, code review, safe rollouts
HumanSomeone deletes the wrong tableBackups, permissions, approvals
NetworkSlow or lost messagesRetries, timeouts
OverloadToo many requests at onceRate limiting, queues, scaling

Retry, but safely

Retrying a request that failed is a good idea for random glitches. But there are two rules.

⏳Wait longer each time
1 sec, then 2, then 4 (backoff). Add a little random delay (jitter), so all clients do not retry together.
πŸ”‚Make requests idempotent
Doing it twice should equal doing it once. Then a retried payment is not charged twice.
VisualizerDoes the request survive a failure?Pick a kind of failure and a protection, then send 20 requests.
What goes wrong?
Protection
πŸ“±Client
→↓one try
πŸ–₯️Main serverfails 30%
Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·
Expected to work
70.0%
by maths
This run
-
worked
One try, and a glitch means a failed request. Click Send to see it.

07How to Use It / Steps / Implementation

  1. 1
    List what can fail
    Disks, servers, networks, other services, people.
  2. 2
    Remove single points of failure
    Run copies of important parts.
  3. 3
    Add timeouts
    A slow service must not hold everyone up.
  4. 4
    Add retries with backoff
    For short glitches. Make the call idempotent.
  5. 5
    Protect data
    Replicate it and take backups. Test a restore.
  6. 6
    Degrade gracefully
    If recommendations fail, still show the main page.
  7. 7
    Test failures on purpose
    Turn a server off in a test and see what happens.
  8. 8
    Monitor and alert
    Know about the problem before users tell you.
A request that handles a failure
  1. 1
    Client sends a request
  2. 2
    Server A does not answer (timeout)
    We do not wait forever
  3. 3
    Retry after a short wait
    Backoff + jitter
  4. 4
    Request goes to Server B
    Failover
  5. βœ“
    Correct answer returned
    User never saw the fault

08Key Terms to Know

TermMeaning in easy words
FaultOne part of the system goes wrong
FailureThe whole system stops giving the service users expect
Fault toleranceWorking correctly even when parts fail
RedundancyExtra copies of parts to cover for failures
DurabilitySaved data stays saved, even after crashes
IdempotentDoing the same request many times has the same result as once
TimeoutA limit on how long we wait for a reply
RetryTrying a failed request again
BackoffWaiting longer between each retry
Graceful degradationLosing a small feature but keeping the main service working
Chaos testingBreaking things on purpose to find weak spots

09Pros, Cons and Trade-offs

βœ… Pros
  • Users trust the system
  • No lost or wrong data
  • Small faults stay small
  • Fewer night-time emergencies
⚠️ Cons
  • More cost: copies, backups, monitoring
  • More complex code (retries, idempotency)
  • Slower writes when data is copied safely
  • Hard to test every failure

Trade-offs

ChoiceWe gainWe lose
More retriesSurvive glitchesMore load when the service is already struggling
Longer timeoutsFewer false failuresUsers wait longer
Writing to several copies before replyingSafer dataSlower writes
Frequent backupsLess data lost in a disasterMore storage and cost

10Common Problems and Mistakes

Common mistakes

  1. Retrying without limit. Endless retries can crush a service that is already down. This is a β€œretry storm”.
  2. Retrying a non-idempotent call. The customer may be charged twice.
  3. No timeouts. One slow service makes everything wait.
  4. Backups never tested. You only know a backup works when you restore it.
  5. Assuming the network is perfect. It is slow and lossy sometimes.
  6. Mixing up reliability and availability. Up does not mean correct.

Problems that appear at scale

🌩️Retry storm
Everyone retries at once and makes the overload worse.
⛓️Cascading failure
One failed part overloads the next, and so on.
πŸ•³οΈSilent data loss
Data is lost and nobody notices until much later.
πŸ’‘Circuit breaker
If a service keeps failing, stop calling it for a short time (open the β€œcircuit”). Let it recover, then try a few calls again. This protects both sides.

11Real-World Examples

These are general ideas. The exact methods inside each company are more complex.

πŸ’³Payment apps
Use unique request IDs, so a retried payment is not taken twice.
πŸ“¦Cloud storage
Keep several copies of each file, in different places, so one disk failure loses nothing.
🎬Streaming apps
If recommendations are down, the app still plays your video (graceful degradation).
πŸ§ͺChaos testing
Some companies turn off servers on purpose to check that the system survives.
Graceful degradation
πŸ‘€User opens the app
→↓
🎬Play videoworks
→↓also loads
⭐Recommendationsfailed: hidden
πŸ’¬Commentsworks
Works Failed, but not blocking
A non-critical part fails, but the main job still works.

12Related Topics to Read Next

Availability→

The partner idea: being up when needed.

Single Point of Failure (SPOF)β†’

The first weakness to remove.

Scalability→

More machines means more chances for failure.

CAP Theorem→

Choices about data when the network fails.

Checksums→

A way to detect damaged data.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • βœ”What: correct results over time, even when parts fail.
  • βœ”Fault β‰  failure: design so a fault never reaches the user.
  • βœ”Not the same as availability: up can still be wrong.
  • βœ”Tools: redundancy, retries + backoff, timeouts, backups, testing, monitoring.
  • βœ”Key word: idempotent, so retries are safe.
  • βœ”Protect: circuit breakers and graceful degradation.
  • βœ”Always: test restores and failures before they happen for real.
  • βœ”One line: β€œA reliable system keeps its promise, even when things go wrong.”
← Previous
Availability
Next β†’
Single Point of Failure (SPOF)