» google_dataproc_autoscaling_policy

Describes an autoscaling policy for Dataproc cluster autoscaler.

» Example Usage - Dataproc Autoscaling Policy

resource "google_dataproc_cluster" "basic" {
  name     = "tf-dataproc-test-"
  region   = "us-central1"

  cluster_config {
    autoscaling_config {
      policy_uri = google_dataproc_autoscaling_policy.asp.name
    }
  }
}

resource "google_dataproc_autoscaling_policy" "asp" {
  policy_id = "tf-dataproc-test-"
  location  = "us-central1"

  worker_config {
    max_instances = 3
  }

  basic_algorithm {
    yarn_config {
      graceful_decommission_timeout = "30s"

      scale_up_factor   = 0.5
      scale_down_factor = 0.5
    }
  }
}

» Argument Reference

The following arguments are supported:

  • policy_id - (Required) The policy id. The id must contain only letters (a-z, A-Z), numbers (0-9), underscores (_), and hyphens (-). Cannot begin or end with underscore or hyphen. Must consist of between 3 and 50 characters.

  • worker_config - (Optional) Describes how the autoscaler will operate for primary workers. Structure is documented below.

  • secondary_worker_config - (Optional) Describes how the autoscaler will operate for secondary workers. Structure is documented below.

  • basic_algorithm - (Optional) Basic algorithm for autoscaling. Structure is documented below.

  • location - (Optional) The location where the autoscaling poicy should reside. The default value is global.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

The worker_config block supports:

  • min_instances - (Optional) Minimum number of instances for this group. Bounds: [2, maxInstances]. Defaults to 2.

  • max_instances - (Required) Maximum number of instances for this group.

  • weight - (Optional) Weight for the instance group, which is used to determine the fraction of total workers in the cluster from this instance group. For example, if primary workers have weight 2, and secondary workers have weight 1, the cluster will have approximately 2 primary workers for each secondary worker. The cluster may not reach the specified balance if constrained by min/max bounds or other autoscaling settings. For example, if maxInstances for secondary workers is 0, then only primary workers will be added. The cluster can also be out of balance when created. If weight is not set on any instance group, the cluster will default to equal weight for all groups: the cluster will attempt to maintain an equal number of workers in each group within the configured size bounds for each group. If weight is set for one group only, the cluster will default to zero weight on the unset group. For example if weight is set only on primary workers, the cluster will use primary workers only and no secondary workers.

The secondary_worker_config block supports:

  • min_instances - (Optional) Minimum number of instances for this group. Bounds: [0, maxInstances]. Defaults to 0.

  • max_instances - (Optional) Maximum number of instances for this group. Note that by default, clusters will not use secondary workers. Required for secondary workers if the minimum secondary instances is set. Bounds: [minInstances, ). Defaults to 0.

  • weight - (Optional) Weight for the instance group, which is used to determine the fraction of total workers in the cluster from this instance group. For example, if primary workers have weight 2, and secondary workers have weight 1, the cluster will have approximately 2 primary workers for each secondary worker. The cluster may not reach the specified balance if constrained by min/max bounds or other autoscaling settings. For example, if maxInstances for secondary workers is 0, then only primary workers will be added. The cluster can also be out of balance when created. If weight is not set on any instance group, the cluster will default to equal weight for all groups: the cluster will attempt to maintain an equal number of workers in each group within the configured size bounds for each group. If weight is set for one group only, the cluster will default to zero weight on the unset group. For example if weight is set only on primary workers, the cluster will use primary workers only and no secondary workers.

The basic_algorithm block supports:

  • cooldown_period - (Optional) Duration between scaling events. A scaling period starts after the update operation from the previous event has completed. Bounds: [2m, 1d]. Default: 2m.

  • yarn_config - (Required) YARN autoscaling configuration. Structure is documented below.

The yarn_config block supports:

  • graceful_decommission_timeout - (Required) Timeout for YARN graceful decommissioning of Node Managers. Specifies the duration to wait for jobs to complete before forcefully removing workers (and potentially interrupting jobs). Only applicable to downscaling operations. Bounds: [0s, 1d].

  • scale_up_factor - (Required) Fraction of average pending memory in the last cooldown period for which to add workers. A scale-up factor of 1.0 will result in scaling up so that there is no pending memory remaining after the update (more aggressive scaling). A scale-up factor closer to 0 will result in a smaller magnitude of scaling up (less aggressive scaling). Bounds: [0.0, 1.0].

  • scale_down_factor - (Required) Fraction of average pending memory in the last cooldown period for which to remove workers. A scale-down factor of 1 will result in scaling down so that there is no available memory remaining after the update (more aggressive scaling). A scale-down factor of 0 disables removing workers, which can be beneficial for autoscaling a single job. Bounds: [0.0, 1.0].

  • scale_up_min_worker_fraction - (Optional) Minimum scale-up threshold as a fraction of total cluster size before scaling occurs. For example, in a 20-worker cluster, a threshold of 0.1 means the autoscaler must recommend at least a 2-worker scale-up for the cluster to scale. A threshold of 0 means the autoscaler will scale up on any recommended change. Bounds: [0.0, 1.0]. Default: 0.0.

  • scale_down_min_worker_fraction - (Optional) Minimum scale-down threshold as a fraction of total cluster size before scaling occurs. For example, in a 20-worker cluster, a threshold of 0.1 means the autoscaler must recommend at least a 2 worker scale-down for the cluster to scale. A threshold of 0 means the autoscaler will scale down on any recommended change. Bounds: [0.0, 1.0]. Default: 0.0.

» Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • name - The "resource name" of the autoscaling policy.

» Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 4 minutes.
  • update - Default is 4 minutes.
  • delete - Default is 4 minutes.

» Import

AutoscalingPolicy can be imported using any of these accepted formats:

$ terraform import google_dataproc_autoscaling_policy.default projects/{{project}}/locations/{{location}}/autoscalingPolicies/{{policy_id}}
$ terraform import google_dataproc_autoscaling_policy.default {{project}}/{{location}}/{{policy_id}}
$ terraform import google_dataproc_autoscaling_policy.default {{location}}/{{policy_id}}

» User Project Overrides

This resource supports User Project Overrides.