Timeouts, retries and circuit breakers
A timeout is not proof of failure
A remote request may commit a payment and then lose its response. A timeout limits how long the caller waits, not whether the operation happened. Use a stable idempotency key for the same logical operation, store its result durably with the side effect where possible, and reject reuse with different input. An external payment provider needs its own idempotency contract and reconciliation. Never retry a non-idempotent charge blindly.
Budget and jitter
For an illustrative 600 ms end-to-end budget, allow at most three attempts of 150 ms each, with waits of 0–40 ms and 0–80 ms before attempts two and three. The worst modeled total is 570 ms, leaving 30 ms for other work. Real budgets must include DNS, connection, TLS and application overhead. Use a monotonic deadline and avoid starting an attempt when insufficient time remains. Retry transient errors only; respect service retry guidance, cap exponential backoff and add random jitter to prevent synchronized retry waves. Account for SDK retries instead of multiplying them at every layer.
Circuit breakers and bounded queues
A closed circuit permits normal calls; repeated failures can open it and reject calls quickly. After a cooldown a half-open circuit admits limited probes; recovery closes it, failure reopens it. This is separate from the per-request retry budget. Backpressure asks producers to slow down; load shedding rejects excess work deliberately. Bound queue depth, age and worker concurrency. For receipts, accept asynchronous work only after durable enqueue and expose status; never claim an unconfirmed payment succeeded. Monitor rejected work and backlog age.
Practice a lost response
The offline retry model charges a fictional order once, simulates a lost response, and returns the stored result on retry. It is an in-memory illustration, not durable payment processing. Two nested layers with three attempts each can produce nine downstream calls for one request. Select a single retry owner, monitor retry rate and protect critical operations from optional work. When an outage exceeds the budget, report an unknown or pending outcome and reconcile before attempting a new charge.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Timeouts, retries and circuit breakers — knowledge check
Reason about failure isolation, retry budgets and regional consistency.
A payment response times out. What is known?
Three 150 ms attempts and waits capped at 40 and 80 ms consume at most what?
Why add jitter to retry delay?
What should a half-open breaker permit?
What is appropriate when a receipt queue reaches its limit?