I have a managed instance-group in a project in Google Cloud Platform. My instance group is using the smallest predetermined machines that GCP offers, the f1-micro (more info here: https://cloud.google.com/compute/docs/machine-types#sharedcore)
I have autoscaling enabled on my instance group with these settings:
gcloud compute instance-groups managed set-autoscaling [my-ig] \ --region us-central1 \ --min-num-replicas=3 \ --max-num-replicas=15 \ --cool-down-period=250 \ --scale-based-on-cpu \ --target-cpu-utilization=0.9
I have some strange behaviour where after some small/short peaks in cpu usage the autoscaler decides to massively autoscale my instances, just to then go back to the original number a few minutes later.
This is how a cpu-graph of my instance group looks like, in this screenshot the instance group had no autoscaling and it has 3 instances running my app:
To me, those instances don't look like they need to autoscale, they seem stable with the power they have, and in practice, the website does perform very good.
This is what google says about that type of vm instance:
f1-micro machine types offer bursting capabilities that allow instances to use additional physical CPU for short periods of time. Bursting happens automatically when your instance requires more physical CPU than originally allocated. During these spikes, your instance will opportunistically take advantage of available physical CPU in bursts
My problem is:
- Are those spikes in that graph normal, given that each vm instance has 0.2 shared cpus? Or those spikes should not be there even though the machine is so small?
- With autoscaling on, the autoscaler starts adding instances like crazy on each rising edge of the cpu activity, when in reality if you average the cpu, there were no real spikes in cpu usage, just small bursts that quickly stabilized.
My options (I think) are:
- use less instances but of a larger size
use some stackdriver graph that averages cpu by 10minute average(too expensive)
- disable autoscaling and do it manually
- fix the cpu spikes in my code (if possible, in case it is not a normal behaviour of micro VMs)