Service options are a type of pipeline option that let you specify
additional job modes and configurations for a Dataflow job. Set
these options by setting the Dataflow service options
[pipeline option](https://docs.cloud.google.com/dataflow/docs/reference/pipeline-options.md.txt).

### Java

    --dataflowServiceOptions=SERVICE_OPTION

Replace <var translate="no">SERVICE_OPTION</var> with the service option that you
want to use.

### Python

    --dataflow_service_options=SERVICE_OPTION

Replace <var translate="no">SERVICE_OPTION</var> with the service option that you
want to use.

### Go

    --dataflow_service_options=SERVICE_OPTION

Replace <var translate="no">SERVICE_OPTION</var> with the service option that you
want to use.

### gcloud

Use the
[`gcloud dataflow jobs run`](https://docs.cloud.google.com/sdk/gcloud/reference/dataflow/jobs/run.md.txt) command
with the `additional-experiments` option. If you're using Flex Templates, use
the
[`gcloud dataflow flex-template run`](https://docs.cloud.google.com/sdk/gcloud/reference/dataflow/flex-template/run.md.txt)
command.

    --additional-experiments=SERVICE_OPTION

For example:

```bash
gcloud dataflow jobs run JOB_NAME --additional-experiments=SERVICE_OPTION
```

Replace the following values:

- <var translate="no">JOB_NAME</var>: the name of your Dataflow job
- <var translate="no">SERVICE_OPTION</var>: the service option that you want to use

### REST

Use the `additionalExperiments` field in the
[`RuntimeEnvironment`](https://docs.cloud.google.com/dataflow/docs/reference/rest/v1b3/RuntimeEnvironment.md.txt)
object. If you're using Flex Templates, use the `additionalExperiments` field
in the
[`FlexTemplateRuntimeEnvironment`](https://docs.cloud.google.com/dataflow/docs/reference/rest/v1b3/projects.locations.flexTemplates/launch.md.txt#FlexTemplateRuntimeEnvironment)
object.

```json
{
  additionalExperiments : ["SERVICE_OPTION"]
  ...
}
```

Replace <var translate="no">SERVICE_OPTION</var> with the service option that you
want to use.

For more information, see
[Set Dataflow pipeline options](https://docs.cloud.google.com/dataflow/docs/guides/setting-pipeline-options.md.txt#set_pipeline_options_programmatically).

Dataflow supports the following service options.

| Option | Description |
|---|---|
| `block_project_ssh_keys` | Prevents VMs from accepting SSH keys that are stored in project metadata. For more information, see [Restrict SSH keys from VMs](https://docs.cloud.google.com/compute/docs/connect/restrict-ssh-keys.md.txt#block-keys). |
| `disable_image_streaming` | Fully download containers up-front instead of downloading their content as needed. This option is the opposite of `enable_image_streaming`. |
| `enable_confidential_compute` | Enables Confidential VM with AMD Secure Encryption Virtualization (SEV) on Dataflow worker VMs. For more information, see [Confidential Computing concepts](https://docs.cloud.google.com/confidential-computing/confidential-vm/docs/about-cvm). This service option is not compatible with Dataflow Prime or worker accelerators. You must specify a [supported machine type](https://docs.cloud.google.com/confidential-computing/confidential-vm/docs/os-and-machine-type). When this option is enabled, the job incurs additional flat per-vCPU and per-GB costs. For more information, see [Dataflow pricing](https://docs.cloud.google.com/dataflow/pricing#confidential_vm). |
| `enable_cross_gen_auto_vm` | For a batch job that uses [Auto VM Selection](https://docs.cloud.google.com/dataflow/docs/guides/auto-vm-selection.md.txt), lets the worker pool use both 4th generation and 2nd generation Compute Engine machines. Dataflow prioritizes 4th generation machines and uses 2nd generation machines when 4th generation machines are unavailable. This option isn't supported for streaming jobs. To explicitly disable cross-generation Auto VM Selection, set this option to `false`. For more information, see [Cross-generation Auto VM Selection](https://docs.cloud.google.com/dataflow/docs/guides/auto-vm-selection.md.txt#cross-generation). |
| `enable_lineage` | Enable data lineage for your Dataflow jobs. For more information, see [Use data lineage in Dataflow](https://docs.cloud.google.com/dataflow/docs/guides/lineage.md.txt). |
| `enable_dynamic_thread_scaling` | Enable dynamic thread scaling on Dataflow worker VMs. For more information, see [Dynamic thread scaling](https://docs.cloud.google.com/dataflow/docs/guides/thread-scaling.md.txt). |
| `enable_eager_watermark_advancement` | For a [Streaming Engine](https://docs.cloud.google.com/dataflow/docs/streaming-engine.md.txt) job, this option prevents records that arrive behind the current watermark from stalling the watermark. If your pipeline uses windowed aggregations or stateful processing, configure allowed lateness to cover expected delays before you enable this option. For more information, see [Eager watermark advancement](https://docs.cloud.google.com/dataflow/docs/guides/eager-watermark-advancement.md.txt). |
| `enable_google_cloud_heap_sampling` | Enable heap profiling. For more information, see [Monitoring pipeline performance using Cloud Profile](https://docs.cloud.google.com/dataflow/docs/guides/profiling-a-pipeline.md.txt). |
| `enable_google_cloud_profiler` | Enable performance profiling. For more information, see [Monitoring pipeline performance using Cloud Profile](https://docs.cloud.google.com/dataflow/docs/guides/profiling-a-pipeline.md.txt). |
| `enable_image_streaming` | Download container content as-needed instead of downloading their full content up-front. This option improves startup time and autoscaling latency for pipelines using custom containers that can process data before their full content is available. You must have the [Container File System API](https://console.cloud.google.com/marketplace/product/google/containerfilesystem.googleapis.com) enabled to benefit from this option. For more information, see [Dataflow container image streaming](https://docs.cloud.google.com/dataflow/docs/guides/run-custom-container.md.txt#container_image_streaming). |
| `enable_preflight_validation` | When you run your pipeline on Dataflow, before the job launches, Dataflow performs validation checks on the pipeline. This option is enabled by default. To disable pipeline validation, set this option to `false`. For more information, see [Pipeline validation](https://docs.cloud.google.com/dataflow/docs/guides/deploying-a-pipeline.md.txt#validation). |
| `enable_prime` | Enable Dataflow Prime for this job. To explicitly disable Dataflow Prime, set this option to `false`. For more information, see [Use Dataflow Prime](https://docs.cloud.google.com/dataflow/docs/guides/enable-dataflow-prime.md.txt). |
| `enable_streaming_engine_resource_based_billing` | Enable resource-based billing for this job. For more information, see [Pricing](https://docs.cloud.google.com/dataflow/docs/streaming-engine.md.txt#pricing) in "Use Streaming Engine for streaming jobs." |
| `graph_validate_only` | Runs a job graph validation check to verify whether a replacement job is valid. For more information, see [Validate a replacement job](https://docs.cloud.google.com/dataflow/docs/guides/updating-a-pipeline.md.txt#validate). |
| `map_task_backup_mode` | Enables speculative execution for batch pipelines to mitigate the impact of slow-running or stuck tasks. When a task is identified as a straggler, a backup worker is initiated in parallel. The first task to finish is used, and the other is cancelled. This feature is not supported for streaming pipelines. Set one of the following modes as a parameter to the flag: - `ON`: A backup worker is created if the original task is estimated to take 20% longer to complete than a new task. - `CAUTIOUS`: A backup worker is created if the original task is estimated to take 70% longer to complete than a new task. For example: `--dataflow_service_options=map_task_backup_mode=ON` For more information, see [Use speculative execution to avoid stragglers](https://docs.cloud.google.com/dataflow/docs/guides/large-pipeline-best-practices.md.txt#backup-tasks). |
| `max_dataflow_custom_metrics_override` | This option overrides the default limit of 100 custom metrics per project. Use this option to create more than 100 custom metrics across all your Dataflow jobs in a single project. For `max_dataflow_custom_metrics_override=N`, replace `N` with the specified limit up to 10000. Increasing this limit might result in higher [Cloud Monitoring costs](https://cloud.google.com/products/observability/pricing). |
| `managed_transforms_rolling_upgrade_window` | Sets the upgrade window for Managed I/O connectors for a job. Specify the number of days as a parameter, or `never` to disable rolling upgrades for this job. For more information, see [Automatic upgrades](https://docs.cloud.google.com/dataflow/docs/guides/managed-io.md.txt#upgrades). |
| `max_workflow_runtime_walltime_seconds` | The maximum number of seconds the job can run. If the job exceeds this limit, Dataflow cancels the job. This service option is supported for batch jobs only. Batch jobs can't run for more than 10 days. After 10 days, the job is cancelled. Specify the number of seconds as a parameter to the flag. For example: `--dataflowServiceOptions=max_workflow_runtime_walltime_seconds=300` |
| `min_num_workers` | The minimum number of workers the job uses. Helps to make sure that a Dataflow job always has at least the number of workers specified. Horizontal autoscaling doesn't scale below the number of workers specified. |
| `num_pubsub_keys` | Overrides the default number of shuffle keys and sets the parallelism for pipeline stages that read from Pub/Sub. The next power of 2 greater than or equal to the specified value is used. By default, for [Streaming Engine](https://docs.cloud.google.com/dataflow/docs/streaming-engine.md.txt) jobs, Dataflow dynamically calculates the number of keys based on the active workers at a particular instant: `(number of workers * threads per worker) / 2`, bounded between 128 and 65,536 keys, and rounded down to the nearest power of 2. For non-Streaming Engine jobs, the number of keys defaults to the lowest power of 2 greater than or equal to `(4 * maximum workers)`. Specify the number of keys as a parameter to the flag. For example: `--dataflow_service_options=num_pubsub_keys=2048` For more information, see [Pub/Sub source parallelism](https://docs.cloud.google.com/dataflow/docs/concepts/streaming-with-cloud-pubsub.md.txt#parallelism). |
| `parallel_replace_job_cancel_on_drain_timeout` | When you enable an automated stop-and-replace update, specifies whether Dataflow cancels the old job if draining times out (takes longer than `parallel_replace_job_max_stop_duration`). The default value is `true`. |
| `parallel_replace_job_cancel_timeout` | When you enable an automated stop-and-replace update and `parallel_replace_job_cancel_on_drain_timeout` is `true`, this option specifies how long to wait for the old job to finish canceling before force-canceling the job. |
| `parallel_replace_job_id` | When you enable an [automated parallel pipeline update](https://docs.cloud.google.com/dataflow/docs/guides/upgrade-guide.md.txt#automated-parallel-updates) or [stop-and-replace update](https://docs.cloud.google.com/dataflow/docs/guides/upgrade-guide.md.txt#automated-stop-replace), identifies the job to replace by job ID. You must provide either this option or `parallel_replace_job_name`. |
| `parallel_replace_job_max_stop_duration` | When you enable an [automated stop-and-replace update](https://docs.cloud.google.com/dataflow/docs/guides/upgrade-guide.md.txt#automated-stop-replace), this option specifies the maximum amount of time the new job waits for the old job to finish draining before it begins message processing. The duration must be formatted as a string ending in `s`, `m`, or `h`, such as `30m` or `1h`. |
| `parallel_replace_job_min_parallel_pipelines_duration` | When you enable an [automated parallel pipeline update](https://docs.cloud.google.com/dataflow/docs/guides/upgrade-guide.md.txt#automated-parallel-updates), specifies the minimum amount of time the two pipelines run in parallel. After this duration passes, the old job is sent a drain signal. The duration must be between 0 seconds (`0s`) and 31 days (`744h`). The duration must be formatted as a string that ends in `s`, `m`, or `h`. The default value is `60m`. Specify the duration as a parameter. For example, to specify 10 minutes, use the following syntax: `--dataflowServiceOptions=parallel_replace_job_min_parallel_pipelines_duration=10m` |
| `parallel_replace_job_name` | When you enable an [automated parallel pipeline update](https://docs.cloud.google.com/dataflow/docs/guides/upgrade-guide.md.txt#automated-parallel-updates) or [stop-and-replace update](https://docs.cloud.google.com/dataflow/docs/guides/upgrade-guide.md.txt#automated-stop-replace), this option identifies the job to replace by job name. You must provide either this option or `parallel_replace_job_id`. |
| `parallel_replace_job_preallocate_compute_resources` | When you enable an automated stop-and-replace or parallel pipeline update, this option specifies whether workers are allocated in advance for the new pipeline while the old job drains to minimize transition delay. Values: `true` (default) or `false`. When `parallel_replace_job_preallocate_compute_resources` is set to `false`, the new job remains in a pending state until the old job drains. |
| `pause_on_failure` | Pauses a batch job instead of failing it when a work item fails four times. With this option set, you can also manually pause a job. This option requires the job to use [Dataflow shuffle](https://docs.cloud.google.com/dataflow/docs/shuffle-for-batch.md.txt). By default, the maximum pause duration is 7 days (`7d`). You can manually specify a maximum pause duration using the `pause_duration` parameter. You can configure the maximum duration in hours (`h`) or days (`d`), between 1 hour (`1h`) and 7 days (`7d`). For example: `--dataflowServiceOptions=pause_on_failure=pause_duration:1d` For more information, see [Pause a Dataflow job](https://docs.cloud.google.com/dataflow/docs/guides/pause-job.md.txt). |
| `requires_high_availability` | Enables streaming high availability for a [Streaming Engine](https://docs.cloud.google.com/dataflow/docs/streaming-engine.md.txt) job, replicating backend state across zones within a region. For more information, see [Streaming high availability](https://docs.cloud.google.com/dataflow/docs/guides/streaming-high-availability.md.txt). |
| `sdf_checkpoint_after_duration` | The maximum duration each worker buffers [splittable `DoFn`](https://beam.apache.org/documentation/programming-guide/#splittable-dofns) (SDF) outputs before [checkpointing](https://beam.apache.org/documentation/runtime/model/#bundling-and-persistence) for further processing. Set this duration when you want low-latency processing on pipelines that have low throughput per worker, such as when reading [change streams from Spanner](https://docs.cloud.google.com/spanner/docs/change-streams/use-dataflow.md.txt). The worker checkpoints when either the duration limit or the bytes limit is triggered, so you can use this service option with `sdf_checkpoint_after_output_bytes` or by itself. This service option is supported for [Streaming Engine](https://docs.cloud.google.com/dataflow/docs/streaming-engine.md.txt) jobs that use the [Portable Runner](https://docs.cloud.google.com/dataflow/docs/portable-runner.md.txt). Specify the duration as a parameter. For example, to change the default from 5 seconds to 500 milliseconds, use the following syntax: `--dataflowServiceOptions=sdf_checkpoint_after_duration=500ms` |
| `sdf_checkpoint_after_output_bytes` | The maximum [splittable `DoFn`](https://beam.apache.org/documentation/programming-guide/#splittable-dofns) (SDF) output bytes each worker produces and buffers before [checkpointing](https://beam.apache.org/documentation/runtime/model/#bundling-and-persistence) for further processing. Set this value when you want low-latency processing on pipelines that have low throughput per worker, such as when reading [change streams from Spanner](https://docs.cloud.google.com/spanner/docs/change-streams/use-dataflow.md.txt). The worker checkpoints when either the duration limit or the bytes limit is triggered, so you can use this service option with `sdf_checkpoint_after_duration` or by itself. This service option is supported for [Streaming Engine](https://docs.cloud.google.com/dataflow/docs/streaming-engine.md.txt) jobs that use the [Portable Runner](https://docs.cloud.google.com/dataflow/docs/portable-runner.md.txt). Specify the number of bytes as a parameter. For example, to change the default from 5 MiB to 512 KiB, use the following syntax: `--dataflowServiceOptions=sdf_checkpoint_after_output_bytes=524288` |
| `streaming_mode_at_least_once` | Enables at-least-once streaming mode. For more information, see [Set the pipeline streaming mode](https://docs.cloud.google.com/dataflow/docs/guides/streaming-modes.md.txt). |
| `streaming_enable_pubsub_direct_output` | Enables at-least-once streaming mode for Pub/Sub output. This option does not affect the streaming mode for the rest of the pipeline. For more information, see [Set the pipeline streaming mode](https://docs.cloud.google.com/dataflow/docs/guides/streaming-modes.md.txt). |
| `use_network_tags` | Apply network tags to a Dataflow job. For more information, see [Use network tags with Dataflow](https://docs.cloud.google.com/dataflow/docs/guides/routes-firewall.md.txt#specifying_network_tags). |
| `use_vm_tags` | Apply secure tags to a Dataflow job. For more information, see [Use secure tags with Dataflow](https://docs.cloud.google.com/dataflow/docs/guides/routes-firewall.md.txt#secure_tags). |
| `worker_accelerator` | Enable GPUs or TPUs for this job. If you use [right fitting](https://docs.cloud.google.com/dataflow/docs/guides/right-fitting.md.txt), don't use this service option. **GPUs** Specify the type and number of GPUs to attach to Dataflow workers as parameters to the flag. For a list of GPU types that are supported with Dataflow, see [Dataflow support for GPUs](https://docs.cloud.google.com/dataflow/docs/gpu/gpu-support.md.txt#availability). For example: `--dataflow_service_options "worker_accelerator=type:GPU_TYPE;count:GPU_COUNT;install-nvidia-driver"` If you're using [NVIDIA Multi-Process Service (MPS)](https://docs.cloud.google.com/dataflow/docs/gpu/use-nvidia-mps.md.txt), append the `use_nvidia_mps` parameter to the end of the list of parameters. For example: `"worker_accelerator=type:GPU_TYPE;count:GPU_COUNT;install-nvidia-driver;use_nvidia_mps"` For more information about using GPUs, see [GPUs with Dataflow](https://docs.cloud.google.com/dataflow/docs/gpu). **TPUs** Specify the type and topology of TPUs to attach to Dataflow workers as parameters to the flag. For a list of TPU types that are supported with Dataflow, see [Supported TPU accelerators](https://docs.cloud.google.com/dataflow/docs/tpu/tpu-support.md.txt#supported-tpus). For example: `--dataflow_service_options "worker_accelerator=type:TPU_TYPE;topology:TPU_TOPOLOGY"` For a TPU type `tpu-v5-lite-podslice` with a `1x1` topology, the flag looks like the following: `"worker_accelerator=type:tpu-v5-lite-podslice;topology:1x1"` |
| `worker_utilization_hint` | Specifies the target CPU utilization. For more information, see [Set the worker utilization hint](https://docs.cloud.google.com/dataflow/docs/guides/tune-horizontal-autoscaling.md.txt#utilization-hint). |