Bird
Raised Fist0
GCPcloud~10 mins

Request-based auto scaling in GCP - Interactive Code Practice

Choose your learning style10 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.

Practice

(1/5)
1. What does request-based auto scaling primarily adjust in a cloud service?
easy
A. The number of server instances based on incoming requests
B. The amount of storage space available
C. The network bandwidth allocation
D. The security settings of the service

Solution

  1. Step 1: Understand the purpose of request-based auto scaling

    Request-based auto scaling changes resources based on the number of incoming requests to handle load efficiently.
  2. Step 2: Identify what is adjusted

    The main resource adjusted is the number of server instances to match demand.
  3. Final Answer:

    The number of server instances based on incoming requests -> Option A
  4. Quick Check:

    Scaling adjusts instances = A [OK]
Hint: Auto scaling changes instance count, not storage or security [OK]
Common Mistakes:
  • Confusing scaling with storage or bandwidth changes
  • Thinking it adjusts security settings
  • Assuming it changes fixed resources regardless of requests
2. Which of the following is the correct way to set the minimum number of instances in a GCP service YAML configuration for request-based auto scaling?
easy
A. min-instances: 2
B. minInstances: 2
C. minimum_instances: 2
D. min_instances: 2

Solution

  1. Step 1: Recall GCP YAML syntax for scaling parameters

    GCP uses kebab-case for configuration keys like min-instances.
  2. Step 2: Identify the correct key format

    The correct key to set minimum instances is min-instances, not camelCase or underscored.
  3. Final Answer:

    min-instances: 2 -> Option A
  4. Quick Check:

    Use kebab-case keys like min-instances [OK]
Hint: Use kebab-case keys like min-instances in GCP YAML [OK]
Common Mistakes:
  • Using camelCase or underscores instead of kebab-case
  • Misspelling the key name
  • Confusing min-instances with max-instances
3. Given this snippet of a GCP service configuration for request-based auto scaling:
concurrency: 10
min-instances: 1
max-instances: 5

What happens when the service receives 50 simultaneous requests?
medium
A. The service scales down to 0 instances to save cost
B. The service stays at 1 instance because min-instances is set
C. The service scales up to 10 instances because concurrency is 10
D. The service scales up to 5 instances to handle the load

Solution

  1. Step 1: Understand concurrency and instance limits

    Concurrency 10 means each instance can handle 10 requests at once. Max-instances is 5, min-instances is 1.
  2. Step 2: Calculate needed instances for 50 requests

    50 requests / 10 concurrency = 5 instances needed, which matches max-instances.
  3. Final Answer:

    The service scales up to 5 instances to handle the load -> Option D
  4. Quick Check:

    Requests/concurrency = instances needed = 5 [OK]
Hint: Divide requests by concurrency, respect max-instances limit [OK]
Common Mistakes:
  • Ignoring max-instances limit
  • Confusing concurrency with max-instances
  • Assuming scaling down when load increases
4. You configured a GCP service with:
concurrency: 5
min-instances: 2
max-instances: 4

But the service never scales above 2 instances even under heavy load. What is the most likely cause?
medium
A. The concurrency value is too high, limiting scaling
B. The max-instances value is too low to allow scaling beyond 2
C. The min-instances value is preventing scaling down
D. The service needs a restart to apply scaling changes

Solution

  1. Step 1: Analyze max-instances and min-instances settings

    Max-instances is set to 4, min-instances is 2. Scaling cannot exceed max-instances.
  2. Step 2: Understand why scaling stops at 2

    If the service never goes above 2 instances, max-instances might be set too low or misinterpreted.
  3. Final Answer:

    The max-instances value is too low to allow scaling beyond 2 -> Option B
  4. Quick Check:

    Max-instances limits max scale = B [OK]
Hint: Check max-instances to allow scaling beyond min-instances [OK]
Common Mistakes:
  • Confusing min-instances with max-instances
  • Assuming concurrency limits scaling up
  • Forgetting to check applied config values
5. You want to optimize cost and performance for a GCP service that experiences unpredictable traffic spikes. Which configuration best balances fast scaling up and cost savings during idle times?
hard
A. Set concurrency to 1, min-instances to 0, max-instances to 10
B. Set concurrency to 50, min-instances to 5, max-instances to 5
C. Set concurrency to 10, min-instances to 1, max-instances to 10
D. Set concurrency to 100, min-instances to 10, max-instances to 20

Solution

  1. Step 1: Understand concurrency and instance settings impact

    Lower concurrency means more instances needed; min-instances controls baseline cost; max-instances limits scale.
  2. Step 2: Evaluate options for balancing cost and performance

    Set concurrency to 10, min-instances to 1, max-instances to 10 uses moderate concurrency (10), low min-instances (1) to save cost, and high max-instances (10) to handle spikes.
  3. Final Answer:

    Set concurrency to 10, min-instances to 1, max-instances to 10 -> Option C
  4. Quick Check:

    Moderate concurrency + low min + high max = balanced scaling [OK]
Hint: Moderate concurrency with low min and high max balances cost and spikes [OK]
Common Mistakes:
  • Setting concurrency too low causing many instances
  • Setting min-instances too high increasing cost
  • Setting max-instances too low limiting scaling
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard