Skip to content

Lesson 1 of 9 · 24m

Partial Failure Is the Default, Not the Edge Case

Learn why distributed systems fail in halves and thirds — slow networks, ambiguous timeouts, split brain, and dependencies that are up but wrong.

A junior engineer once asked me whether a payment service was "up." The honest answer was: yes, for some customers, some of the time, in one region, while returning stale account data. That is distributed systems in one sentence. Failure is not binary. Parts fail independently, and the hardest failures are ambiguous.

A single machine fails differently

On one machine, a call either returns or the process crashes. Across machines, the same logical operation can succeed remotely while the response is lost:

client        network        payment service
  |-------------- request ---------------->|
  |                                      [commits]
  |<X----------- response lost -------------|
  |
timeout: did payment happen? unknown

The client sees a timeout. It does not know whether the request never arrived, the service crashed before committing, or the service committed and the reply disappeared. Retrying blindly can duplicate work; refusing to retry can strand work. This is the origin of idempotency, and we will return to it throughout the course.

Partial failure takes recognizable shapes

Watch for these patterns in real systems:

slow dependency      thread pools fill, queues grow, cascading timeouts
packet loss          latency spikes, retries, duplicated effects
asymmetric routing   A can reach B, B cannot reach A
clock skew           tokens expire early, logs order incorrectly
split brain          two leaders both believe they own writes
gray failure         health checks pass while correctness is broken

Kubernetes liveness probes are a good example of the last trap. A process can return HTTP 200 from /healthz while every database query fails. "Process is running" and "service is correct" are different measurements.

Design for uncertainty, not optimism

Every network call needs four explicit decisions: timeout, retry policy, cancellation behavior, and what the caller does when the outcome is unknown. In Go this often means passing a deadline through the whole call path:

ctx, cancel := context.WithTimeout(r.Context(), 1200*time.Millisecond)
defer cancel()

result, err := payments.Authorize(ctx, request)
if errors.Is(err, context.DeadlineExceeded) {
    // The authorization may or may not have happened remotely.
    return retryableUnknownOutcome(err)
}

The timeout does not tell you the operation failed. It tells you that waiting longer is no longer useful. Those are very different facts.

Systems you already use make these tradeoffs

PostgreSQL streaming replication can lose acknowledged writes if a primary fails before replication catches up. Kafka can duplicate delivery when consumers retry. Redis Sentinel can fail over while an old primary is still writable for a few seconds. DNS resolvers cache partial answers. None of these are implementation mistakes; they are the price of coordination under imperfect information.

Field notes

  • A timeout is an ambiguous result, not proof of failure.
  • Measure dependency latency separately from application latency; averages hide tail collapse.
  • Health checks should test the actual critical dependency path, not every dependency indiscriminately.
  • If the system can commit remotely and lose the response locally, retries must be safe.
  • The absence of an error message is not evidence that the other side did nothing.

Was this lesson helpful?

Sign in to rate