Professional Cloud DevOps Engineer
Prepare and test your skills
Prepare and test your skills
Worked example. The correct answer is already marked and every option is explained below, so there is nothing to select here. To answer questions yourself, start the free trial.
Your company runs an asynchronous batch-processing workload on a Compute Engine Managed Instance Group (MIG). The worker instances consume compute-heavy image rendering tasks from a Cloud Pub/Sub subscription.
During unexpected marketing campaigns, massive influxes of messages arrive in the subscription. The current CPU-based autoscaler reacts too slowly to these sudden surges, resulting in high message processing delays. Furthermore, you need to ensure that the autoscaler does not prematurely scale in instances while tasks are still in progress.
How should you configure the autoscaling policy for the Managed Instance Group to rapidly absorb these traffic surges?
Cloud Pub/Sub queue metric autoscaling allows a Managed Instance Group (MIG) to dynamically resize based on the backlog of work waiting in a specific subscription. The metric pubsub.googleapis.com/subscription/num_undelivered_messages measures the total count of unacknowledged messages, including both pending messages in the queue and messages actively being processed by worker VMs.
num_undelivered_messages includes in-flight messages that have been pulled but not yet acknowledged, the metric will not prematurely drop to zero while instances are still rendering images. This prevents early termination of active workers.singleInstanceAssignment) defines the exact capacity (e.g., 10 messages per VM) that each instance can comfortably handle concurrently, allowing the autoscaler to compute: Target Replicas = Total Unacknowledged Messages / Single Instance Assignment.resource.labels.subscription_id) to isolate scaling signals to the exact workload queue.CPU-based scaling is a lagging indicator for message-driven architectures, whereas queue depth is a leading indicator. Configuring num_undelivered_messages with a single VM instance assignment ensures direct, deterministic scaling proportional to queue size.
Keep the momentum going with these hand-picked practice scenarios
Want more questions like this?
Get a free certification question every week.