QuestionQ128

VerifiedPlanning and implementing a cloud solution

You are running an application across multiple virtual machine instances within a managed instance group, with autoscaling enabled. The autoscaling policy adds instances to the group when CPU utilization exceeds 80%, continuing to add VMs until either the group reaches its maximum size of five VMs or CPU utilization drops back to 80%. The HTTP health check configured for the instances has an initial delay of 30 seconds.

You notice that the VM instances take approximately three minutes to become available to end users. When the instance group autoscales, it ends up provisioning more instances than are actually required to handle the current level of end-user traffic.

You want to ensure that the instance group size is properly maintained during autoscaling. What should you do?

Explanation

The VMs need about three minutes (180 seconds) to become ready, but the health check's initial delay is only 30 seconds. During the initial delay, the MIG ignores unsuccessful health checks because the VM might still be starting up, which prevents it from prematurely recreating the VM. With a 30-second delay, VMs that are still booting fail their health checks and autohealing can recreate them before they ever serve traffic. Setting the initial delay to 200 seconds, longer than the measured startup time, lets each new VM finish starting before failed health checks count against it. For the same reason, the autoscaler's initialization period (default 60 seconds) should also be set to about 180–200 seconds: the autoscaler only recommends scaling out if the average utilization from instances that are not initializing is greater than the target utilization, so a period shorter than the startup time lets it act on VMs that are still initializing. Lowering the maximum number of instances (A, B) only caps legitimate scaling capacity, and switching to a TCP health check (C) does not address the startup-timing issue.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!