# Compute V1 Client - Class AutoscalingPolicy (2.10.0)

2.10.0 (latest) 2.9.0 2.8.0 2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.0.0 1.36.0 1.35.0 1.34.0 1.33.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 1.24.0 1.23.0 1.22.1 1.21.0 1.20.0 1.19.0 1.18.1 1.17.0 1.16.2 1.14.0 1.13.0 1.12.1 1.11.1 1.10.1 1.9.1 1.8.3 1.7.1 1.6.1 1.5.0 Reference documentation and code samples for the Compute V1 Client class AutoscalingPolicy.

Cloud Autoscaler policy.

Generated from protobuf message `google.cloud.compute.v1.AutoscalingPolicy`

## Namespace

Google \\ Cloud \\ Compute \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ cool_down_period_sec` | `int` The number of seconds that your application takes to initialize on a VM instance. This is referred to as the [initialization period](https://docs.cloud.google.com/compute/docs/autoscaler#cool_down_period). Specifying an accurate initialization period improves autoscaler decisions. For example, when scaling out, the autoscaler ignores data from VMs that are still initializing because those VMs might not yet represent normal usage of your application. The default initialization period is 60 seconds. Initialization periods might vary because of numerous factors. We recommend that you test how long your application takes to initialize. To do this, create a VM and time your application's startup process. |
| `↳ cpu_utilization` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.AutoscalingPolicyCpuUtilization` Defines the CPU utilization policy that allows the autoscaler to scale based on the average CPU utilization of a managed instance group. |
| `↳ custom_metric_utilizations` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.AutoscalingPolicyCustomMetricUtilization>` Configuration parameters of autoscaling based on a custom metric. |
| `↳ load_balancing_utilization` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.AutoscalingPolicyLoadBalancingUtilization` Configuration parameters of autoscaling based on load balancer. |
| `↳ max_num_replicas` | `int` The maximum number of instances that the autoscaler can scale out to. This is required when creating or updating an autoscaler. The maximum number of replicas must not be lower than minimal number of replicas. |
| `↳ min_num_replicas` | `int` The minimum number of replicas that the autoscaler can scale in to. This cannot be less than 0. If not provided, autoscaler chooses a default value depending on maximum number of instances allowed. |
| `↳ mode` | `string` Defines the operating mode for this policy. The following modes are available: - OFF: Disables the autoscaler but maintains its configuration. - ONLY_SCALE_OUT: Restricts the autoscaler to add VM instances only. - ON: Enables all autoscaler activities according to its policy. For more information, see "Turning off or restricting an autoscaler" Check the Mode enum for the list of possible values. |
| `↳ scale_in_control` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.AutoscalingPolicyScaleInControl` |
| `↳ scaling_schedules` | `array|https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` Scaling schedules defined for an autoscaler. Multiple schedules can be set on an autoscaler, and they can overlap. During overlapping periods the greatest min_required_replicas of all scaling schedules is applied. Up to 128 scaling schedules are allowed. |
| `↳ stabilization_period_sec` | `int` The number of seconds that autoscaler waits for load stabilization before making scale-in decisions. This is referred to as the [stabilization period](https://docs.cloud.google.com/compute/docs/autoscaler#stabilization_period). This might appear as a delay in scaling in but it is an important mechanism for your application to not have fluctuating size due to short term load fluctuations. The default stabilization period is 600 seconds. |

### getCoolDownPeriodSec

The number of seconds that your application takes to initialize on a VM
instance. This is referred to as the
[initialization period](https://docs.cloud.google.com/compute/docs/autoscaler#cool_down_period).

Specifying an accurate initialization period improves
autoscaler decisions. For example, when scaling out, the autoscaler ignores
data from VMs that are still initializing because those VMs might not yet
represent normal usage of your application. The default initialization
period is 60 seconds.
Initialization periods might vary because of numerous
factors. We recommend that you test how long your application takes to
initialize. To do this, create a VM and time your application's startup
process.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### hasCoolDownPeriodSec

### clearCoolDownPeriodSec

### setCoolDownPeriodSec

The number of seconds that your application takes to initialize on a VM
instance. This is referred to as the
[initialization period](https://docs.cloud.google.com/compute/docs/autoscaler#cool_down_period).

Specifying an accurate initialization period improves
autoscaler decisions. For example, when scaling out, the autoscaler ignores
data from VMs that are still initializing because those VMs might not yet
represent normal usage of your application. The default initialization
period is 60 seconds.
Initialization periods might vary because of numerous
factors. We recommend that you test how long your application takes to
initialize. To do this, create a VM and time your application's startup
process.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getCpuUtilization

Defines the CPU utilization policy that allows the autoscaler to scale
based on the average CPU utilization of a managed instance group.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.AutoscalingPolicyCpuUtilization|null` |   |

