Complete the code to specify the target CPU utilization for auto scaling.
autoscaler = compute_v1.Autoscaler()
autoscaler.autoscaling_policy = compute_v1.AutoscalingPolicy(
cpu_utilization=compute_v1.AutoscalingPolicyCpuUtilization(
utilization_target=[1]
)
)The target CPU utilization is set to 0.8 (80%) to trigger scaling when CPU usage exceeds this threshold.
Complete the code to set the minimum number of instances for the autoscaler.
autoscaler.autoscaling_policy.min_num_replicas = [1]Setting min_num_replicas to 1 ensures at least one instance is always running.
Fix the error in the autoscaler configuration by completing the blank.
autoscaler.autoscaling_policy.max_num_replicas = [1]max_num_replicas must be a positive integer greater than or equal to min_num_replicas. 10 is a reasonable max.
Fill both blanks to configure the autoscaler to scale based on request count per instance.
autoscaler.autoscaling_policy = compute_v1.AutoscalingPolicy(
custom_metric_utilizations=[compute_v1.AutoscalingPolicyCustomMetricUtilization(
metric=[1],
utilization_target=[2]
)]
)The metric for request count is "custom.googleapis.com/request_count" and the target utilization is set to 1000 requests per instance.
Fill all three blanks to create an autoscaler with a request count metric and set min and max replicas.
autoscaler.autoscaling_policy = compute_v1.AutoscalingPolicy(
min_num_replicas=[1],
max_num_replicas=[2],
custom_metric_utilizations=[compute_v1.AutoscalingPolicyCustomMetricUtilization(
metric=[3],
utilization_target=500
)]
)Minimum replicas set to 1, maximum to 10, and custom metric for request count with target 500 requests per instance.