Skip to main content

Retry Policy

A retry policy is a service mesh setting that automatically retries failed requests without application changes. In Istio it is defined per route in a VirtualService, with the number of attempts, a per-try timeout, and the conditions that trigger a retry.

How retries work

When a request fails, the caller's sidecar sends it again, and the application may never see the first failure. This smooths over transient problems like a connection reset during a pod restart.

sequenceDiagram participant O as Orders app participant S as Orders sidecar participant P as Payments pod O->>S: Request S->>P: Attempt 1 P-->>S: Connection reset S->>P: Attempt 2 P-->>S: 200 OK S-->>O: 200 OK

Configure in Istio

YAML
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: payments-service
namespace: production
spec:
hosts:
- payments-service
http:
- route:
- destination:
host: payments-service
timeout: 10s
retries:
attempts: 3
perTryTimeout: 3s
retryOn: connect-failure,refused-stream,gateway-error

Istio retries by default (twice, on certain connection-level failures) even without a retries block. Set attempts: 0 to disable.

retryOn value Triggers on
5xx Any 5xx response
connect-failure Failure to connect
gateway-error 502, 503, 504
reset Connection reset
retriable-4xx 409 responses

Safety rules

  • Retry only idempotent operations. GET, HEAD, PUT, and DELETE are usually safe.
  • POST and PATCH need an idempotency key, or a duplicate may be processed. A payment initiation retried without one can double-charge.
  • Do not retry client errors like 400, 401, 403, or 404.
Remember

timeout is the total budget for all attempts. Three 3-second attempts need at least 9 seconds of timeout to complete.

Common Mistake

Retrying non-idempotent POST requests. If the response was lost, the retry repeats the action.

Tip

Combine retries with circuit breaking and a total timeout so retries cannot amplify an outage into a retry storm.

Frequently Asked Questions

How is a mesh retry different from retry code in the app?

It runs in the proxy and applies consistently to every service, in any language, with conditions defined declaratively per route. App-level retries depend on each team implementing them.

Why can retries make an outage worse?

Each failure multiplies load on an already struggling service. Without a total timeout, a retry budget, or circuit breaking, retries can turn a partial failure into a full one.

What does perTryTimeout do?

It limits how long a single attempt may take before it counts as failed and the next retry starts, while the route timeout caps the whole sequence.

Found a mistake, an outdated step or a broken link?