To ensure that VM resources are available when your Dataflow jobs need
them, you can use Compute Engine reservations. Reservations provide a high
level of assurance in obtaining capacity for Compute Engine zonal
resources.

To use [*automatically consumed*](https://docs.cloud.google.com/compute/docs/instances/reservations-overview.md.txt#consumption-type) Compute Engine reservations with Dataflow, perform the
following steps:

1. Create a Compute Engine reservation. It can be a single-project
   reservation or a shared reservation. For more information, see the following
   documents:

   - [Create a reservation for a single project](https://docs.cloud.google.com/compute/docs/instances/reservations-single-project.md.txt)
   - [Create a shared reservation](https://docs.cloud.google.com/compute/docs/instances/reservations-shared.md.txt)

   The reservation can include GPU or TPU accelerators.

   The reservation must be configured for automatic consumption (the default
   setting in Compute Engine). Dataflow doesn't support
   specifically targeted reservations for general workloads.
2. For the reservation to be consumed, the
   Dataflow worker configuration must match the reservation
   configuration (such as zone, machine type, and accelerator settings).
   To set worker VM properties such as machine type to match your
   reservation, see
   [Configure worker VMs](https://docs.cloud.google.com/dataflow/docs/guides/configure-worker-vm.md.txt).

   > [!NOTE]
   > **Note:** Dataflow doesn't support setting reservation affinity options. Worker VMs automatically use `ANY` reservation affinity to consume matching reservations.

3. Submit your Dataflow job.

4. You can monitor the current usage of the reservation by
   Dataflow on the
   [Reservations](https://console.cloud.google.com/compute/reservations) page
   in Google Cloud console.

To prevent other low-priority workloads in the same project from competing for
reservations with Dataflow, set the reservation affinity to
`none` when you create VMs for those workloads. You can't configure
reservation affinity on Dataflow jobs directly. For more
information, see
[Consuming reserved instances](https://docs.cloud.google.com/compute/docs/instances/reserving-zonal-resources#consuming_reserved_instances).

## Limitations

- All limitations of Compute Engine reservations apply when
  Dataflow workers consume reservations. See
  [How reservations work](https://docs.cloud.google.com/compute/docs/instances/reservations-overview.md.txt#how-reservations-work).

- Dataflow doesn't support configuring reservation affinity
  options. Worker VMs automatically consume matching reservations that are
  configured for automatic consumption.

- Dataflow doesn't support consuming
  [*specifically targeted*](https://docs.cloud.google.com/compute/docs/instances/reservations-consume.md.txt#consuming_instances_from_a_specific_reservation)
  reservations for general workloads. To be used by Dataflow,
  reservations must be configured to be consumed automatically. For pipelines
  using accelerators (GPUs or TPUs), specifically targeted reservations are
  available with an allowlist. For more information, see
  [Reservations and accelerators](https://docs.cloud.google.com/dataflow/docs/guides/compute-engine-reservations.md.txt#reservations-accelerators).

- Dataflow relies on the
  [default consumption order](https://docs.cloud.google.com/compute/docs/instances/reservations-overview.md.txt#consumption-order)
  in Compute Engine. As a result, the following limitations apply:

  - Other workloads in the same project or Organization that don't specify the `--reservation` flag might compete with Dataflow workloads for project-specific or shared reservations.
- Dataflow Prime jobs don't consume Compute Engine reservations.

## Reservations and accelerators

Dataflow supports [*specifically targeted*
reservations](https://docs.cloud.google.com/compute/docs/instances/reservations-consume#consuming_instances_from_a_specific_reservation)
for pipelines using accelerators (GPUs or TPUs). This functionality is generally
available with an allowlist. For instructions on using Dataflow
accelerators with specific reservations, contact your account team.

## Pricing

Dataflow bills you for VMs from *automatically consumed*
reservations while your Dataflow job runs. When
Dataflow isn't using the VMs, Compute Engine bills you.

### Compute Engine pricing model

If your Dataflow usage includes VMs from [*specifically targeted*
reservations](https://docs.cloud.google.com/compute/docs/instances/reservations-overview#consumption-type)
that have GPUs or TPUs, then compute resources from those reserved VMs are
billed according to [Compute Engine
Pricing](https://cloud.google.com/compute/all-pricing). If your *specifically targeted* reservations are
attached to a [Compute Engine resource-based
commitment](https://docs.cloud.google.com/compute/docs/instances/signing-up-committed-use-discounts), then
you also receive applicable resource-based committed use discounts (CUDs) for
your usage. You're also billed a management premium for compute resources
consumed in Dataflow. For more pricing details, see [Dataflow Pricing](https://cloud.google.com/dataflow/pricing).

### Dataflow pricing model

For any other type of Compute Engine reservations that you use with
Dataflow, your usage is billed by using the
[Dataflow pricing model](https://cloud.google.com/dataflow/pricing). Dataflow
usage from those reservations isn't eligible for resource-based CUDs, even if
those reservations are attached to a resource-based commitment. This applies to
the following Compute Engine reservations:

- *Specifically targeted* reservations that don't have GPUs or TPUs
- All *automatically consumed* reservations

## What's next

To learn more about Compute Engine reservations, see
[Reservations of Compute Engine zonal resources](https://docs.cloud.google.com/compute/docs/instances/reservations-overview.md.txt).