Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Pelajari cara menetapkan jumlah maksimum permintaan yang dapat diproses
secara bersamaan oleh instance container tertentu dalam penayangan Knative.
Pelajari konkurensi lebih lanjut.
Setiap perubahan konfigurasi akan
menghasilkan revisi baru. Revisi selanjutnya juga akan otomatis mendapatkan
setelan konfigurasi ini, kecuali jika Anda melakukan pembaruan eksplisit untuk mengubahnya.
Anda dapat mengonfigurasi setelan serentak menggunakan konsol Google Cloud , atau Google Cloud CLI saat men-deploy layanan baru atau mengupdate layanan yang ada dan men-deploy revisi:
Klik Buat Layanan jika Anda mengonfigurasi
layanan baru yang akan di-deploy. Jika Anda mengonfigurasi
layanan yang sudah ada, klik layanan tersebut, lalu klik
Edit & Deploy New Revision.
Di bagian Setelan lanjutan, klik Penampung.
Tetapkan nilai konkurensi yang diinginkan di kotak teks Permintaan maksimum per penampung.
Klik Berikutnya untuk melanjutkan ke bagian berikutnya.
Di bagian Configure how this service is triggered,
pilih konektivitas yang ingin Anda gunakan untuk memanggil layanan.
Klik Create untuk men-deploy image ke layanan Knative dan tunggu deployment selesai.
Command line
Untuk layanan yang ada, tetapkan jumlah maksimum permintaan serentak dengan
menjalankan perintah gcloud run services update dengan parameter
--concurrency:
CONCURRENCY dengan jumlah maksimum
permintaan serentak per instance container. Tentukan default untuk menghapus
setelan konkurensi apa pun: --concurrency default.
Untuk layanan baru, tetapkan jumlah maksimum permintaan serentak dengan menjalankan perintah gcloud run deploy dengan parameter --concurrency:
IMAGE_URL dengan referensi ke image container,
misalnya, gcr.io/cloudrun/hello.
CONCURRENCY dengan jumlah maksimum
permintaan serentak per instance container. Tentukan default untuk menghapus
setelan konkurensi apa pun: --concurrency default.
YAML
Anda dapat mendownload konfigurasi layanan yang ada ke dalam
file YAML dengan perintah gcloud run services describe menggunakan
tanda --format=export.
Kemudian, Anda dapat mengubah file YAML tersebut dan men-deploy
perubahan tersebut dengan perintah gcloud run services replace.
Anda harus memastikan bahwa Anda hanya mengubah atribut yang ditentukan.
Download konfigurasi layanan Anda ke dalam file bernama
service.yaml di ruang kerja lokal:
SERVICE dengan nama layanan penayangan Knative Anda
CONCURRENCY dengan jumlah maksimum permintaan serentak
per instance container. Tentukan default untuk menghapus
setelan konkurensi: --concurrency default.
Ganti layanan dengan konfigurasi barunya menggunakan perintah berikut:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-31 UTC."],[],[],null,["# Setting concurrency\n\nLearn how to set the maximum number of requests that can be processed\nsimultaneously by a given container instance in Knative serving.\n[Learn more about concurrency](/kubernetes-engine/enterprise/knative-serving/docs/concurrency).\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\nYou can configure concurrency settings using the Google Cloud console,\nor the Google Cloud CLI when you deploy a new\n[service](/kubernetes-engine/enterprise/knative-serving/docs/deploying#service) or update an existing service and\ndeploy a [revision](/kubernetes-engine/enterprise/knative-serving/docs/deploying#revision): \n\n### Console\n\n\n1. Go to Knative serving in the Google Cloud console:\n\n [Go to Knative serving](https://console.cloud.google.com/kubernetes/run)\n2. Click **Create Service** if you are configuring a\n new service you are deploying to. If you are configuring an\n existing service, click on the service, then click\n **Edit \\& Deploy New Revision**.\n\n3. Under *Advanced settings* , click **Container**.\n\n4. Set the desired concurrency value in the text box *Maximum requests per container*.\n\n5. Click **Next** to continue to the next section.\n\n6. In the **Configure how this service is triggered** section,\n select which connectivity you would like to use to invoke the service.\n\n7. Click **Create** to deploy the image to Knative serving and wait\n for the deployment to finish.\n\n### Command line\n\n- For existing services, set the maximum number of concurrent requests by\n running the `gcloud run services update` command with the\n [`--concurrency`](/sdk/gcloud/reference/run/services/update#--concurrency)\n parameter:\n\n ```bash\n gcloud run services update SERVICE --concurrency CONCURRENCY\n ```\n\n Replace:\n - \u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e with the name of your service.\n - \u003cvar translate=\"no\"\u003eCONCURRENCY\u003c/var\u003e with the maximum number of concurrent requests per container instance. Specify `default` to clear any concurrency settings: `--concurrency default`.\n- For new services, set the maximum number of concurrent requests by running\n the `gcloud run deploy` command with the\n [`--concurrency`](/sdk/gcloud/reference/run/deploy#--concurrency)\n parameter:\n\n ```bash\n gcloud run deploy SERVICE --image=IMAGE_URL --concurrency CONCURRENCY\n ```\n\n Replace:\n - \u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e with the name of your service.\n - \u003cvar translate=\"no\"\u003eIMAGE_URL\u003c/var\u003e with a reference to the container image, for example, `gcr.io/cloudrun/hello`.\n - \u003cvar translate=\"no\"\u003eCONCURRENCY\u003c/var\u003e with the maximum number of concurrent requests per container instance. Specify `default` to clear any concurrency settings: `--concurrency default`.\n\n### YAML\n\n| **Caution:** Deploying configuration changes using YAML files replaces the configuration of your existing services. Since a YAML file completely overwrites all configurations, you should avoid using multiple methods to modify your services. For example, do not use YAML files in conjunction with the Google Cloud console or `gcloud` commands.\n\nYou can download the configuration of an existing service into a\nYAML file with the `gcloud run services describe` command by using the\n[`--format=export`](/sdk/gcloud/reference/run/services/describe) flag.\nYou can then modify that YAML file and deploy\nthose changes with the `gcloud run services replace` command.\nYou must ensure that you modify only the specified attributes.\n\n1. Download the configuration of your service into a file named\n `service.yaml` on local workspace:\n\n ```bash\n gcloud run services describe SERVICE --format export \u003e service.yaml\n ```\n\n Replace \u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e with the name of your\n Knative serving service.\n2. In your local file, 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 spec:\n containerConcurrency: CONCURRENCY\n ```\n\n Replace:\n - \u003cvar translate=\"no\"\u003eSERVICE\u003c/var\u003e with the name of your Knative serving service\n - \u003cvar translate=\"no\"\u003eCONCURRENCY\u003c/var\u003e with the maximum number of concurrent requests per container instance. Specify `default` to clear the concurrency settings: `--concurrency default`.\n3. Replace the service with its new configuration using the following command:\n\n ```bash\n gcloud run services replace service.yaml\n ```"]]