SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
  • Challenges of Distribution
  • Failure Types: Crash vs Byzantine
  • Network Partitions
  • Split Brain Problem
  • Heartbeats
  • Failure Detectors
  • Handling Failures
  • Consistency Models
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Distributed Systems/Distributed System Fundamentals

Failure Types: Crash vs Byzantine

Machines can fail by stopping, by going silent, or by lying. Which kind you expect decides the whole design.

โฑ 12 min readIntermediateInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

A machine can fail in more than one way. The two big families are crash failures (it just stops) and Byzantine failures (it keeps going but sends wrong or lying answers). Which one you plan for decides how many machines you need and how hard the design is.

  • Crash: the node stops. Easy to reason about. Raft and Paxos tolerate it with 2f + 1 nodes.
  • In between: crash-recovery, omission (lost messages) and timing (too slow) failures.
  • Byzantine: the node lies, or is hacked, or has a bug. Needs 3f + 1 nodes and more messages.

02Concept: What is it?

A failure model is a promise about how things are allowed to go wrong. Before you design a distributed system, you say: "I expect machines to fail in these ways, and no others." Every algorithm is only correct inside its failure model.

The models are ordered from gentle to harsh. A harsher model includes everything in the gentler ones, so an algorithm built for the harsh model also works in the gentle one, but it costs more.

From gentle to harsh
๐Ÿ’ฅCrash-stopstops for good
โ†’โ†“
๐Ÿ”„Crash-recoverystops, then returns
โ†’โ†“
๐Ÿ“ญOmissiondrops messages
โ†’โ†“
๐ŸŒTiminganswers too late
โ†’โ†“
๐ŸŽญByzantineanything at all
Each step to the right allows more kinds of bad behaviour.

The name Byzantine comes from a famous 1982 paper where generals must agree on a plan, but some of them may be traitors who send different messages to different people. A Byzantine node is not just broken. It can behave in the worst possible way.

๐Ÿง The one-line difference
A crashed node gives you no answer. A Byzantine node gives you a wrong answer, and may give a different wrong answer to each person who asks.

03Real-Life Example

๐ŸตThree Friends Keeping a Shared Diary
You and two friends keep three copies of a shared diary, and the rule is "two out of three copies must agree". If one friend loses their copy (crash), the other two still agree. If one friend is on holiday and answers a week late (timing), you can carry on without them. But if one friend lies and tells you one thing and tells your other friend something else, the two honest copies can end up different, and nobody can tell who is lying.
The diary story
Distributed system
A friend loses their copy
Crash failure
They lose it, then rewrite it from memory
Crash-recovery (it may forget things)
Some letters never arrive
Omission failure
A reply that comes a week late
Timing failure
A friend who tells different people different stories
Byzantine failure
Two out of three must agree
A majority quorum
Needing four friends to out-vote one liar
3f + 1 nodes
One bad node, two kinds of trouble
Crash
๐Ÿ–ฅ๏ธNode 1: balance 100
๐Ÿ–ฅ๏ธNode 2: balance 100
๐Ÿ’ฅNode 3: silenceeasy to spot and ignore
Byzantine
๐Ÿ–ฅ๏ธNode 1: balance 100
๐Ÿ–ฅ๏ธNode 2: balance 100
๐ŸŽญNode 3: says 999 to you, 5 to Node 2looks like a good answer

04Why Do We Need It?

๐ŸŽฏPick the right tool
A crash-only design is simple and fast. Using a Byzantine design for every job wastes machines and time.
๐Ÿ“Count the nodes
The failure model gives the exact number of machines you need: 2f + 1 for crashes, 3f + 1 for liars.
๐ŸงชTest the right things
You can only test failures you have named. A list of failure types is a test plan.
๐Ÿ›ก๏ธSpot hidden risks
Slow nodes and lost messages are far more common than liars, and are often mistaken for crashes.
๐Ÿ“œRead papers and docs
Words like crash-stop, fail-stop and Byzantine tell you what an algorithm really promises.
๐Ÿ’ฌTalk clearly in interviews
Starting with โ€œI assume crash failuresโ€ shows you know every design has assumptions.
Say what kind of failure you expect before you say how you will handle it. The design follows from that choice.

05Where Do We Use It?

