About retries

A retry specifies the maximum number of times Gloo Gateway attempts to connect to an upstream service if the initial call fails. Retries can enhance service availability and application performance by making sure that calls don’t fail permanently because of transient problems such as a temporarily overloaded service or network.

To configure retries, you can use the following settings in the RouteOption resource:

  • options.retries.retryOn : The condition under which to retry forwarding the request to the upstream service. This setting exposes the x-envoy-retry-on Envoy header.
  • options.retries.numRetries: The number of allowed retries. The default value is 1.
  • options.retries.perTryTimeout: The timeout duration for each retry attempt. This setting expses the x-envoy-expected-rq-timeout-ms header.

Before you begin

  1. Follow the Get started guide to install Gloo Gateway, set up a gateway resource, and deploy the httpbin sample app.

  2. Get the external address of the gateway and save it in an environment variable.

Set up retries

Use a RouteOption resource to specify retries for a specific route.

  1. Create a RouteOption custom resource to specify your retry rules. In the following example, the request is retried up to 3 times when a connection failur is detected. For each retry a timeout of 5 seconds is set.

      kubectl apply -n httpbin -f- <<EOF
    apiVersion: gateway.solo.io/v1
    kind: RouteOption
      name: retry
      namespace: httpbin
          retryOn: 'connect-failure'
          numRetries: 3
          perTryTimeout: '5s'
  2. Create an HTTPRoute resource for the httpbin app that references the RouteOption resource that you created.

      kubectl apply -f- <<EOF
    apiVersion: gateway.networking.k8s.io/v1beta1
    kind: HTTPRoute
      name: httpbin-retry
      namespace: httpbin
      - name: http
        namespace: gloo-system
        - retry.example
        - filters:
            - type: ExtensionRef
                group: gateway.solo.io
                kind: RouteOption
                name: retry
            - name: httpbin
              port: 8000
  3. Send a request to the httpbin app on the retry.example domain. Verify that the request succeeds and that you see a X-Envoy-Expected-Rq-Timeout-Ms header. If the header is present, Gloo Gateway expects requests to the httpbin app to succeed within the set timeout.

    Example output for a successful response:

        "headers": {
          "Accept": [
          "Host": [
          "User-Agent": [
          "X-Envoy-Expected-Rq-Timeout-Ms": [
          "X-Forwarded-Proto": [
          "X-Request-Id": [

  4. Optional: Remove the resources that you created.

      kubectl delete httproute httpbin-retry -n httpbin
    kubectl delete routeoption retry -n httpbin