Reference documentation and code samples for the Compute V1 Client class AutoscalingPolicy.
Cloud Autoscaler policy.
Generated from protobuf messagegoogle.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 theinitialization 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.
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.
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.
getCoolDownPeriodSec
The number of seconds that your application takes to initialize on a VM instance. This is referred to as theinitialization 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 theinitialization 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.
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 fieldoptional .google.cloud.compute.v1.AutoscalingPolicyScaleInControl scale_in_control = 527670872;
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.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Compute V1 Client - Class AutoscalingPolicy (1.35.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.35.0 (latest)](/php/docs/reference/cloud-compute/latest/V1.AutoscalingPolicy)\n- [1.34.0](/php/docs/reference/cloud-compute/1.34.0/V1.AutoscalingPolicy)\n- [1.33.0](/php/docs/reference/cloud-compute/1.33.0/V1.AutoscalingPolicy)\n- [1.32.0](/php/docs/reference/cloud-compute/1.32.0/V1.AutoscalingPolicy)\n- [1.31.0](/php/docs/reference/cloud-compute/1.31.0/V1.AutoscalingPolicy)\n- [1.30.0](/php/docs/reference/cloud-compute/1.30.0/V1.AutoscalingPolicy)\n- [1.29.0](/php/docs/reference/cloud-compute/1.29.0/V1.AutoscalingPolicy)\n- [1.28.0](/php/docs/reference/cloud-compute/1.28.0/V1.AutoscalingPolicy)\n- [1.27.0](/php/docs/reference/cloud-compute/1.27.0/V1.AutoscalingPolicy)\n- [1.26.0](/php/docs/reference/cloud-compute/1.26.0/V1.AutoscalingPolicy)\n- [1.25.0](/php/docs/reference/cloud-compute/1.25.0/V1.AutoscalingPolicy)\n- [1.24.0](/php/docs/reference/cloud-compute/1.24.0/V1.AutoscalingPolicy)\n- [1.23.0](/php/docs/reference/cloud-compute/1.23.0/V1.AutoscalingPolicy)\n- [1.22.1](/php/docs/reference/cloud-compute/1.22.1/V1.AutoscalingPolicy)\n- [1.21.0](/php/docs/reference/cloud-compute/1.21.0/V1.AutoscalingPolicy)\n- [1.20.0](/php/docs/reference/cloud-compute/1.20.0/V1.AutoscalingPolicy)\n- [1.19.0](/php/docs/reference/cloud-compute/1.19.0/V1.AutoscalingPolicy)\n- [1.18.1](/php/docs/reference/cloud-compute/1.18.1/V1.AutoscalingPolicy)\n- [1.17.0](/php/docs/reference/cloud-compute/1.17.0/V1.AutoscalingPolicy)\n- [1.16.2](/php/docs/reference/cloud-compute/1.16.2/V1.AutoscalingPolicy)\n- [1.14.0](/php/docs/reference/cloud-compute/1.14.0/V1.AutoscalingPolicy)\n- [1.13.0](/php/docs/reference/cloud-compute/1.13.0/V1.AutoscalingPolicy)\n- [1.12.1](/php/docs/reference/cloud-compute/1.12.1/V1.AutoscalingPolicy)\n- [1.11.1](/php/docs/reference/cloud-compute/1.11.1/V1.AutoscalingPolicy)\n- [1.10.1](/php/docs/reference/cloud-compute/1.10.1/V1.AutoscalingPolicy)\n- [1.9.1](/php/docs/reference/cloud-compute/1.9.1/V1.AutoscalingPolicy)\n- [1.8.3](/php/docs/reference/cloud-compute/1.8.3/V1.AutoscalingPolicy)\n- [1.7.1](/php/docs/reference/cloud-compute/1.7.1/V1.AutoscalingPolicy)\n- [1.6.1](/php/docs/reference/cloud-compute/1.6.1/V1.AutoscalingPolicy)\n- [1.5.0](/php/docs/reference/cloud-compute/1.5.0/V1.AutoscalingPolicy) \nReference documentation and code samples for the Compute V1 Client class AutoscalingPolicy.\n\nCloud Autoscaler policy.\n\nGenerated from protobuf message `google.cloud.compute.v1.AutoscalingPolicy`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Compute \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getCoolDownPeriodSec\n\nThe number of seconds that your application takes to initialize on a VM instance. This is referred to as the [initialization period](https://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.\n\n### hasCoolDownPeriodSec\n\n### clearCoolDownPeriodSec\n\n### setCoolDownPeriodSec\n\nThe number of seconds that your application takes to initialize on a VM instance. This is referred to as the [initialization period](https://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.\n\n### getCpuUtilization\n\nDefines the CPU utilization policy that allows the autoscaler to scale based on the average CPU utilization of a managed instance group.\n\n### hasCpuUtilization\n\n### clearCpuUtilization\n\n### setCpuUtilization\n\nDefines the CPU utilization policy that allows the autoscaler to scale based on the average CPU utilization of a managed instance group.\n\n### getCustomMetricUtilizations\n\nConfiguration parameters of autoscaling based on a custom metric.\n\n### setCustomMetricUtilizations\n\nConfiguration parameters of autoscaling based on a custom metric.\n\n### getLoadBalancingUtilization\n\nConfiguration parameters of autoscaling based on load balancer.\n\n### hasLoadBalancingUtilization\n\n### clearLoadBalancingUtilization\n\n### setLoadBalancingUtilization\n\nConfiguration parameters of autoscaling based on load balancer.\n\n### getMaxNumReplicas\n\nThe 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.\n\n### hasMaxNumReplicas\n\n### clearMaxNumReplicas\n\n### setMaxNumReplicas\n\nThe 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.\n\n### getMinNumReplicas\n\nThe 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.\n\n### hasMinNumReplicas\n\n### clearMinNumReplicas\n\n### setMinNumReplicas\n\nThe 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.\n\n### getMode\n\nDefines 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\"\nCheck the Mode enum for the list of possible values.\n\n### hasMode\n\n### clearMode\n\n### setMode\n\nDefines 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\"\nCheck the Mode enum for the list of possible values.\n\n### getScaleInControl\n\nGenerated from protobuf field `optional .google.cloud.compute.v1.AutoscalingPolicyScaleInControl scale_in_control = 527670872;`\n\n### hasScaleInControl\n\n### clearScaleInControl\n\n### setScaleInControl\n\nGenerated from protobuf field `optional .google.cloud.compute.v1.AutoscalingPolicyScaleInControl scale_in_control = 527670872;`\n\n### getScalingSchedules\n\nScaling 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.\n\n### setScalingSchedules\n\nScaling 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."]]