Reading preferences
Concept

Retry with Backoff

Retry transient failures carefully with bounded delays and safe effects.

system design, retries, idempotency

Retry only when it is safe

A transient failure may clear on another attempt. Backoff increases the wait between attempts; jitter randomizes it to spread traffic. Set a maximum delay, attempt count and total deadline. Permanent errors, such as invalid input, usually need correction rather than repeated calls.

Notification service

  1. A notification request returns a temporary unavailable response.
  2. Wait one second, then retry with the same operation identity.
  3. If the second attempt succeeds, stop. A real system may add jitter and cap further waits; this small example uses fixed delays for readability.

See the reasoning

Follow the example one step at a time

Retry one notification after a temporary failure. This is a prepared teaching demonstration, not live code execution.

First attempt

operation 42 → unavailable

The first call encounters a temporary failure.

Inventory timeout

A reservation request times out: the inventory service may have applied it before the response was lost. Retrying with a new identity could reserve twice. Reuse a stable idempotency key only if the service durably implements that contract, and reconcile an unknown result. If no such mechanism exists, automatic retry of the mutation may be unsafe.

Trade-offs and failure

Timeouts, retry budgets and circuit breakers complement each other. Respect server retry guidance when appropriate. Retrying at multiple layers can multiply attempts; assign responsibility and observe attempts and outcomes. Retries add latency and load and do not guarantee recovery.

Reflect on the concept

Four fixed questions to reinforce the reasoning. Answers are not saved or scored.

1. Which failure may be suitable for retry?
2. Why add jitter to retry delays?
3. What does an idempotency key help a service recognize?
4. Why bound attempts and total time?

References and further reading