You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Managed Instance Groups (MIGs) are the foundation for building scalable, self-healing applications on Compute Engine. Combined with autoscaling, MIGs automatically adjust the number of VM instances in response to load, ensuring your application can handle traffic spikes while minimising costs during quiet periods.
Autoscaling automatically adds or removes VM instances in a MIG based on configurable signals. When demand increases, the autoscaler creates new instances from the instance template. When demand decreases, it removes instances to reduce costs.
| Signal | Description | Use Case |
|---|---|---|
| CPU utilisation | Average CPU usage across all instances | General workloads |
| HTTP load balancing utilisation | Requests per second per instance | Web applications behind a load balancer |
| Cloud Monitoring metrics | Custom or built-in Stackdriver metrics | Queue depth, custom business metrics |
| Schedule | Time-based scaling on a recurring schedule | Predictable traffic patterns |
# Set autoscaling based on CPU utilisation
gcloud compute instance-groups managed set-autoscaling web-mig \
--zone=europe-west2-a \
--min-num-replicas=2 \
--max-num-replicas=20 \
--target-cpu-utilization=0.60 \
--cool-down-period=90
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.