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

Network Partitions

When the network splits the machines into groups that cannot talk to each other.

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

01Quick Summary

A network partition happens when the network breaks so that the machines in a system are split into groups that can not talk to each other. Each group is still running, but it can not see the others.

  • Nobody crashed. The links between machines failed (a cable, a switch, a bad config, a busy network).
  • Each side can not tell if the other side is dead or just cut off.
  • The system must choose: refuse some requests to stay correct, or keep answering and risk disagreement. This is the heart of the CAP theorem.

02Concept: What is it?

Imagine a database with five nodes in two data centres. One day the link between the data centres is cut. All five machines are healthy, and each data centre still works inside. But the three nodes in one data centre can not reach the two nodes in the other.

This is a partition. The important point is that it is not a crash. A crashed machine is silent and so is a cut-off machine, so from the outside you can not tell them apart.

A cluster before and after a partition
Healthy
πŸ—„οΈN1
πŸ—„οΈN2
πŸ—„οΈN3
↕all connected
πŸ—„οΈN4
πŸ—„οΈN5
Partitioned
πŸ—„οΈN1
πŸ—„οΈN2
πŸ—„οΈN3
β†•βœ‚ cut
πŸ—„οΈN4
πŸ—„οΈN5
Both groups are alive. Each one may think the other has failed.

Partitions are not rare events from textbooks. Real networks have bad switches, mistaken config pushes, overloaded links, cloud zones losing contact and even a single long pause that makes a machine look gone. Treat them as something that will happen.

🧠Partition tolerance is not optional
In the CAP theorem you do not really get to choose "no partitions". Partitions will happen, so the real choice is what to do while one is happening: stay consistent (refuse some requests) or stay available (answer, maybe with old or conflicting data).

03Real-Life Example

🍡Two Shops Sharing One Stock List
A company has two shops in two cities. Both sell the last pair of shoes of a model, and the phone line between the shops goes down. The manager of shop A can not call shop B to check. Does shop A sell the shoes anyway (and risk that shop B sold them too), or does it tell the customer "sorry, I can not sell right now" until the phone works again? The first is available but maybe wrong. The second is correct but unavailable. When the phone line is back, they compare notes and fix any double sale.
The two shops
Partitioned system
The phone line goes down
The network between two groups fails
Both shops are open and fine
All nodes are alive
Selling anyway
Choosing availability (AP)
Refusing to sell until the line is back
Choosing consistency (CP)
The same pair sold twice
Conflicting writes
Comparing notes afterwards
Healing and merging (reconciliation)
Needing a majority of managers to agree
Quorum
The life of a partition
βœ…Normalall connected
→↓
βœ‚οΈPartitiongroups cut off
→↓
βš–οΈChooserefuse or accept
→↓
πŸ”§Heallinks return
→↓
πŸ”€Reconcilemerge the data

04Why Do We Need It?

🧭It will happen
Large networks always have broken links somewhere. A design that ignores partitions is a design that fails.
βš–οΈIt forces a choice
During a partition you must pick between correct answers and answering at all. Knowing this lets you pick on purpose.
πŸ”It explains CAP
CAP is about what a system does when a partition happens, not when everything works.
πŸ› οΈIt shapes the database choice
Some databases refuse writes without a majority. Others accept everywhere and merge later.
πŸ’ΈIt protects money and data
Handling partitions well prevents double spending, double booking and lost updates.
πŸ§ͺIt guides testing
You can test partitions on purpose (for example by blocking traffic between nodes) and see what the system does.
A partition is a broken link, not a broken machine. The system can not tell the difference, so it must decide how to behave without knowing.

05Where Do We Use It?

🌍Multi-region deployments
Links between continents fail more often than links inside a rack.
🏒Between availability zones
A zone can lose contact with the others while still running.
πŸ—„οΈReplicated databases
Replicas and leaders may lose contact, and each side must decide what to do.
🧩Microservices
A service that can not reach another one sees the same thing as a partition.
πŸ“±Mobile and offline apps
A phone with no signal is a partition of one. Apps often keep working and sync later.
πŸ”§Bad deployments
A wrong firewall rule or config push can split a healthy cluster in seconds.

06Types / Parts / How It Works

What a partition can look like