### hasCpuUtilization

### clearCpuUtilization

### setCpuUtilization

Defines the CPU utilization policy that allows the autoscaler to scale
based on the average CPU utilization of a managed instance group.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.AutoscalingPolicyCpuUtilization` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getCustomMetricUtilizations

Configuration parameters of autoscaling based on a custom metric.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.AutoscalingPolicyCustomMetricUtilization>` |   |

### setCustomMetricUtilizations

Configuration parameters of autoscaling based on a custom metric.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.AutoscalingPolicyCustomMetricUtilization>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getLoadBalancingUtilization

Configuration parameters of autoscaling based on load balancer.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.AutoscalingPolicyLoadBalancingUtilization|null` |   |

### hasLoadBalancingUtilization

### clearLoadBalancingUtilization

### setLoadBalancingUtilization

Configuration parameters of autoscaling based on load balancer.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.AutoscalingPolicyLoadBalancingUtilization` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getMaxNumReplicas

The maximum number of instances that the autoscaler can scale out to. This
is required when creating or updating an autoscaler. The maximum number
of replicas must not be lower than minimal number of replicas.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### hasMaxNumReplicas

### clearMaxNumReplicas

### setMaxNumReplicas

The maximum number of instances that the autoscaler can scale out to. This
is required when creating or updating an autoscaler. The maximum number
of replicas must not be lower than minimal number of replicas.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getMinNumReplicas

The minimum number of replicas that the autoscaler can scale in to.

This cannot be less than 0. If not provided, autoscaler chooses a
default value depending on maximum number of instances allowed.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### hasMinNumReplicas

### clearMinNumReplicas

### setMinNumReplicas

The minimum number of replicas that the autoscaler can scale in to.

This cannot be less than 0. If not provided, autoscaler chooses a
default value depending on maximum number of instances allowed.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getMode

Defines the operating mode for this policy.

The following modes are available:

- OFF: Disables the autoscaler but maintains its configuration.
- ONLY_SCALE_OUT: Restricts the autoscaler to add VM instances only.
- ON: Enables all autoscaler activities according to its policy. For more information, see "Turning off or restricting an autoscaler" Check the Mode enum for the list of possible values.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### hasMode

### clearMode

### setMode

Defines the operating mode for this policy.

The following modes are available:

- OFF: Disables the autoscaler but maintains its configuration.
- ONLY_SCALE_OUT: Restricts the autoscaler to add VM instances only.
- ON: Enables all autoscaler activities according to its policy. For more information, see "Turning off or restricting an autoscaler" Check the Mode enum for the list of possible values.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getScaleInControl

Generated from protobuf field `optional .google.cloud.compute.v1.AutoscalingPolicyScaleInControl scale_in_control = 527670872;`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.AutoscalingPolicyScaleInControl|null` |   |

### hasScaleInControl

### clearScaleInControl

### setScaleInControl

Generated from protobuf field `optional .google.cloud.compute.v1.AutoscalingPolicyScaleInControl scale_in_control = 527670872;`

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-compute/latest/V1.AutoscalingPolicyScaleInControl` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getScalingSchedules

Scaling schedules defined for an autoscaler. Multiple schedules
can be set on an autoscaler, and they can overlap. During overlapping
periods the greatest min_required_replicas of all scaling schedules is
applied. Up to 128 scaling schedules are allowed.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` |   |

### setScalingSchedules

Scaling schedules defined for an autoscaler. Multiple schedules
can be set on an autoscaler, and they can overlap. During overlapping
periods the greatest min_required_replicas of all scaling schedules is
applied. Up to 128 scaling schedules are allowed.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array|https://protobuf.dev/reference/php/api-docs/Google/Protobuf/Internal/MapField` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getStabilizationPeriodSec

The number of seconds that autoscaler waits for load stabilization before
making scale-in decisions. This is referred to as the
[stabilization period](https://docs.cloud.google.com/compute/docs/autoscaler#stabilization_period).

This might appear as a delay in scaling in but it is an important mechanism
for your application to not have fluctuating size due to short term load
fluctuations.
The default stabilization period is 600 seconds.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

### hasStabilizationPeriodSec

### clearStabilizationPeriodSec

### setStabilizationPeriodSec

The number of seconds that autoscaler waits for load stabilization before
making scale-in decisions. This is referred to as the
[stabilization period](https://docs.cloud.google.com/compute/docs/autoscaler#stabilization_period).

This might appear as a delay in scaling in but it is an important mechanism
for your application to not have fluctuating size due to short term load
fluctuations.
The default stabilization period is 600 seconds.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |