Skip to content

googleDataprocAutoscalingPolicy

Describes an autoscaling policy for Dataproc cluster autoscaler.

Example Usage - Dataproc Autoscaling Policy

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleDataprocAutoscalingPolicyAsp =
  new google.dataprocAutoscalingPolicy.DataprocAutoscalingPolicy(this, "asp", {
    basic_algorithm: [
      {
        yarn_config: [
          {
            graceful_decommission_timeout: "30s",
            scale_down_factor: 0.5,
            scale_up_factor: 0.5,
          },
        ],
      },
    ],
    location: "us-central1",
    policy_id: "dataproc-policy",
    worker_config: [
      {
        max_instances: 3,
      },
    ],
  });
new google.dataprocCluster.DataprocCluster(this, "basic", {
  cluster_config: [
    {
      autoscaling_config: [
        {
          policy_uri: googleDataprocAutoscalingPolicyAsp.name,
        },
      ],
    },
  ],
  name: "dataproc-policy",
  region: "us-central1",
});

Argument Reference

The following arguments are supported:

  • policyId - (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.

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

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

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

  • location - (Optional) The location where the autoscaling policy 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 workerConfig block supports:

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

  • maxInstances - (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 secondaryWorkerConfig block supports:

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

  • maxInstances - (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 basicAlgorithm block supports:

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

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

The yarnConfig block supports:

  • gracefulDecommissionTimeout - (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].

  • scaleUpFactor - (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].

  • scaleDownFactor - (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].

  • scaleUpMinWorkerFraction - (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.

  • scaleDownMinWorkerFraction - (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:

  • id - an identifier for the resource with format projects/{{project}}/locations/{{location}}/autoscalingPolicies/{{policyId}}

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

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 20 minutes.
  • update - Default is 20 minutes.
  • delete - Default is 20 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.