KindWhat happensExample
Clean splitTwo groups, each fully connected insideLink between two data centres is cut
Isolated nodeOne node is cut off from all othersA machine's network card fails
Partial (asymmetric)A can reach B, but B can not reach A, or A sees C but B does notA bad firewall rule, a flaky switch
Client cut offClients can not reach servers, but servers talk to each other fineUsers' internet or a load balancer problem
Slow, not cutMessages arrive, but so late that timeouts fireOverloaded link, long GC pause

What a system can choose during a partition

Two ways to behave
Consistency first (CP)
βœ…Majority sidekeeps accepting writes
β›”Minority siderefuses writes, returns errors
πŸ”’Resultone version of the truth
Availability first (AP)
βœ…Both sideskeep accepting writes
πŸ”€Versions drift apartconflicts may appear
πŸ”§Resultmerge after healing
Correctness Always answering Refuses requests
Majority groups can keep going. Minority groups must either stop or risk conflicts.

Common ways to merge after healing

MethodHow it worksRisk
Last write winsKeep the write with the latest timestampA real write is silently lost, and clocks may be wrong
Version vectorsTrack history, find which writes truly conflictThe app may have to resolve the conflicts
CRDTsData types that always merge without conflictOnly some data fits, such as counters and sets
Ask the userShow both versions and let a human chooseAnnoying, but nothing is lost
VisualizerCut the network: refuse writes or accept them?Cut the network, then write on each side. Compare a system that needs a majority with one that accepts writes everywhere. Heal the network and see what is lost.
When the network splits, the system chooses…
How the cut falls
πŸ—„οΈNode 1value v0
πŸ—„οΈNode 2value v0
πŸ—„οΈNode 3value v0
πŸ—„οΈNode 4value v0
πŸ—„οΈNode 5value v0
All nodes can talk to each other.
Writes accepted
0
Writes refused
0
user saw an error
Writes lost
0
thrown away on merge
Nodes that agree
5 of 5
Five nodes hold the same value (v0) and the network is healthy. Press 'Cut the network' to split them, then write on each side.

A simplified model with one value and two groups. Real systems have timeouts, many keys and smarter merging than last-write-wins, but the choice is the same: refuse some requests, or risk disagreement.

07How to Use It / Steps / Implementation

Living with partitions

  1. 1
    Decide per feature
    Money transfers and stock counts usually want consistency. Likes, view counts and shopping carts can often accept old or merged data. Choose for each feature, not once for everything.
  2. 2
    Use a majority (quorum)
    Require more than half of the nodes to agree on a write. Two groups can not both hold a majority, so only one side keeps going.
  3. 3
    Use an odd number of nodes
    With 3 or 5 nodes there is always at most one majority. With 4 nodes, a 2-and-2 split leaves nobody with a majority.
  4. 4
    Spread nodes over three places
    If the cluster is in only two data centres, one of them holds the majority and its loss stops everything. Use three zones.
  5. 5
    Set sensible timeouts
    Too short and a slow network looks like a partition. Too long and you notice the real one very late.
  6. 6
    Plan the merge
    If you accept writes on both sides, decide how conflicts are resolved before launch: version vectors, CRDTs or a business rule.
  7. 7
    Test it
    Block traffic between nodes in a test environment and check what users see, what is lost and how the system recovers.
πŸ’‘Return a clear error
A system that refuses a request on the minority side should say so fast and clearly. A quick "try again later" is much better than a long hang.
⚠️Healing is the dangerous moment
Many data problems appear not during the partition, but right after it, when two different histories meet. Test the heal step as much as the cut.

08Key Terms to Know

TermMeaning in easy words
Network partitionA network failure that splits nodes into groups that can not reach each other
QuorumThe minimum number of nodes (usually a majority) that must agree for an action
MajorityMore than half of all nodes
MinorityA group with half or fewer of the nodes
CP systemKeeps data consistent during a partition and may refuse requests
AP systemKeeps answering during a partition and may return old or conflicting data
ReconciliationMerging different versions of data after the network heals
Last write wins (LWW)A merge rule: keep the write with the newest timestamp
Asymmetric partitionA can reach B, but B can not reach A
Split brainBoth sides of a partition act as the leader
HealingThe moment the network works again and the groups can talk

