gRPC automatic retry and hedging config
gRPC clients can retry failed RPCs automatically when the service config JSON
declares a retryPolicy or hedgingPolicy under a method’s methodConfig
entry. This reference lists every field in both policies with its JSON type,
whether it is required, and what it controls, plus a live search.
How it works
A retryPolicy retries sequentially: attempt 1 fails, the client waits a backoff
interval, then attempt 2 runs, and so on up to maxAttempts. The wait grows
exponentially:
"retryPolicy": {
"maxAttempts": 4,
"initialBackoff": "0.1s",
"maxBackoff": "1s",
"backoffMultiplier": 2,
"retryableStatusCodes": ["UNAVAILABLE", "RESOURCE_EXHAUSTED"]
}
A hedgingPolicy instead fires a new attempt every hedgingDelay without
waiting, and the first successful response wins. Durations are strings ending in
s (e.g. "0.5s"). Exactly one of the two policies may appear per method.
Tips and notes
maxAttemptscounts the original call, so4means up to 3 retries.- Only list status codes that are safe to retry for that method’s idempotency.
- Set a non-retryable fallback by omitting
retryableStatusCodesentirely. - The total retry buffer is also bounded by the channel’s
retryThrottling.