๐Ÿ—ณ๏ธRaft, Paxos, ZAB
Consensus built for crash failures. Used inside etcd, ZooKeeper and Consul.
๐Ÿ—„๏ธReplicated databases
Spanner, CockroachDB and most SQL clusters assume nodes crash or slow down, not lie.
โ›“๏ธBlockchains
Anyone can join, so some nodes will lie. These systems must be Byzantine fault tolerant.
โœˆ๏ธAircraft and spacecraft
Flight computers vote across units, because a damaged sensor can send nonsense, not just silence.
๐ŸฆConsortium ledgers
Banks sharing a ledger do not fully trust each other, so they use PBFT-style protocols.
๐Ÿ’พStorage with checksums
A disk that returns wrong bytes is a small Byzantine fault. Checksums catch it.

06Types / Parts / How It Works

The five failure types

TypeWhat the node doesExampleHow we cope
Crash (crash-stop)Stops and never returnsPower cut, kernel panicReplicas, timeouts, replace the node
Crash-recoveryStops, then restarts with only its saved stateProcess restartWrite promises to disk before replying
OmissionRuns, but some messages are lostFull buffer, dropped packetRetries, acknowledgements
TimingAnswers correctly but too lateLong GC pause, slow diskTimeouts, fencing tokens
ByzantineDoes anything, even liesBug, corrupt memory, hacked node3f + 1 nodes, signatures, voting

How many nodes do you need?

If up to f nodes can be faulty, you need enough healthy nodes left to still form a clear answer.

๐Ÿ’ฅCrash faultsn โ‰ฅ 2f + 1
โ†’โ†“
๐ŸงฎA majority of f + 1 survives3 nodes tolerate 1
๐ŸŽญByzantine faultsn โ‰ฅ 3f + 1
โ†’โ†“
๐Ÿงฎ2f + 1 must agree4 nodes tolerate 1
๐Ÿ“Why 3f + 1?
With f liars, they could be among the answers you hear, and f honest nodes may be slow and not answer. So you must be able to decide using only n โˆ’ f replies, and still have more honest ones than liars among them. That works out to n โ‰ฅ 3f + 1.
Crash model Byzantine model
VisualizerBreak node 3 in five different waysPick a failure type and a design assumption. See what the client gets back, whether that design copes, and how many nodes it needs for f faulty ones. Then try the Byzantine failure against the crash-only design.
What goes wrong with node 3?
What did the designer assume?
A client asks all three nodes: "What is the balance?"
๐Ÿ–ฅ๏ธ
Node 1
balance = 100
๐Ÿ–ฅ๏ธ
Node 2
balance = 100
๐ŸŽญ
Node 3 (faulty)
balance = 999 (a lie)
Byzantine: The node sends wrong or conflicting answers, by bug, corruption or on purpose.
Nodes needed
3
2f + 1 = 3
Extra cost of lying
+1
4 instead of 3 nodes
Result
Breaks
Byzantine fault
Majority voting believes every node's word. A liar can tell different nodes different things, and the nodes stop agreeing.

Simplified: one faulty node out of three is shown, while the node counts follow the formulas for f faulty nodes. Crash-only agreement needs a majority (2f + 1 nodes). Agreement when nodes may lie needs 3f + 1.

07How to Use It / Steps / Implementation

Choosing a failure model for your system

  1. 1
    List who runs the machines
    If you own and trust every node, expect crashes, slowness and lost messages. If strangers can join, expect lying.
  2. 2
    Pick the gentlest model that is honest
    Most company systems choose crash-recovery with timing and omission faults.
  3. 3
    Choose f
    How many faulty nodes must the service survive at once? One is common, two for critical data.
  4. 4
    Compute the size
    Crash: 2f + 1 nodes. Byzantine: 3f + 1 nodes.
  5. 5
    Save promises to disk
    In crash-recovery, a node must write what it promised before it answers.
  6. 6
    Guard against slow nodes
    Use timeouts, and fencing tokens for locks, because a paused node can wake up and act late.
  7. 7
    Add cheap Byzantine defences anyway
    Checksums, TLS, authentication and input validation catch many โ€œsmall liesโ€ without full BFT.
๐Ÿ’กSmall lies are common, big liars are rare
Bit flips, bad firmware and misconfigured clients are far more likely than an attacker running a node. Checksums and validation handle most of it at low cost.

08Key Terms to Know

TermMeaning in easy words
Failure modelA statement of how components are allowed to fail
Crash-stopA node stops and never comes back
Crash-recoveryA node stops, then returns with only the state it saved to disk
Omission failureA node or link loses messages but is otherwise correct
Timing failureA node responds correctly but outside the expected time
Byzantine failureA node behaves arbitrarily, including lying or sending conflicting answers
Fail-stopA crash that other nodes can reliably detect
fThe number of faulty nodes a system is designed to survive
QuorumThe smallest group whose agreement is enough to decide
Fail-silentA node that stops and gives no sign, so others cannot be sure it is dead
Gray failureA node that is partly working, so some checks pass and some fail

