# retry\_policy

## Summary

A retry policy is a way for the Grey Matter Sidecar or Edge to automatically retry a failed request on behalf of the client. This is mostly transparent to the client; they will only get the status and return of the final request attempted (failed or succeeded). The only effects they should see from a successful retry is a longer average request time and fewer failures.

### Example object

```javascript
{
  "num_retries": 2,
  "per_try_timeout_msec": 60000,
  "timeout_msec": 60000
}
```

### Fields

#### `num_retries`

This is the max number of retries attempted. Setting this field to N will cause up to N retries to be attempted before returning a result to the user.

Setting to 0 means only the original request will be sent and no retries are attempted. A value of 1 means the original request plus up to 1 retry will be sent, resulting in potentially 2 total requests to the server. A value of N will result in up to N+1 total requests going to the service.

#### `per_try_timeout_msec`

This is the timeout for each retry. The retry attempts can have longer or shorter timeouts than the original request. However, if the `per_try_timeout_msec` is too long, it is possible that not all retries will be attempted as it would violate the [timeout\_msec](#timeoutmsec) field.

#### `timeout_msec`

This is the total timeout for the entire chain: initial request + all timeouts. This should typically be set large enough to accommodate the request and all retries desired.

#### `retry_on`

A comma delimited list of conditions for the retry policy to be executed on. See [Envoy docs](https://www.envoyproxy.io/docs/envoy/v1.16.4/configuration/http/http_filters/router_filter#config-http-filters-router-x-envoy-retry-on) for a full list of options. If no retry policy is defined, the default value is `"connect-failure, refused-stream, gateway-error"`.
