Retry policy

On this page 7

A retry policy is a set of rules that determines whether, how many times and at what intervals a failed operation is attempted again before the system gives up. In automation reliability, it is the mechanism that turns temporary failures, such as network timeouts, rate limits or brief service outages, into successful runs without human intervention.

A complete retry policy specifies which errors are retryable, the maximum number of attempts, the delay between attempts and what happens after the final failure. Applied carelessly, retries multiply load on a struggling service and duplicate side effects, so a good policy is always paired with idempotency, backoff and a dead letter destination.

How a retry policy works

A retry policy works by classifying each failure and deciding the next step: retry after a delay, fail immediately or escalate. When a step in a workflow or job fails, the runtime checks the error against the policy, increments the attempt counter and schedules the next attempt if allowed.

Classification is the most important decision. Transient errors, such as connection resets, timeouts and HTTP 429, 502, 503 or 504 responses, are usually worth retrying. Permanent errors, such as HTTP 400 validation failures, 401 or 403 authorization failures and 404 for a missing resource, will fail again identically and should not be retried.

Error typeExamplesRetry?
Network failureTimeout, connection reset, DNS errorYes, with backoff
Rate limitingHTTP 429, quota exceededYes, honoring Retry-After if provided
Server unavailableHTTP 502, 503, 504Yes, with backoff
Invalid requestHTTP 400, schema validation errorNo, fix the input
Authorization failureHTTP 401, 403No, unless a token refresh resolves it
Internal server errorHTTP 500Limited retries, then escalate
Classifying failures for retries

After the last allowed attempt, the policy defines a terminal action: mark the run as failed, move the item to a dead letter queue, notify an operator or trigger a compensating workflow that undoes earlier steps.

Retry policy parameters

A retry policy is defined by a small set of parameters that control persistence and pacing. Their values should reflect how long a dependency is typically unavailable and how quickly the result is needed.

ParameterTypical valuesPurpose
Maximum attempts3 to 10 for calls, more for queued jobsLimits wasted work
Initial delay100 ms to a few secondsFirst pause after failure
Backoff multiplier2 is the most commonGrowth of delay per attempt
Maximum delay30 seconds to several minutesCaps a single wait
JitterRandom 0 to 100 percent of the delaySpreads retries from many clients
Overall deadlineSeconds for user requests, hours for jobsStops retrying when the result is useless
Core retry policy parameters

Jitter is essential at scale. Without it, thousands of clients that failed at the same moment retry at the same moment, producing synchronized waves of traffic that can keep a recovering service down. Randomizing each delay spreads the load evenly over time.

Retry strategies compared

Retry strategies differ mainly in how the waiting time changes between attempts. Exponential backoff with jitter is the usual default for calls to shared services, while simpler strategies fit local or low-volume cases.

StrategyDelay patternSuitable forRisk
Immediate retryNo delayRare, brief glitchesHammers a failing service
Fixed intervalSame delay each timeLow-volume internal jobsSynchronized retries
Linear backoffDelay grows by a constantModerate loadSlow to back off under heavy failure
Exponential backoffDelay doubles each attemptRemote APIs and shared servicesLong waits without a cap
Exponential with jitterDoubling plus randomnessLarge fleets of clientsSlightly less predictable timing
Common retry strategies

A retry policy also interacts with a circuit breaker. While retries handle individual failures, a circuit breaker stops calls entirely after a failure threshold, giving the dependency time to recover and preventing retry storms across the whole system.

Retries, idempotency and dead letter queues

A retry policy is only safe when the operation being retried is idempotent, meaning that repeating it has the same effect as performing it once. A timeout does not tell the caller whether the server completed the work, so a blind retry of a payment or an email can duplicate the side effect.

Common techniques include idempotency keys sent with each request, upserts instead of inserts and checks for prior completion before acting. When retries are exhausted, a dead letter queue keeps the failed item with its error details so that it can be inspected, fixed and replayed instead of being lost.

Common retry policy mistakes

Poor retry policies cause outages as often as they prevent them. The most damaging mistakes involve retrying the wrong errors, retrying at several layers and retrying without limits.

MistakeConsequenceBetter practice
Retrying permanent errorsWasted attempts and delayed alertsClassify errors explicitly
Retries at every layerAttempts multiply, such as 3 x 3 x 3 = 27Retry at one chosen layer
No maximum attemptsEndless loops and growing loadSet attempts and a deadline
No jitterSynchronized retry stormsAdd randomized delay
Silent final failureLost work nobody noticesDead letter queue and alerting
Mistakes and their consequences

Stripped to the essentials

A retry policy is the rule for what to do when something does not work the first time. It is like calling a friend whose line is busy: you wait a little, try again, wait a bit longer, and after a few tries you send a message instead.

The important part is knowing when trying again makes sense. A busy line is worth another try; a wrong phone number is not, no matter how often you dial.

Where it is applied

A subscription company runs a nightly workflow that charges renewing customers through a payment provider. Occasionally the provider returns HTTP 503 for a few minutes, and previously the whole batch failed and had to be restarted by hand.

The team defines a retry policy: up to six attempts with exponential backoff starting at two seconds, capped at five minutes, with full jitter. Each charge request carries an idempotency key based on the invoice number, so a retried request cannot charge a customer twice. Card declines are classified as permanent and are not retried.

Items that still fail go to a dead letter queue reviewed each morning. Since the change, short provider outages resolve themselves without manual work, and no duplicate charges have occurred.