Maximale Anzahl gleichzeitiger Anfragen pro Instanz festlegen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Um die Einstellung für die maximale Anzahl gleichzeitiger Anfragen pro Instanz zu verstehen, lesen Sie das Konzeptdokument.
Erforderliche Rollen
Bitten Sie Ihren Administrator, Ihnen die folgenden IAM-Rollen zuzuweisen, um die Berechtigungen zu erhalten, die Sie zum Konfigurieren und Bereitstellen von Cloud Run-Diensten benötigen:
Dienstkontonutzer (roles/iam.serviceAccountUser)
für die Dienstidentität
Wenn Sie einen Dienst oder eine Funktion aus Quellcode bereitstellen, müssen Sie auch zusätzliche Rollen für Ihr Projekt und Ihr Cloud Build-Dienstkonto haben.
Maximale Anzahl gleichzeitiger Anfragen pro Instanz konfigurieren
Jede Konfigurationsänderung führt zur Erstellung einer neuen Überarbeitung. Für nachfolgende Überarbeitungen gilt automatisch dieselbe Konfigurationseinstellung, sofern Sie sie nicht explizit aktualisieren.
Für Cloud Run-Dienste können Sie die maximale Anzahl gleichzeitiger Anfragen pro Instanz über die Google Cloud Console, die gcloud-Befehlszeile oder über eine YAML-Datei festlegen, wenn Sie einen neuen Dienst erstellen oder eine neue Revision bereitstellen:
Konsole
Rufen Sie in der Google Cloud Console Cloud Run auf:
Wählen Sie im Menü Dienste aus und klicken Sie auf Container bereitstellen, um einen neuen Dienst zu konfigurieren.
Wenn Sie einen vorhandenen Dienst konfigurieren möchten, klicken Sie auf den Dienst und dann auf Neue Überarbeitung bearbeiten und bereitstellen.
Wenn Sie einen neuen Dienst konfigurieren, füllen Sie die Seite mit den anfänglichen Diensteinstellungen aus und klicken Sie dann auf Container, Volumes, Netzwerk, Sicherheit, um die Seite zur Dienstkonfiguration zu maximieren.
Klicken Sie auf den Tab Container.
Sie können den gewünschten Maximalwert für gleichzeitige Anfragen pro Instanz im Textfeld Maximale Anfragen pro Container festlegen:
Klicken Sie auf Erstellen oder Bereitstellen.
gcloud
Mit dem folgenden Befehl legen Sie die maximale Anzahl gleichzeitiger Anfragen pro Instanz fest:
CONCURRENCY: Die maximale Anzahl gleichzeitiger Anfragen pro Instanz. Im Folgenden wird beispielsweise ein Maximum von 1 gleichzeitigen Anfrage festgelegt:
gcloudrunservicesupdateSERVICE--concurrency1
Wenn Sie die maximale Anzahl gleichzeitiger Anfragen pro Instanz eines bestimmten Dienstes ändern, wird diese Einstellung auch für neue Überarbeitungen übernommen.
Mit dem folgenden Befehl können Sie zur Standardeinstellung für die maximale Anzahl gleichzeitiger Anfragen pro Instanz (80) zurückkehren:
Ersetzen Sie SERVICE durch den Namen des Dienstes, den Sie konfigurieren möchten.
YAML
Wenn Sie einen neuen Dienst erstellen, überspringen Sie diesen Schritt.
Wenn Sie einen vorhandenen Dienst aktualisieren, laden Sie die zugehörige YAML-Konfiguration herunter:
IMAGE_URL: ein Verweis auf das Container-Image, z. B. us-docker.pkg.dev/cloudrun/container/hello:latest Wenn Sie Artifact Registry verwenden, muss das RepositoryREPO_NAME bereits erstellt sein. Die URL hat das Format LOCATION-docker.pkg.dev/PROJECT_ID/REPO_NAME/PATH:TAG.
CONCURRENCY: Die maximale Anzahl gleichzeitiger Anfragen pro Instanz.
REVISION durch einen neuen Überarbeitungsnamen oder löschen (falls vorhanden). Wenn Sie einen neuen Überarbeitungsnamen angeben, muss er die folgenden Kriterien erfüllen:
Beginnt mit SERVICE-
Enthält nur Kleinbuchstaben, Ziffern und -
Endet nicht mit -
Darf nicht mehr als 63 Zeichen enthalten
Erstellen oder aktualisieren Sie den Dienst mit dem folgenden Befehl:
gcloudrunservicesreplaceservice.yaml
Terraform
Informationen zum Anwenden oder Entfernen einer Terraform-Konfiguration finden Sie unter Grundlegende Terraform-Befehle.
resource"google_cloud_run_v2_service""default"{name="cloudrun-service-concurrency"location="us-central1"deletion_protection=false # set to "true" in productiontemplate{containers{image="us-docker.pkg.dev/cloudrun/container/hello"} # Maximum concurrent requestsmax_instance_request_concurrency=80}}
Ersetzen Sie 80 durch die gewünschte maximale Anzahl gleichzeitiger Anfragen.
Gleichzeitigkeitseinstellungen anzeigen
So rufen Sie die aktuellen Gleichzeitigkeitseinstellungen für Ihren Cloud Run-Dienst auf:
Konsole
Rufen Sie in der Google Cloud Console Cloud Run auf:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[],[],null,["# Set maximum concurrent requests per instance\n\nTo understand the maximum concurrent requests per instance setting, read the\n[concept document](/run/docs/about-concurrency).\n\nRequired roles\n--------------\n\n\nTo get the permissions that\nyou need to configure and deploy Cloud Run services,\n\nask your administrator to grant you the\nfollowing IAM roles:\n\n- [Cloud Run Developer](/iam/docs/roles-permissions/run#run.developer) (`roles/run.developer`) on the Cloud Run service\n- [Service Account User](/iam/docs/roles-permissions/iam#iam.serviceAccountUser) (`roles/iam.serviceAccountUser`) on the service identity\n\n\nIf you are deploying a [service](/run/docs/deploying-source-code#required_roles)\nor [function](/run/docs/deploy-functions#required-roles) from source code, you\nmust also have additional roles granted to you on your project and\nCloud Build service account.\n\nFor a list of IAM roles and permissions that are associated with\nCloud Run, see\n[Cloud Run IAM roles](/run/docs/reference/iam/roles)\nand [Cloud Run IAM permissions](/run/docs/reference/iam/permissions).\nIf your Cloud Run service interfaces with\nGoogle Cloud APIs, such as Cloud Client Libraries, see the\n[service identity configuration guide](/run/docs/configuring/services/service-identity).\nFor more information about granting roles, see\n[deployment permissions](/run/docs/reference/iam/roles#additional-configuration)\nand [manage access](/iam/docs/granting-changing-revoking-access).\n\nConfigure maximum concurrent requests per instance\n--------------------------------------------------\n\nAny configuration change leads to the\ncreation of a new revision. Subsequent revisions will also automatically get\nthis configuration setting unless you make explicit updates to change it.\n\nFor Cloud Run services, you can set maximum concurrent requests\nper instance using the Google Cloud console, the\ngcloud command line, or using a .yaml file when you\n[create a new service](/run/docs/deploying#service) or\n[deploy a new revision](/run/docs/deploying#revision): \n\n### Console\n\n\n1. In the Google Cloud console, go to Cloud Run:\n\n [Go to Cloud Run](https://console.cloud.google.com/run)\n2. Select **Services** from the menu, and click **Deploy container** to\n configure a new service.\n If you are configuring an existing service, click the\n service, then click **Edit and deploy new revision**.\n\n3. If you are configuring a new service, fill out the initial service\n settings page, then click **Container(s), Volumes, Networking, Security** to expand the\n service configuration page.\n\n4. Click the **Container** tab.\n\n - Set the desired maximum concurrent requests per instance value in the text box *Maximum requests per container*.\n5. Click **Create** or **Deploy**.\n\n### gcloud\n\nTo set maximum concurrent requests per instance, use the following command:\n\n\u003cbr /\u003e\n\n```bash\ngcloud run services update SERVICE --concurrency CONCURRENCY\n```\n\n\u003cbr /\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e: the name of your service.\n- \u003cvar translate=\"no\"\u003eCONCURRENCY\u003c/var\u003e: the maximum number of concurrent requests per\n instance. For example, the following sets a maximum of 1\n concurrent requests:\n\n ```bash\n gcloud run services update SERVICE --concurrency 1\n ```\n\nChanging the maximum concurrent requests per instance of a given service will capture this setting in a\nnew revision.\n\nTo revert to the default maximum concurrent requests per instance (`80`), use the command\n\n\u003cbr /\u003e\n\n```bash\ngcloud run services update SERVICE --concurrency default\n```\n\n\u003cbr /\u003e\n\nReplace \u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e with the name of the service you are configuring.\n\n### YAML\n\n1. If you are creating a new service, skip this step.\n If you are updating an existing service, download its [YAML configuration](/run/docs/reference/yaml/v1):\n\n ```bash\n gcloud run services describe SERVICE --format export \u003e service.yaml\n ```\n2. Update the `containerConcurrency` attribute:\n\n ```yaml\n apiVersion: serving.knative.dev/v1\n kind: Service\n metadata:\n name: SERVICE\n spec:\n template:\n metadata:\n name: REVISION\n spec:\n containerConcurrency: CONCURRENCY\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e: the name of your Cloud Run service\n - \u003cvar translate=\"no\"\u003eIMAGE_URL\u003c/var\u003e: a reference to the container image, for example, `us-docker.pkg.dev/cloudrun/container/hello:latest`. If you use Artifact Registry, the [repository](/artifact-registry/docs/repositories/create-repos#docker) \u003cvar translate=\"no\"\u003eREPO_NAME\u003c/var\u003e must already be created. The URL follows the format of \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e`-docker.pkg.dev/`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`/`\u003cvar translate=\"no\"\u003eREPO_NAME\u003c/var\u003e`/`\u003cvar translate=\"no\"\u003ePATH\u003c/var\u003e`:`\u003cvar translate=\"no\"\u003eTAG\u003c/var\u003e .\n - \u003cvar translate=\"no\"\u003eCONCURRENCY\u003c/var\u003e: the maximum number of concurrent requests per instance.\n - \u003cvar translate=\"no\"\u003eREVISION\u003c/var\u003e with a new revision name or delete it (if present). If you supply a new revision name, it **must** meet the following criteria:\n - Starts with \u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e`-`\n - Contains only lowercase letters, numbers and `-`\n - Does not end with a `-`\n - Does not exceed 63 characters\n3. Create or update the service using the following command:\n\n ```bash\n gcloud run services replace service.yaml\n ```\n\n### Terraform\n\n\nTo learn how to apply or remove a Terraform configuration, see\n[Basic Terraform commands](/docs/terraform/basic-commands).\nAdd the following to a [`google_cloud_run_v2_service`](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_run_v2_service) resource in your Terraform configuration: \n\n\u003cbr /\u003e\n\n resource \"google_cloud_run_v2_service\" \"default\" {\n name = \"cloudrun-service-concurrency\"\n location = \"us-central1\"\n\n deletion_protection = false # set to \"true\" in production\n\n template {\n containers {\n image = \"us-docker.pkg.dev/cloudrun/container/hello\"\n }\n # Maximum concurrent requests\n max_instance_request_concurrency = 80\n }\n }\n\nReplace `80` with your desired maximum number of concurrent requests.\n\nView concurrency settings\n-------------------------\n\nTo view the current concurrency settings for your\nCloud Run service: \n\n### Console\n\n1. In the Google Cloud console, go to Cloud Run:\n\n [Go to Cloud Run](https://console.cloud.google.com/run)\n2. Click the service you are interested in to open the **Service details**\n page.\n\n3. Click the **Revisions** tab.\n\n4. In the details panel at the right, the concurrency setting\n is listed under the **Container** tab.\n\n### gcloud\n\n1. Use the following command:\n\n ```bash\n gcloud run services describe SERVICE\n ```\n2. Locate the concurrency setting in the returned\n configuration."]]