0
0
GCPcloud~10 mins

Request-based auto scaling in GCP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the target CPU utilization for auto scaling.

GCP
autoscaler = compute_v1.Autoscaler()
autoscaler.autoscaling_policy = compute_v1.AutoscalingPolicy(
    cpu_utilization=compute_v1.AutoscalingPolicyCpuUtilization(
        utilization_target=[1]
    )
)
Drag options to blanks, or click blank then click option'
A0.4
B0.6
C1.0
D0.8
Attempts:
3 left
💡 Hint
Common Mistakes
Using values greater than 1.0 which is invalid.
Setting too low a target causing frequent scaling.
2fill in blank
medium

Complete the code to set the minimum number of instances for the autoscaler.

GCP
autoscaler.autoscaling_policy.min_num_replicas = [1]
Drag options to blanks, or click blank then click option'
A1
B0
C5
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Setting minimum replicas to 0 causing no instances to run.
Setting too high minimum causing unnecessary cost.
3fill in blank
hard

Fix the error in the autoscaler configuration by completing the blank.

GCP
autoscaler.autoscaling_policy.max_num_replicas = [1]
Drag options to blanks, or click blank then click option'
A1000
B0
C10
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using negative or zero values for max replicas.
Setting max replicas too high causing cost spikes.
4fill in blank
hard

Fill both blanks to configure the autoscaler to scale based on request count per instance.

GCP
autoscaler.autoscaling_policy = compute_v1.AutoscalingPolicy(
    custom_metric_utilizations=[compute_v1.AutoscalingPolicyCustomMetricUtilization(
        metric=[1],
        utilization_target=[2]
    )]
)
Drag options to blanks, or click blank then click option'
A"custom.googleapis.com/request_count"
B1000
C0.8
D"compute.googleapis.com/instance/cpu/utilization"
Attempts:
3 left
💡 Hint
Common Mistakes
Using CPU utilization metric instead of request count.
Setting utilization target as a decimal instead of a count.
5fill in blank
hard

Fill all three blanks to create an autoscaler with a request count metric and set min and max replicas.

GCP
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
    )]
)
Drag options to blanks, or click blank then click option'
A1
B10
C"custom.googleapis.com/request_count"
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Setting min replicas higher than max replicas.
Using wrong metric string for custom metric.