Distributed Systems Fundamentals: Partial Failure, No Shared Clock, and What You Do About Them
Machines that share nothing but a network fail independently and disagree about time. The few ideas that make distributed designs survivable.
On this page
On one machine, a function call either returns or the program dies. Between two machines there is a third outcome: you called, and you will never know what happened. Almost everything interesting in distributed systems is a response to that single fact.
What changes when you leave one machine
Search, online banking and multiplayer games all work this way. The machinery is invisible until it breaks.
The three questions behind most bugs
1. Did it happen?
You send a payment request and the connection times out. Three worlds are indistinguishable from your side:
World A: the request never reached the server -> safe to retry
World B: the server processed it, the reply was lost -> retry double-charges
World C: the server crashed halfway -> state may be partial
You cannot tell them apart from the client. The answer is not to guess better but to make retry safe: give each operation an idempotency key, so repeating it has the same effect as doing it once.
2. In what order?
Two nodes each record an event with their own clock. Their timestamps disagree by milliseconds, which is plenty to reverse cause and effect. Lamport’s classic paper showed that what matters is the happened-before relation, and that a logical counter attached to messages can order causally related events without any synchronised clock.
Node A: e1 (counter 1) ---- message ---->
Node B: e2 (counter max(0,1)+1 = 2)
When you need a single agreed order of writes, you use a consensus protocol such as Raft or Paxos instead of trusting clocks.
3. Who is in charge?
Replicas must agree on a leader, or two nodes both think they are primary and accept conflicting writes. Leader election, quorums and fencing tokens exist to answer this safely, even when the network splits.
The fallacies that bite
The “fallacies of distributed computing” are assumptions that hold on a developer laptop and fail in production.
| Assumption | Reality |
|---|---|
| The network is reliable | Packets drop, connections reset, links partition |
| Latency is zero | Calls cost milliseconds, sometimes seconds, and vary wildly |
| Bandwidth is infinite | Large payloads and chatty protocols saturate links |
| The network is secure | Every hop is a trust boundary |
| Topology does not change | Nodes join, leave, move, and addresses change |
| There is one administrator | Different teams, vendors and policies |
| Transport cost is zero | Serialisation and egress cost CPU and money |
| The network is homogeneous | Different protocols, versions and hardware |
A call without a timeout turns a slow dependency into a stuck thread, then a full thread pool, then an outage that spreads upstream. Set a deadline on every network call, and pick it from measured latency, not hope.
The standard toolkit
- Timeouts and bounded retries
Fail fast, retry a small number of times, and back off exponentially with jitter so a recovering service is not stampeded by synchronised retries.
- Idempotency
Design writes so repeating them is safe: idempotency keys, upserts, conditional updates. This is what makes retries legal.
- Replication
Keep copies on several nodes so one failure does not lose data or availability. You then choose how strongly replicas must agree, which is the consistency trade-off.
- Partitioning
Split data across nodes so no single machine must hold or serve everything.
- Consensus and leader election
Use a proven protocol for decisions that must be unanimous, such as who the leader is or the order of writes. Do not invent your own.
- Observability
Distributed tracing, correlated logs and good metrics, because the failing component is rarely the one showing the error.
Benefits and costs, plainly
| You gain | You pay |
|---|---|
| Capacity beyond one machine | Network failure as a normal event |
| Availability through redundancy | Consistency trade-offs to reason about |
| Geographic proximity to users | Harder debugging and testing |
| Independent scaling and deployment | Operational and cognitive overhead |
Do
Distribute for a named reason: load beyond one machine, availability targets one machine cannot meet, or data that must live near users. Use proven building blocks for consensus, queues and storage.
Don't
Split a system into services and machines “for scale” before it has any, then discover that every call is now a network call that can fail, lag or double-run.
Takeaway
Distributed systems are hard because machines share only a network, so failure is partial, time is unreliable and certainty is expensive. Assume every call can time out, make operations safe to repeat, order events logically, and agree on leaders with proven protocols. Do that, and most of the scary vocabulary turns into a short checklist.
Frequently asked questions
What is a distributed system?
A set of independent computers that communicate only by passing messages over a network and cooperate to look like one service. They share no memory and no common clock, and they can fail separately, which is what makes them harder to build than a program on one machine.
What is partial failure?
A situation where some parts of the system fail while others keep running. A request can time out with no way to tell whether the server never received it, received it and crashed, or processed it and lost the reply. On one machine a failure is usually total and obvious.
Why can't distributed systems just use timestamps to order events?
Clocks on different machines drift and cannot be perfectly synchronised, so two timestamps from different nodes cannot be reliably compared. Systems use logical clocks, version vectors or consensus protocols to agree on order without trusting wall-clock time.
When is it better not to distribute a system?
When one well-provisioned machine plus a standby meets the load and availability goals. Distribution brings network failure, consistency trade-offs and operational complexity. Adopt it for a concrete reason such as capacity, availability or geography, not for resume value.
/* Comments */
Comments are offline right now — we reconnect automatically, nothing is lost.