09Pros, Cons and Trade-offs

โœ… Pros
  • Naming the failure model makes a design testable
  • Crash-only designs are simple, fast and well understood
  • Byzantine designs survive attacks and bugs that lie
  • Helps you size the cluster with simple formulas
  • Makes papers and product claims easier to judge
โš ๏ธ Cons
  • Crash-only designs break if a node lies
  • Byzantine designs need more nodes and many more messages
  • Real failures often fall between the categories
  • A wrong assumption fails silently, only in rare cases
  • Too much defence adds cost for a failure that may never come

Trade-offs

ChoiceWe gainWe lose
Assume crash onlyFew nodes, fast, simpleUnsafe if a node lies
Assume ByzantineSafe against liars and bugs3f + 1 nodes and heavy messaging
Crash-recoveryNodes can restart safelyEvery promise must reach disk first
Short timeoutsQuick failure detectionSlow nodes treated as dead
Checksums and signatures onlyCheap protection against small liesNot full Byzantine safety

10Common Problems and Mistakes

Common mistakes

  1. Assuming nodes only crash. A bug or memory fault can make a node send wrong data while looking healthy.
  2. Treating slow as dead. A paused node comes back and may act on stale ideas.
  3. Forgetting disk in crash-recovery. A node that promised something in memory only can break its promise after a restart.
  4. Using BFT for everything. It costs more machines and more messages for a risk you may not have.
  5. Not saying the model. Teams argue about correctness because each assumes a different failure model.
  6. Ignoring partial failures. A node that answers health checks but fails real requests is a gray failure.

Things to watch

๐ŸŒซ๏ธGray failures
The node is neither up nor down. Health checks pass while users see errors.
๐ŸงฌSilent corruption
Bad bits from disks or memory. Use checksums end to end.
๐ŸงฑCorrelated failures
Nodes on the same rack, same bug or same bad deploy fail together. Tolerating f does not help then.
๐Ÿง‘โ€๐Ÿ’ปHuman error
A wrong config pushed to all nodes is the most common Byzantine failure of all.

11Real-World Examples

๐Ÿ“„The Byzantine Generals paper (1982)
Lamport, Shostak and Pease proved you need more than two thirds honest nodes to agree.
๐Ÿ—ณ๏ธetcd and ZooKeeper
Crash-fault tolerant. A 3-node cluster survives 1 failure, a 5-node cluster survives 2.
โ›“๏ธTendermint and Hyperledger Fabric
Byzantine fault tolerant consensus used by blockchain platforms.
๐Ÿ›ฐ๏ธSpace shuttle computers
Several flight computers voted on every command, because a failed unit might send plausible nonsense.
๐ŸงฎZFS and S3 checksums
Detect silent corruption, a small Byzantine fault from a disk.
โ˜๏ธCloud gray failures
Large providers publish write-ups about nodes that were slow, not dead, and caused wide outages.
Mini case: replica with a flipped bit
๐Ÿ’ฝDisk returns wrong datano error raised
โ†’โ†“no check
๐ŸŽญReplica sends bad valueacts Byzantine
โ†’โ†“with checksum
๐Ÿ›ก๏ธMismatch foundread fails over to another copy
Checksums turn a silent lie into a visible crash.

12Related Topics to Read Next

Byzantine Fault Tolerance (BFT)โ†’

How to reach agreement when some nodes lie.

Failure Detectorsโ†’

How a system guesses which nodes have failed.

Handling Failuresโ†’

Timeouts, retries and fallbacks in practice.

Consensus Algorithmsโ†’

Agreement among nodes under a chosen failure model.

Raftโ†’

A crash-fault tolerant algorithm with 2f + 1 nodes.

Fencing Tokensโ†’

Protect against a slow node that wakes up late.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • โœ”Failure model: say how things may fail, then design for that.
  • โœ”Crash: the node stops. Needs 2f + 1 nodes (majority).
  • โœ”Crash-recovery: save promises to disk before answering.
  • โœ”Omission and timing: lost or late messages. Use retries, timeouts, fencing.
  • โœ”Byzantine: the node may lie. Needs 3f + 1 nodes.
  • โœ”Harsher includes gentler: a BFT design also covers crashes, at higher cost.
  • โœ”Cheap defence: checksums, TLS and validation catch small lies.
  • โœ”One line: โ€œA silent node is easy. A lying node is the hard one.โ€
โ† Previous
Challenges of Distribution
Next โ†’
Network Partitions