09Pros, Cons and Trade-offs

βœ… Pros
  • Planning for partitions makes the system safe on bad days
  • A majority rule gives one clear winner
  • Giving up some availability protects important data
  • Merge rules let apps keep working offline
  • Tests of partitions find real bugs early
⚠️ Cons
  • Consistency-first systems return errors to some users
  • Availability-first systems can create conflicts and lost updates
  • Merging data is hard to get right
  • Hard to test, because real partitions are messy and partial
  • Needs extra nodes and zones, which cost money

Trade-offs

ChoiceWe gainWe lose
Refuse writes without a majority (CP)No conflicting dataThe minority side is unavailable
Accept writes everywhere (AP)Always answers, good for offline useConflicts to merge, risk of lost writes
Short failure timeoutReacts fast to real partitionsFalse alarms when the network is only slow
Long failure timeoutFewer false alarmsLong delay before the system reacts
Last write winsSimpleSilent data loss and clock problems
More zones and nodesSurvives bigger failuresMore cost and more to coordinate

10Common Problems and Mistakes

Common mistakes

  1. Assuming partitions are rare. They happen in every large network, often from human mistakes.
  2. Mixing up a crash and a cut. A node that looks dead may be alive and still accepting writes somewhere.
  3. Even-sized clusters. A 2-and-2 split of four nodes leaves nobody with a majority, and the cluster stops.
  4. Two zones only. One zone must hold the majority, so losing it stops the system, even though the other zone is fine.
  5. Last-write-wins on important data. Money and orders silently vanish.
  6. Never testing the heal. The merge step has bugs that show up only in production.
  7. Only testing clean splits. Real partitions are partial and one-way.

Things to watch

πŸ”€Split brain
Two leaders at once. Prevent it with majority votes and fencing tokens.
πŸ•³οΈLost updates
Both sides write the same item. One write is dropped on merge.
πŸͺžStale reads
The cut-off side keeps serving old data without telling anyone.
🌊Reconnect storm
When the link returns, every node syncs at once and overloads the network.

11Real-World Examples

πŸ—„οΈZooKeeper, etcd, Raft
Consistency first: they only accept writes on the side that has a majority of nodes.
🧱Cassandra, DynamoDB
Designed to stay available. Tunable settings let you choose how many replicas must answer.
πŸƒMongoDB replica sets
A primary that loses the majority steps down, and the majority side elects a new primary.
πŸ“Collaborative editors
Work offline, then merge edits when the connection returns (CRDTs or operational transformation).
πŸ§ͺJepsen
A testing project that creates partitions in databases and often finds lost or conflicting writes.
πŸ›’Shopping carts
A known design keeps carts available and merges them, preferring an extra item over a lost one.
πŸ“Note
How a product behaves in a partition depends on its settings and version. Check its documentation and test it before you rely on it.
Mini case: 5 nodes in 3 zones
🏒Zone A2 nodes
↔
🏒Zone B2 nodes
↔
🏒Zone C1 node
Zone with nodes Healthy link
Whichever single zone is cut off, 3 of the 5 nodes can still talk, so the cluster keeps working.

12Related Topics to Read Next

CAP Theorem→

The rule that says what you must give up during a partition.

Split Brain Problem→

What happens when both sides of a partition act as leader.

Heartbeats→

How a node notices that others have gone silent.

Consistency Models→

The different promises a system can make about what readers see.

Consensus Algorithms→

How a majority can agree even when others are cut off.

CRDTs→

Data types that merge cleanly after a partition.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • βœ”What: the network splits nodes into groups that can not talk, though all nodes are alive.
  • βœ”Hard part: a cut-off node looks the same as a crashed one.
  • βœ”Choice: refuse some requests (CP) or keep answering and merge later (AP).
  • βœ”Quorum: a majority must agree. Two majorities always overlap, so only one side can win.
  • βœ”Cluster size: use an odd number, and spread it over three zones.
  • βœ”Merge: last-write-wins loses data. Version vectors and CRDTs are safer.
  • βœ”Test: cut links, write on both sides, heal, and look for lost writes.
  • βœ”One line: β€œPartitions will happen, so decide ahead what to give up.”
← Previous
Failure Types: Crash vs Byzantine
Next β†’
Split Brain Problem