This page shows you how to manually scale your worker pool.
Overview
Manual scaling lets you set a specific instance count without requiring redeployment. This gives you the option to write your own scaling logic using an external system. See the Kafka Autoscaler for an example of this.
Billing considerations when using manual scaling
When you use manual scaling, all the instances that you requested are billed as active instances, even if they happen to be idle. For complete billing details, see the pricing page.
Required roles
To get the permissions that you need to deploy Cloud Run worker pools, ask your administrator to grant you the following IAM roles:
-
Cloud Run Developer (
roles/run.developer
) on the Cloud Run service -
Service Account User (
roles/iam.serviceAccountUser
) on the service identity -
Artifact Registry Reader (
roles/artifactregistry.reader
) on the Artifact Registry repository of the deployed container image (if applicable)
For a list of IAM roles and permissions that are associated with Cloud Run, see Cloud Run IAM roles and Cloud Run IAM permissions. If your Cloud Run worker pool interfaces with Google Cloud APIs, such as Cloud Client Libraries, see the service identity configuration guide. For more information about granting roles, see deployment permissions and manage access.
Configure scaling
Configure the scaling mode using the Google Cloud CLI when you create a new worker pool or deploy a new revision:
gcloud
To specify scaling for a new worker pool, use the deploy command:
gcloud beta run worker-pools deploy WORKER_POOL \ --scaling=INSTANCE_COUNT \ --image IMAGE_URL
Replace:
- WORKER_POOL with the name of your worker pool.
- INSTANCE_COUNT with the number of instances for the worker pool.
This sets the worker pool to manual scaling. Specify a value of
0
to disable the worker pool. - IMAGE_URL with a reference to the container image that
contains the worker pool, such as
us-docker.pkg.dev/cloudrun/container/worker-pool:latest
.
Specify scaling for an existing worker pool by using the following update command:
gcloud beta run worker-pools update WORKER_POOL \ --scaling=INSTANCE_COUNT
View scaling configuration for a worker pool
In the Google Cloud console, go to Cloud Run:
Click Worker pools to display the list of deployed worker pools.
Click the worker pool you want to examine to display its details pane.
The current scaling setting is shown above the worker pools revision list: Scaling: Manual (Instances: ).
Disable a worker pool
To disable a worker pool, use the following command to set scaling to zero:
gcloud beta run worker-pools update WORKER_POOL --scaling=0
Replace WORKER_POOL with the name of your worker pool.