A field guide to distributed-systems failure

Ambiguous outcomes, payment retries, deadlines, and the resource limits that keep one failing dependency from exhausting a service.


A process can accept a write and die before sending its response. A disk can stall while a health endpoint keeps answering. Partial failure already exists on one machine; network boundaries add more places where a caller cannot distinguish slow, unreachable, and completed-without-a-reply.

The dangerous interval sits between committing an effect and acknowledging it. That interval exists whether the operation is a payment, a queue job, or a replicated write. A timeout tells the caller that its waiting budget expired. It does not tell the caller whether the effect happened.

A payment service persists pending state and a stable provider key. A lost provider response leaves the operation pending; retries reconcile the same operation before publishing a terminal result.

The operation keeps the same identity across timeouts. An expired provider key requires a recovery decision; blindly submitting the payment again can duplicate the external effect.

Open full size Scroll horizontally to read the diagram on a small screen.

The partial-failure problem

The defining hazard is that a component can fail in a way its callers cannot see. A service returning errors is easy, because you get errors. A service that accepts your request, does nothing with it, and never replies is a nightmare, because from the outside that looks exactly like a service which is merely slow.

Which is why timeouts are load-bearing rather than a nicety. A call without one can hang forever, and a thread blocked forever is a thread you’ve lost. Stack enough of those and a single slow dependency drags down a service that was otherwise fine. That’s the cascading failure everyone quotes, where the thing that breaks is never the thing that caused it. For example, a dependency can exhaust its caller’s connection pool when stalled requests retain connections indefinitely, even if most completed requests remain fast.

Idempotency, or “did that actually happen”

Here’s a question with no clean answer. You sent a request, the connection dropped, and no response came back. Did it succeed? The transport outcome alone cannot settle it. The server may have processed it and failed to reply, or never received it. From where you’re standing those are the same event.

An idempotent operation preserves its intended effect when repeated. Returning a byte-identical response is a separate API choice. For payments, putting a key in a local ledger is insufficient if the provider has already charged the card and the process crashes before writing the ledger.

An example payment protocol makes that boundary explicit. The names below describe storage operations with explicit atomicity requirements; they are not implementations of a payment library.

def charge_card(caller, operation_key, request):
    # Unique on (caller, operation_key); compare a canonical request digest.
    operation = operations.create_or_load_atomically(
        caller, operation_key, fingerprint(request)
    )
    operation.require_same_request(request)
    authorize_current_caller(caller, operation)
    if operation.completed:
        return operation.result

    # Persisted once with the operation, reused after every transport failure.
    provider_key = operation.provider_idempotency_key
    result = provider.charge(request, idempotency_key=provider_key)
    if not result.definitive:
        return operations.pending_response(operation.id)
    return operations.publish_terminal_once_atomically(operation.id, result)

The local unique constraint prevents two different operation records for one scoped key. Request comparison prevents reusing that key for a different amount or currency. The provider key closes the crash interval between an external charge and local result storage, within the provider’s stated idempotency contract. Concurrent local attempts still need bounded ownership or coordination; provider deduplication handles the external effect. Here, definitive means the adapter has established the payment outcome under the provider contract. A timeout, concurrent-request conflict, or indeterminate error remains pending. Terminal publication is conditional: a late worker cannot overwrite an already recorded outcome, and every successful publication returns the stored result.

There is no transaction spanning the local database and an arbitrary payment API. If the provider returns an ambiguous timeout, the operation stays pending, and retry or reconciliation uses the same provider identity. After the provider’s retention horizon expires, blind resubmission can create a new charge. That state needs provider lookup, reconciliation, or an explicit operator decision. It must not quietly acquire a fresh idempotency key.

Stripe retains the first executed request’s status and body for an idempotency key, including errors, and permits key removal after at least 24 hours. That retention window bounds the provider contract. A local table named ledger cannot extend it.

A retry has a resource cost

Safe repetition still consumes requests, connections, CPU, and time. Give one layer ownership of retries and propagate the original deadline. Five layers each making three attempts can generate 3^5 = 243 calls to the lowest dependency for one top-level operation. Each layer can look conservative in isolation while the combined system overwhelms the service it is trying to recover.

Retry eligibility belongs in the operation contract. Validation and authorization failures do not improve with another attempt. A lost acknowledgement may require reconciliation. Transient overload can justify delayed retries, provided the caller has time left and the dependency has capacity.

For retry number k, an illustrative full-jitter delay is a random value between zero and min(cap, base × 2^k). Cap attempts, enforce a total elapsed budget, and honor a server’s retry guidance when applicable. A timeout does not necessarily cancel remote execution; repeated timed-out requests can remain active at the server. Idempotency, deadlines, and jitter share a budget because each retry consumes capacity while its predecessor may still be running.

Containment beats prevention

You can’t prevent failure here. You can only decide how far it spreads, and most of the discipline is drawing boundaries. Bulkheads, circuit breakers, isolated pools. When a component goes bad the blast radius should be that component.

A circuit breaker is the cleanest version of the idea. Once a dependency starts failing you stop calling it for a while rather than hammering it with requests that were going to fail anyway. You fail fast and locally instead of slowly and globally, which protects the struggling dependency and frees your own resources to serve the requests that never needed it.

Containment starts with countable resources. A bounded connection pool limits active database work, but an unbounded queue in front of it can still exhaust memory. Bound queue length and age, reject excess work deliberately, and separate traffic classes when one tenant or operation could monopolize the budget.

A breaker needs a controlled half-open state. Letting every waiting caller probe a recovering dependency recreates the overload immediately. Allow a small number of probes, give them deadlines, and close the breaker only after the recovery condition is met. Fallbacks consume resources too; a cache miss path cannot become an unlimited second route to the same failing database.

The useful incident signals are admission wait, active work, queue age, retry count per logical operation, and the number of unresolved outcomes. A healthy average latency can hide a growing pending-payment ledger. Recovery is complete when those ambiguous operations have been reconciled and the system can carry its normal load again.