Skip to main content

Configure Retries

Send a request again when the service behind the API fails, so that a brief failure is not seen by the caller.

How it works​

When a request to the backend fails for a transient reason, the gateway sends it again, after a short wait that grows with each attempt. The caller sees one request that succeeded.

A retried request may be executed twice

Retry on connection failures for any operation. Retry on 5xx only for idempotent operations, or the backend may create two orders.

Every parameter and its default: reference.

Use cases​

For requests that are safe to repeat: reads, and writes that your service recognises when it receives them twice.

Prerequisites​

Procedure​

  1. In API Manager, go to API Instances and open the API. To cover everything published on a gateway instead, open the gateway.
  2. Open its Backend traffic policies and add the rule retry.
  3. In Max Retries, give how many times a failed request is sent again.
  4. In Retry On, list what triggers a retry: 5xx, gateway-error, reset, connect-failure.
  5. Adjust Base Interval and Max Interval, the wait between attempts.
  6. Deploy.

Parameters​

FieldWhat it isDefault
Max RetriesHow many times a failed request is sent again.3
Retry OnThe failures that trigger a retry.5xx, gateway-error, reset
Base IntervalThe wait before the first retry. It grows with each attempt.100ms
Max IntervalThe longest wait between two attempts.10s

Behavior and limits​

  • A retry sends the same request again: on a write, it can create a duplicate unless your service recognises a request it already handled.
  • Retries add load to a service that is already failing. Combine them with a circuit breaker.
  • The total time of a request with its retries is bounded by the timeout.

See also​