Update a Dataproc cluster by using a template
This page shows you how to use anGoogle APIs Explorer template toupdate a Dataproc cluster to change the number of workers in acluster.Scaling a clusterup to include more workers is a common task when additional workers are neededto process larger jobs.
For other ways to update a Dataproc cluster, see:
Before you begin
This quickstart assumes you have already created a Dataproc cluster.You can use theAPIs Explorer, theGoogle Cloud console,the gcloud CLIgcloud command-line tool,or theQuickstarts using Cloud Client Librariesto create a cluster.Update a cluster
To update the number of workers in your cluster, fill in and execute theGoogle APIs ExplorerTry this API template.
Note: Theregion,clusterName andupdateMask andconfig.workerConfig.numInstances parameter values are filled in for you.Confirm or replace theregion andclusterName parameter values to matchyour cluster's region and name. TheupdateMask parameter value is required toupdate the number of workers in your cluster. You can accept or changetheconfig.workerConfig.numInstances parameter value.Request parameters:
- Insert yourprojectId.
- Specify theregionwhere your cluster is located (confirm or replace "us-central1").Your cluster's region is listed on theDataprocClusterspage in the Google Cloud console.
- Specify theclusterNameof the existing cluster that you are updating (confirm or replace "example-cluster").
- updateMask:"config.worker_config.num_instances". This is the JSON PATHrelative to theClusterresource to the
numInstancesparameter to be updated (see the Request body instructions).
Request body:
- config.workerConfig.numInstances:("3": the new number of workers). You can change this value to add feweror more workers. For example, if your standard cluster has the defaultnumber of 2 workers, specifying "3" will add 1 worker; specifying "4 will add 2).A standard Dataproc cluster must have at least 2 workers.
ClickEXECUTE. The first time yourun the API template, you may be asked to choose and sign intoyour Google account, then authorize the Google APIs Explorer to access youraccount. If the request is successful, the JSON responseshows that cluster update is pending.
To confirm that the number of workers in the cluster has been updated,open the DataprocClusters page in the Google Cloud consoleand view the cluster'sTotal worker nodes column. You may needto click REFRESH at the top of the page to view the updated value after thecluster update completes.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.
- If you don't need the cluster to explore the other quickstarts or to runother jobs, use theAPIs Explorer, theGoogle Cloud console,the gcloud CLIgcloud command-line tool,or theQuickstarts using Cloud Client Librariesto delete the cluster.
What's next
You can use this quickstart template to restore the cluster to its previous
workerConfig.numInstancesvalue.Learn how towrite and run a Spark Scala job.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.