diff --git a/alb/guides/request-timeout.mdx b/alb/guides/request-timeout.mdx new file mode 100644 index 0000000..b6d5d56 --- /dev/null +++ b/alb/guides/request-timeout.mdx @@ -0,0 +1,277 @@ +--- +title: "Raise the Request Timeout for an HTTPProxy" +description: "Stop large downloads, streams, and slow API responses from being cut off after about 15 seconds by raising an HTTPProxy's request timeout to as much as 1 hour with datumctl and an Envoy Gateway BackendTrafficPolicy." +--- + +This guide describes how to **raise the request timeout** for an application behind a Datum **`HTTPProxy`**, from the default of about 15 seconds up to a maximum of **1 hour**, using `datumctl`. The configuration uses an **Envoy Gateway `BackendTrafficPolicy`** resource and applies to **Windows, macOS, and Linux**. + +--- + +## Overview + +By default, Datum's edge gives every request about **15 seconds** to finish. The clock starts when the request arrives and covers the whole response, not just the wait for it to begin. If your origin is still sending when time runs out, Datum ends the response. + +You likely need this guide if you see any of the following: + +- **Large downloads stop partway through.** The file is cut off after about 15 seconds. `curl` reports: + + ``` + curl: (18) transfer closed with bytes remaining to read + ``` + +- **Streaming responses stop after about 15 seconds.** Server-sent events, log tails, long polling, and similar connections that stay open close without warning. +- **Slow requests fail with a `504`.** If your origin takes more than about 15 seconds to start answering, the request returns `504 Gateway Timeout` with a page that mentions `response_timeout`. + +`HTTPProxy` has no timeout setting of its own. Instead, you attach a `BackendTrafficPolicy` to the route that Datum creates for your `HTTPProxy`, and set the timeout there. + +At a high level, this setup: + +1. Finds the name of your `HTTPProxy`, which is also the name of the route to target +2. Applies a **`BackendTrafficPolicy`** that sets `timeout.http.requestTimeout` +3. Confirms the policy was accepted +4. Verifies that a long response now completes + +--- + +## Prerequisites + +- `datumctl` installed and authenticated +- A valid **Project** +- An existing **`HTTPProxy`** +- Permission to create: + - `BackendTrafficPolicy` + +Verify access and find your `HTTPProxy` name: + +```bash +datumctl get httpproxy --project --namespace default +``` + +--- + +## Critical Requirement: Target the Route with Your HTTPProxy's Name + +Datum creates an `HTTPRoute` for every `HTTPProxy`, and gives it **the same name as the `HTTPProxy`**. The policy must target that `HTTPRoute`, not the `HTTPProxy` itself. + +### Why This Matters + +- A `BackendTrafficPolicy` can only attach to Gateway API resources such as an `HTTPRoute`. It cannot target an `HTTPProxy` directly +- If `targetRefs` names a route that doesn't exist, the policy is stored but never takes effect, and your responses are still cut off at about 15 seconds + +You can confirm the route exists: + +```bash +datumctl get httproute --project --namespace default +``` + +--- + +## Configuration Steps + +### Step 1: Set Variables + +Set `timeout` to the longest you expect a single response to take, up to `1h`. Use a value like `90s`, `10m`, or `1h`. + +#### Windows (PowerShell) + +```powershell +$project = "your-project-id" +$namespace = "default" +$proxy = "your-httpproxy-name" +$hostname = "your-app.example.com" +$timeout = "1h" +``` + +#### macOS / Linux + +```bash +project="your-project-id" +namespace="default" +proxy="your-httpproxy-name" +hostname="your-app.example.com" +timeout="1h" +``` + +--- + +### Step 2: Apply the BackendTrafficPolicy + +> **Note:** Datum caps the request timeout at **1 hour**. A value higher than `1h` is rejected when you apply it. + +> **Warning:** Only one `BackendTrafficPolicy` can attach to a route. If your route already has one (for example, from the [Load Balancer Failover](/alb/guides/load-balancer-failover) guide), add the `timeout` block to that policy instead of creating a second one. A second policy targeting the same route reports `Accepted: False` with reason `Conflicted` and has no effect. + +#### Windows (PowerShell) + +```powershell +@" +apiVersion: gateway.envoyproxy.io/v1alpha1 +kind: BackendTrafficPolicy +metadata: + name: ${proxy}-timeout +spec: + targetRefs: + - group: gateway.networking.k8s.io + kind: HTTPRoute + name: $proxy + timeout: + http: + requestTimeout: $timeout +"@ | datumctl apply --project $project --namespace $namespace -f - +``` + +#### macOS / Linux + +```bash +cat <-timeout`) so it's easy to find and clean up + +--- + +## Summary + +- Datum's edge ends every response about 15 seconds after the request arrives unless you raise the timeout +- `HTTPProxy` has no timeout field. Set `timeout.http.requestTimeout` in a `BackendTrafficPolicy` instead +- The policy targets the `HTTPRoute` that has the same name as your `HTTPProxy` +- The maximum is `1h`, measured over the whole response, including streams +- Only one `BackendTrafficPolicy` can attach to a route, so add the timeout to an existing policy if there is one diff --git a/docs.json b/docs.json index e9f1fd8..924f671 100644 --- a/docs.json +++ b/docs.json @@ -118,7 +118,8 @@ "alb/guides/basic-auth", "alb/guides/oidc-google", "alb/guides/oidc-auth0", - "alb/guides/load-balancer-failover" + "alb/guides/load-balancer-failover", + "alb/guides/request-timeout" ] } ]