Learn how to set the time within which a response for a request must be returned
by your Knative serving services. If a response isn't returned within the
time specified, the request ends and error 504
is returned.
Timeout limits
The maximum timeout limit differs based on the version of your GKE cluster .
| GKE version | Default limit | Maximum timeout limit |
|---|---|---|
|
0.16.0-gke.1 and later
|
300 seconds | 24 hours |
|
0.15.0-gke.3 and earlier
|
300 seconds | 900 seconds |
In addition to changing the Knative serving request timeout, you should check your language framework to see whether it has its own request timeout setting that you must also update.
Setting and updating request timeout
Any configuration change leads to the creation of a new revision. Subsequent revisions will also automatically get this configuration setting unless you make explicit updates to change it.
You can set request timeout using the Google Cloud console, the Google Cloud CLI, or a YAML file when you deploy a new service or update an existing service and deploy a revision :
Console
-
Go to Knative serving in the Google Cloud console:
-
Click Create Serviceif you are configuring a new service you are deploying to. If you are configuring an existing service, click on the service, then click Edit & Deploy New Revision.
-
Under Advanced settings , click Container.

-
In the Request timeout field, enter the timeout value that you want to use. The value you specify must be less than the timeout limit for the cluster's GKE version.
-
Click Nextto continue to the next section.
-
In the Configure how this service is triggeredsection, select which connectivity you would like to use to invoke the service.
-
Click Createto deploy the image to Knative serving and wait for the deployment to finish.
Command line
-
For existing services, set the request timeout by running the
gcloud run services updatecommand with the--timeoutparameter:gcloud run services update SERVICE --timeout TIMEOUT
Replace:
- SERVICE with the name of your service.
- TIMEOUT
with the desired time, using an integer
value in seconds, or an absolute duration value
,
for example
1m20swhich is 1 minute, 20 seconds. The value you specify must be less than the timeout limit for the cluster's GKE version. Specify0to set the timeout to the default value .
-
For new services, set the request timeout by running the
gcloud run deploycommand with the--timeoutparameter:gcloud run deploy SERVICE --image = IMAGE_URL --timeout TIMEOUT
Replace:
- SERVICE with the name of your service.
- IMAGE_URL
with a reference to the container image, for
example,
gcr.io/myproject/my-image:latest. - TIMEOUT
with the desired time, using an integer
value in seconds, or an absolute duration value
,
for example
1m20swhich is 1 minute, 20 seconds. The value you specify must be less than the timeout limit for the cluster's GKE version. Specify0to set the timeout to the default value .
YAML
You can download the configuration of an existing service into a
YAML file with the gcloud run services describe
command by using the --format=export
flag.
You can then modify that YAML file and deploy
those changes with the gcloud beta run services replace
command.
You must ensure that you modify only the specified attributes.
-
Download the configuration of your service into a file named
service.yamlon local workspace:gcloud run services describe SERVICE --format export > service.yaml
Replace SERVICE with the name of your Knative serving service.
-
In your local file, update the
timeoutSecondsattribute:apiVersion : serving.knative.dev/v1 kind : Service metadata : name : SERVICE spec : template : spec : containers : - image : IMAGE timeoutSeconds : TIMEOUT
Replace:
- SERVICE with the name of your Knative serving service
- IMAGE_URL
with a reference to the container image, for
example,
gcr.io/myproject/my-image:latest. - TIMEOUT with the desired timeout, in seconds.
-
Replace the service with its new configuration using the following command:
gcloud beta run services replace service.yaml

