Single node clusters are Managed Service for Apache Spark clusters with only one node.
This single node acts as the master and worker for your
Managed Service for Apache Spark cluster. While single
node clusters only have one node, most Managed Service for Apache Spark concepts and features
still apply, except those [listed below](https://docs.cloud.google.com/managed-spark/docs/concepts/configuring-clusters/single-node-clusters.md.txt#limitations).

There are a number of situations where single node Managed Service for Apache Spark clusters can
be useful, including:

- Trying out new versions of Spark and Hadoop or other open source components
- Building proof-of-concept (PoC) demonstrations
- Lightweight data science
- Small-scale non-critical data processing
- Education related to the Spark and Hadoop ecosystem

## Single node cluster semantics

The following semantics apply to single node Managed Service for Apache Spark clusters:

- Single node clusters are configured the same as multi node Managed Service for Apache Spark clusters, and include services such as HDFS and YARN.
- Single node clusters report as master nodes for [initialization actions](https://docs.cloud.google.com/managed-spark/docs/concepts/configuring-clusters/init-actions.md.txt).
- Single node clusters show 0 workers since the single node acts as both master and worker.
- Single node clusters are given hostnames that follow the pattern `clustername-m`. You can use this hostname to SSH into or connect to a [web UI](https://docs.cloud.google.com/managed-spark/docs/concepts/accessing/cluster-web-interfaces.md.txt) on the node.
- Single node clusters cannot be upgraded to multi node clusters. Once created, single node clusters are restricted to one node. Similarly, multi node clusters cannot be scaled down to single node clusters.

## Limitations

- Single node clusters are not recommended for large-scale parallel data
  processing. If you exceed the resources on a single node cluster, a multi node
  Managed Service for Apache Spark cluster is recommended.

- Single node clusters are not available with
  [high-availability](https://docs.cloud.google.com/managed-spark/docs/concepts/configuring-clusters/high-availability.md.txt)
  since there is only one node in the cluster.

- Single node clusters cannot use [preemptible VMs](https://docs.cloud.google.com/managed-spark/docs/concepts/compute/preemptible-vms).

## Create a single node cluster

### Console


- Open the [Create cluster](https://console.cloud.google.com/dataproc/clusters/create) page.
- In the **Define your cluster shape** section, select **Development**.
- Under **Additional configuration** , edit **Driver node** , clear the checkbox, **Default driver node to the same as primary worker**, then confirm or change driver node settings.

<br />

### gcloud command


You can create a single node Managed Service for Apache Spark cluster using the `gcloud`
command-line tool. To create a single node cluster, pass the
`--single-node` flag to the
[`gcloud dataproc clusters create`](https://docs.cloud.google.com/sdk/gcloud/reference/dataproc/clusters/create.md.txt)
command.

```
gcloud dataproc clusters create cluster-name \
    --region=region \
    --single-node \
    ... other args
```

<br />

### REST API


You can create a single node cluster through the
[Dataproc REST API](https://docs.cloud.google.com/managed-spark/docs/reference/rest.md.txt) using a
[clusters.create](https://docs.cloud.google.com/managed-spark/docs/reference/rest/v1/projects.regions.clusters/create.md.txt)
request. When making this request, you must:

1. Add the property `"dataproc:dataproc.allow.zero.workers":"true"` to the [SoftwareConfig](https://docs.cloud.google.com/managed-spark/docs/reference/rest/v1/ClusterConfig.md.txt#SoftwareConfig) of the cluster request.
2. Don't submit values for `workerConfig` and `secondaryWorkerConfig` (see [ClusterConfig](https://docs.cloud.google.com/managed-spark/docs/reference/rest/v1/ClusterConfig.md.txt)).

> [!NOTE]
> To examine and construct the JSON body of a Dataproc API clusters create request, open the Google Cloud console [Create a cluster](https://console.cloud.google.com/dataproc/clusters/create) page in your browser, fill in the applicable fields, then click **Equivalent REST** at the bottom of the page to view the POST request with the completed JSON request body.

<br />