System design concepts · When Machines Disagree

Distributed Systems Basics for System Design Interviews

A distributed system is one where a computer you didn't know existed can stop your own computer from working. Everything in this part follows from taking that sentence seriously.

What you'll be able to explain
  • Say what makes a system "distributed" and why that changes everything
  • List the eight fallacies and spot them in a design
  • Tell crash, omission, timing and Byzantine failures apart
  • Detect failures with heartbeats, timeouts and gossip, and know their limits
  • Explain split-brain, fencing and why "exactly once" is so hard

What makes a system distributed

A system is distributed when its parts run on separate machines that cooperate only by sending messages over a network. There is no shared memory and no shared clock. Each machine sees only its own state plus whatever messages happen to arrive.

That one constraint produces three permanent problems:

  1. Partial failure. Part of the system can be broken while the rest works. On one machine, a crash stops everything; in a distributed system, the payment service can be down while checkout is up.
  2. Unreliable communication. A message can be lost, delayed, duplicated or reordered, and the sender can't tell which.
  3. No global "now". Each machine's clock drifts. You can't reliably order events across machines by timestamp alone (Unique ID Generation in Distributed Systems).
Analogy

Picture planning a wedding entirely by post. Letters get lost, some arrive weeks late, some arrive twice, and you never know whether silence means "the caterer is thinking", "the letter is lost", or "the caterer has gone out of business". Every distributed protocol is a careful way of planning that wedding anyway.

The eight fallacies

Engineers new to distributed systems tend to assume these eight things. Every one is false, and each has broken production systems.

Fallacy Reality Design response
The network is reliable Packets drop; links flap; switches reboot Timeouts, retries, idempotency
Latency is zero Cross-region calls take 50–250 ms Fewer round trips, batching, caching, locality
Bandwidth is infinite Big payloads saturate links and cost money Compression, pagination, streaming
The network is secure Anyone may be listening TLS everywhere, zero trust, mTLS between services
Topology doesn't change Instances come and go every minute Service discovery, health checks
There is one administrator Many teams, vendors and clouds Clear contracts, versioning, defensive clients
Transport cost is zero Egress fees and serialisation CPU add up Measure; keep chatty services close
The network is homogeneous Mixed hardware, protocols and versions Standard protocols, compatibility tests
Common trap

Drawing an arrow between two boxes and treating it like a function call. Every arrow in an architecture diagram can be slow, fail, or succeed without you hearing back. A strong candidate says what happens in each case.

How things fail

Failure model What happens Example
Crash-stop A node stops and never comes back Hardware dies; instance terminated
Crash-recovery A node stops, then restarts with whatever was on disk Process OOM-killed and restarted
Omission Some messages are lost A full queue drops packets
Timing (performance) A node responds, but too slowly 30-second GC pause; noisy neighbour
Byzantine A node lies or behaves arbitrarily Corrupted memory, bugs, or malicious actors

Most company systems assume crash-recovery with omission and timing failures, and trust their own nodes not to lie. Blockchains and some aerospace systems tolerate Byzantine failures, at a large cost in messages and complexity.

The fundamental uncertainty

ClientPayments1charge ₹499 (case 1: request lost)2charge ₹499 (case 2: processed…)3…but the reply is lost4charge ₹499 (case 3: still processing)5all three end in a timeout
Did the payment happen? From the client's side, these three cases look identical.

When a request times out, the client cannot know whether the work happened. This one fact explains a huge share of distributed systems design:

  • Retries are necessary (case 1) and dangerous (cases 2 and 3), so operations need idempotency keys.
  • "Exactly-once delivery" is impossible over an unreliable network; what we build is at-least-once delivery plus idempotent processing, which gives an exactly-once effect.
  • Status checks ("did order 77 go through?") and reconciliation jobs are features, not hacks.