Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Auf dieser Seite wird beschrieben, wie Sie die Anzahl der zu verwendenden CPUs für jede Cloud Run-Instanz angeben. Cloud Run-Containerinstanzen sind standardmäßig auf eine CPU beschränkt. Sie können diesen Wert wie auf dieser Seite beschrieben erhöhen oder verringern.
CPU-Limits festlegen und aktualisieren
Standardmäßig ist jede Instanz auf 1 CPU beschränkt.
Sie können diesen Wert mit einem beliebigen Ganzzahlwert bis zu maximal acht CPUs erhöhen.
CPU und Arbeitsspeicher
Im Folgenden sind die Mindestspeicheranforderungen für CPUs aufgeführt:
CPUs
Mindestspeicher
4
2 GiB
6
4 GiB
8
4 GiB
Erforderliche Rollen
Bitten Sie Ihren Administrator, Ihnen die folgenden IAM-Rollen zu gewähren, um die zum Konfigurieren von Cloud Run-Jobs erforderlichen Berechtigungen zu erhalten:
Klicken Sie auf Container bereitstellen und wählen Sie Job aus, um die Seite mit den anfänglichen Jobeinstellungen auszufüllen. Wählen Sie den Job aus und klicken Sie dann auf Bearbeiten, wenn Sie einen vorhandenen Job konfigurieren.
Klicken Sie auf Container, Variablen und Secrets, Verbindungen, Sicherheit, um die Seite mit den Jobattributen zu maximieren.
Klicken Sie auf den Tab Allgemein.
Wählen Sie das gewünschte CPU-Limit aus der Drop-down-Liste aus. Wählen Sie einen Wert von 1, 2, 4, 6 oder 8 CPUs aus. Für Jobs ist mindestens 1 CPU erforderlich. Die erforderlichen Einstellungen finden Sie in der Tabelle unter CPU-Limits festlegen und aktualisieren.
CPU durch das gewünschte CPU-Limit Geben Sie den Wert 1, 2, 4, 6 oder 8 CPUs an. Für Jobs ist mindestens 1 CPU erforderlich. Die erforderlichen Einstellungen finden Sie in der Tabelle unter CPU-Limits festlegen und aktualisieren.
Sie können die CPU auch festlegen, wenn Sie einen Job erstellen, indem Sie den folgenden Befehl verwenden:
IMAGE_URL durch einen Verweis auf das Container-Image, z. B. us-docker.pkg.dev/cloudrun/container/job:latest.
CPU durch das gewünschte CPU-Limit Geben Sie den Wert 1, 2, 4, 6 oder 8 CPUs an. Für Jobs ist mindestens 1 CPU erforderlich. Die erforderlichen Einstellungen finden Sie in der Tabelle unter CPU-Limits festlegen und aktualisieren.
YAML
Wenn Sie einen neuen Job erstellen, überspringen Sie diesen Schritt.
Wenn Sie einen vorhandenen Job aktualisieren, laden Sie die zugehörige YAML-Konfiguration herunter:
Ersetzen Sie CPU durch das gewünschte CPU-Limit. Geben Sie den Wert 1, 2, 4, 6 oder 8 CPUs an. Für Jobs ist mindestens 1 CPU erforderlich. Die erforderlichen Einstellungen finden Sie in der Tabelle unter CPU-Limits festlegen und aktualisieren.
Sie können auch weitere Konfigurationen angeben, z. B. Umgebungsvariablen oder Speicherlimits.
Aktualisieren Sie die vorhandene Jobkonfiguration:
gcloudrunjobsreplacejob.yaml
CPU-Einstellungen aufrufen
So rufen Sie die aktuellen CPU-Einstellungen für Ihren Cloud Run-Job auf:
Console
Wechseln Sie in der Google Cloud Console zur Seite "Cloud Run-Jobs":
[[["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: 2024-12-05 (UTC)."],[],[],null,["# Configure CPU limits for jobs\n\nThis page describes how to specify the number of CPUs to use for each\nCloud Run instance. By default, Cloud Run container instances\nare limited to 1 CPU. You can increase or decrease this\nvalue as described in this page.\n\n\u003cbr /\u003e\n\nSet and update CPU limits\n-------------------------\n\nBy default, each instance is limited to 1 CPU.\nYou can change this to any of the values shown in the following table.\n\n### CPU and memory table\n\nThe following are minimum memory requirements for CPUs:\n\n\u003cbr /\u003e\n\nRequired roles\n--------------\n\n\nTo get the permissions that\nyou need to configure Cloud Run jobs,\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 job\n- [Service Account User](/iam/docs/roles-permissions/iam#iam.serviceAccountUser) (`roles/iam.serviceAccountUser`) on the service identity\n\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 job interfaces with\nGoogle Cloud APIs, such as Cloud Client Libraries, see the\n[service identity configuration guide](/run/docs/configuring/jobs/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 CPU limits\n--------------------\n\nYou must set a minimum of 1 CPU for a Cloud Run job.\n\nTo specify CPU for a Cloud Run job: \n\n### Console\n\n\n1. In the Google Cloud console, go to the Cloud Run jobs page:\n\n [Go to Cloud Run](https://console.cloud.google.com/run)\n2. Select **Jobs** from the menu, and click **Deploy container** to fill out\n the initial job settings page. If you are configuring an existing job,\n select the job, then click **Edit**.\n\n3. Click **Container(s), Volumes, Connections, Security** to expand the job properties page.\n\n4. Click the **General** tab.\n\n - Select the desired CPU limit from the dropdown list. Select a value of `1`, `2`, `4`, `6`, or `8` CPUs. Jobs require a minimum of 1 CPU. (See the table under [Setting and updating CPU limits](#setting) for required settings.)\n5. Click **Create** or **Update**.\n\n### gcloud\n\n1. [Update the CPU limits](/sdk/gcloud/reference/run/jobs/update)\n of a given job by using the following command:\n\n ```bash\n gcloud run jobs update JOB_NAME --cpu CPU\n ```\n\n Replace\n - \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e with the name of your job\n - \u003cvar translate=\"no\"\u003eCPU\u003c/var\u003e with the desired CPU limit. Specify the value `1`, `2`, `4`, `6`, or `8` CPUs. Jobs require a minimum of 1 CPU. (See the table under [Setting and updating CPU limits](#setting) for required settings.)\n\n You can also set CPU when you\n [create a job](/sdk/gcloud/reference/run/jobs/create) using the command: \n\n ```bash\n gcloud run jobs create JOB_NAME --image IMAGE_URL --cpu CPU\n ```\n\n Replace\n - \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e with the name of your job.\n - \u003cvar translate=\"no\"\u003eIMAGE_URL\u003c/var\u003e: a reference to the [container image](/run/docs/building/containers)---for example, `us-docker.pkg.dev/cloudrun/container/job:latest`.\n - \u003cvar translate=\"no\"\u003eCPU\u003c/var\u003e with the desired CPU limit. Specify the value `1`, `2`, `4`, `6`, or `8` CPUs. Jobs require a minimum of 1 CPU. (See the table under [Setting and updating CPU limits](#setting) for required settings.)\n\n### YAML\n\n1. If you are creating a new job, skip this step.\n If you are updating an existing job, download its [YAML configuration](/run/docs/reference/yaml/v1#job):\n\n ```bash\n gcloud run jobs describe JOB_NAME --format export \u003e job.yaml\n ```\n2. Update the `cpu` attribute:\n\n ```yaml\n apiVersion: run.googleapis.com/v1\n kind: Job\n metadata:\n name: JOB\n spec:\n template:\n spec:\n template:\n spec:\n containers:\n - image: IMAGE\n resources:\n limits:\n cpu: CPU\u003cvar translate=\"no\"\u003e\u003c/var\u003e\n ```\n\n Replace \u003cvar translate=\"no\"\u003eCPU\u003c/var\u003e with the desired CPU limit. Specify the value\n `1`, `2`, `4`, `6`, or `8`\n CPUs. Jobs require a minimum of 1 CPU. (See the table under\n [Setting and updating CPU limits](#setting) for required settings.)\n\n You can also specify more configuration such as environment variables or\n memory limits.\n3. Update the existing job configuration:\n\n ```bash\n gcloud run jobs replace job.yaml\n ```\n\n### Terraform\n\n\u003cbr /\u003e\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_job`](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_run_v2_job) resource in your Terraform configuration: \n\n\u003cbr /\u003e\n\n resource \"google_cloud_run_v2_job\" \"default\" {\n name = \"cloudrun-job\"\n location = \"\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e\"\n deletion_protection = false\n\n template {\n template {\n containers {\n image = \"us-docker.pkg.dev/cloudrun/container/job\"\n resources {\n limits = {\n cpu = \"\u003cvar translate=\"no\"\u003eCPU\u003c/var\u003e\"\n }\n }\n }\n }\n }\n }\n\nReplace:\n\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e with the Google Cloud region. For example, `europe-west1`.\n- \u003cvar translate=\"no\"\u003eCPU\u003c/var\u003e with your service's required memory limit. Specify the value `1`, `2`, `4`, `6`, or `8` CPUs. Jobs require a minimum of 1 CPU. (See the table under [Setting and updating CPU limits](#setting) for required settings.)\n\nView CPU settings\n-----------------\n\nTo view the current CPU settings for your\nCloud Run job: \n\n### Console\n\n1. In the Google Cloud console, go to the Cloud Run jobs page:\n\n [Go to Cloud Run jobs](https://console.cloud.google.com/run/jobs)\n2. Click the job you are interested in to open the **Job details** page.\n\n3. Click **View and Edit job configuration**.\n\n4. Locate the CPU setting in the configuration\n details.\n\n### gcloud\n\n1. Use the following command:\n\n ```bash\n gcloud run jobs describe JOB_NAME\n ```\n2. Locate the CPU setting in the returned\n configuration."]]