To understand the maximum concurrent requests per instance setting, read the concept document.
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.
For Cloud Run services, you can set maximum concurrent requests per instance using the Google Cloud console, the gcloud command line, or using a .yaml file when you create a new service or deploy a new revision:
Click Create Service if you are configuring a new service you are deploying to. If you are configuring an existing service, click on the service, then click Edit and Deploy New Revision.
If you are configuring a new service, fill out the initial service settings page as desired, then click Container, connections, security to expand the service configuration page.
Click the Container tab.
Set the desired maximum concurrent requests per instance value in the text box Maximum requests per container.
Click Create or Deploy.
To set maximum concurrent requests per instance, use the following command:
gcloud run services update SERVICE --concurrency CONCURRENCY
- SERVICE with the name of your service.
CONCURRENCY with the maximum number of concurrent requests per container instance. For example the following sets a maximum of 1 concurrent requests:
gcloud run services update SERVICE --concurrency 1
Changing the maximum concurrent requests per instance of a given service will capture this setting in a new revision.
To revert to the default maximum concurrent requests per instance (
80), use the command
gcloud run services update SERVICE --concurrency default
Replace SERVICE with the name of the service you are configuring.
You can download and view existing service configuration using the
gcloud run services describe --format export command, which yields
cleaned results in YAML format. You can then modify the fields described below and
upload the modified YAML using the
gcloud run services replace command.
Make sure you only modify fields as documented.
To view and download the configuration:
gcloud run services describe SERVICE --format export > service.yaml
apiVersion: serving.knative.dev/v1 kind: Service metadata: name: SERVICE spec: template: metadata: name: REVISION spec: containerConcurrency: CONCURRENCY
- SERVICE with the name of your Cloud Run service
- IMAGE_URL with a reference to the container image, for
- CONCURRENCY with the maximum number of concurrent requests per container instance.
- REVISION with a new revision name or delete it (if present). If you supply a new revision name, it must meet the following criteria:
- Starts with
- Contains only lowercase letters, numbers and
- Does not end with a
- Does not exceed 63 characters
- Starts with
Replace the service with its new configuration using the following command:
gcloud run services replace service.yaml
Add the following to a
google_cloud_run_service resource in your Terraform
80 with your
desired maximum number of concurrent requests.
# Maximum concurrent requests # https://cloud.google.com/run/docs/configuring/concurrency container_concurrency = 80
To apply your Terraform configuration in a Google Cloud project, complete the following steps:
- Launch Cloud Shell.
Set the Google Cloud project where you want to apply the Terraform configuration:
Create a directory and open a new file in that directory. The filename must have the
.tfextension, for example
mkdir DIRECTORY && cd DIRECTORY && nano main.tf
- Copy the sample into
- Review and modify the sample parameters to apply to your environment.
- Save your changes by pressing
Review the configuration and verify that the resources that Terraform is going to create or
update match your expectations:
Make corrections to the configuration as necessary.
Apply the Terraform configuration by running the following command and entering
yesat the prompt:
Wait until Terraform displays the "Apply complete!" message.
- Open your Google Cloud project to view the results. In the Google Cloud console, navigate to your resources in the UI to make sure that Terraform has created or updated them.
View concurrency settings
To view the current concurrency settings for your Cloud Run service:
Click the service you are interested in to open the Service details page.
Click the Revisions tab.
In the details panel at the right, the concurrency setting is listed under the Container tab.
Use the following command:
gcloud run services describe SERVICE
Locate the concurrency setting in the returned configuration.