A timeout is the amount of time (duration) that Gloo Gateway waits for replies from an upstream service before the service is considered unavailable. This setting can be useful to avoid your apps from hanging or fail if no response is returned in a specific timeframe. With timeouts, calls either succeed or fail within a predicatble timeframe.

The time an app needs to process a request can vary a lot which is why applying the same timeout across services can cause a variety of issues. For example, a timeout that is too long can result in excessive latency from waiting for replies from failing services. On the other hand, a timeout that is too short can result in calls failing unnecessarily while waiting for an operation that needs responses from multiple services.

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 timeouts

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

  1. Create a RouteOption custom resource to specify your timeout rules. In the following example, the request must be completed within 20 seconds.

      kubectl apply -n httpbin -f- <<EOF
    apiVersion: gateway.solo.io/v1
    kind: RouteOption
      name: timeout
      namespace: httpbin
        timeout: '20s'
  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-timeout
      namespace: httpbin
      - name: http
        namespace: gloo-system
        - timeout.example
        - filters:
            - type: ExtensionRef
                group: gateway.solo.io
                kind: RouteOption
                name: timeout
            - name: httpbin
              port: 8000
  3. Send a request to the httpbin app on the timout.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-timeout -n httpbin
    kubectl delete routeoption timeout -n httpbin