Root Causes in Distributed Systems

The six classic distributed failure modes, idempotency, safe retries with backoff and jitter, dead-letter queues, and a ten-step root-cause method.

  • Intermediate to advanced
  • About 25 minutes
  • Includes an exercise and a knowledge check

The concept Accepted here, failed three steps later

Enterprise applications communicate across networks, queues, databases, APIs and vendors. A transaction can be accepted by one component and fail several steps later. That makes distributed investigation very different from debugging one program.

A payment path through API gateway, integration, message broker, consumer, loan servicing database and reconciliation, with five numbered failure pins: 1 duplicate delivery, the same event arrives twice; 2 delayed delivery, published 09:00 and consumed 09:20; 3 out of order, captured arrives before authorized; 4 timeout, outcome unknown; 5 partial update, the first write committed and the second failed. Below, the investigation path: transaction IDs, logs, metrics and traces. Reconstruct the transaction history first, then name the root cause.
Most distributed failures happen between components, or across time.
FailureWhat happensTypical reasons
Duplicate deliveryThe consumer receives the same event twiceProducer retries, consumer fails before acknowledging, network interruption, broker redelivery
Delayed deliveryPublished at 09:00, consumed at 09:20Backlog, consumer down, too little capacity, slow downstream dependency
Out-of-order eventsCaptured arrives before authorizedParallel processing, retries, several partitions
Partial failureOne write succeeds, the next does notNo shared transaction across systems
Timeout, unknown outcomeThe work completed but the reply was lostSlow downstream service, network break
Data inconsistencyTwo systems describe one event differentlyWrong mapping, ID formats, time zones, status meanings, rounding

The key idea Idempotency

Idempotency means repeating an operation with the same identity does not create an extra effect. Pressing a lift button five times still calls one lift. When event EVT9001 arrives twice, a well-designed consumer recognizes it and does not post the payment again:

  1. Receive the event.
  2. Validate its identity.
  3. Check whether it has already been applied.
  4. If it has, record the duplicate delivery and stop.
  5. Otherwise, perform the business operation.
  6. Record the outcome safely.

Retries Retry carefully

FailureUsually the right response
Temporary network errorRetry
Validation errorFix the data; retrying will fail the same way
Authorization failureFix credentials or permissions
TimeoutCheck whether the operation already happened
Downstream outageBack off and recover in a controlled way

A common strategy is exponential backoff with jitter: wait longer after each failure, plus a small random amount, so that thousands of failed requests do not all retry at the same instant. The retry policy must still match the safety of the operation and the capacity of the downstream system.

Recovery Dead-letter queues

Messages that fail repeatedly may be moved to a dead-letter queue: a controlled holding area for investigation and recovery. Before you touch one, ask why it failed, whether the message is malformed, whether the failure is temporary or permanent, whether it can be safely corrected and replayed, whether part of the business operation already happened, and who authorizes the recovery.

The method A ten-step root-cause method

  1. Pick one affected business transaction.
  2. Find its identifiers in every participating system.
  3. Build a timestamped execution timeline.
  4. Find where expected behavior and actual behavior diverge.
  5. Collect supporting logs, traces, records and metrics.
  6. Develop several possible explanations.
  7. Test each explanation against the evidence.
  8. Confirm the cause, or write down what is still unknown.
  9. Determine the business and operational impact.
  10. Recommend a correction and a way to prevent it happening again.

Practice Name the failure mode

Practical exercise

Four short cases

For each case, name the failure mode and the first evidence you would collect.

  1. Some borrowers show a payment status of authorized even though the provider reports captured.
  2. Payments made at 8:55 a.m. appear in loan servicing at 9:20 a.m. every Monday.
  3. A payment appears in loan servicing but not in the audit history.
  4. After a network blip, one payment was posted twice.
Show sample answers
  • Out-of-order events: captured processed first, then overwritten by a late authorized. Evidence: occurred and received timestamps for both events.
  • Delayed delivery: consumer lag on Monday mornings. Evidence: queue depth and consumer lag metrics for Mondays.
  • Partial failure: the posting committed, the audit write did not. Evidence: logs around the posting time, and whether both writes share a transaction.
  • Timeout with unknown outcome plus a blind retry: no idempotency. Evidence: logs for both attempts and the event ID on both postings.

3 questions

Check your understanding

1. What does idempotency guarantee?
2. What does a dead-letter queue help with?
3. A validation error occurs. Should you retry?
Answer every question to submit.

What you can do now

  • Recognize the six distributed failure modes.
  • Explain idempotency and why check-then-insert is not enough.
  • Choose the right response to each kind of failure.
  • Handle dead-letter queues safely and follow the ten-step method.