[MUSIC PLAYING]
ROGER MARTINEZ: If you need to deploy
a large number of identical virtual machines,
then Google Cloud's Managed Instance Groups
is the best way to do that.
But its autoscaling feature is what
takes it to the next level.
So let's take a look at a configuration
to see what it looks like.
So let's start by going over here to the navigation menu
and going down to Compute Engine and then
over to Instance Groups.
So what I have on this project is
one managed instance group called web-app.
So let's click here to go to the overview page,
and we'll see that this managed instance
group has three instances only.
So each instance in this instance group
is just an HTTP application that returns some basic instance
information up here.
It also has some built-in functionality
that lets me increase the load on each instance
in the form of CPU utilization.
So let's initiate that on each of these machines.
Now on the second one, and the third.
So now, on each of these instances,
the application is consuming more and more CPU.
As you can see in the Overview page,
I have autoscaling enabled on this managed instance group.
Let's take a look at the configuration.
So what we have is a regional managed instance
group, distributed across three zones in the US Central region.
And if you go down here, you'll find the autoscaling
configuration.
If you have an existing managed instance
group without autoscaling enabled,
you'll have instead down here a button that
says Configure autoscaling.
So I'm going to talk about a few of the options
that you have in the autoscaling configuration.
First, you'll want to choose what you want your autoscaling
to be triggered by.
And you can choose from any of these three metrics--
CPU utilization, load-balancing utilization, and Stackdriver
monitoring metrics.
Depending on your use case, you can
choose one of these or a combination
by just clicking Add new metric.
Next, you'll want to choose a minimum and a maximum.
I'll set my minimum to 3, because I
have a regional managed instance group,
and I want to make sure I have at least one instance in each
of my three zones.
If you know that it takes a while for your instances
to initialize after boot time, there
are three settings that you'll want to pay attention to.
So the first one is the cooldown period.
So the cooldown period is also known as the application
initialization period.
It's important because when an application on an instance
is initializing, the usage might not
reflect normal circumstances.
So the autoscaler will not take into account
the usage data from this time period
when it decides to scale in or out.
Second is the scaling controls down here.
So scaling controls let you set a limit
to how quickly the autoscaler scales your instance group down
to avoid any sudden drops in the number of instances.
So this isn't required, but it will help you optimize cost
by avoiding turning down too many instances too quickly,
only to have to wait for new ones provisioned immediately
after.
And finally, there's predictive autoscaling.
So predictive autoscaling feeds your instance
groups' historical trends and current load
into a machine-learning model so that you can
anticipate autoscale events.
So this is going to improve the availability, because instead
of scaling up reactively due to a metric threshold like CPU,
the instance group will scale up in anticipation of the load
that it predicts will happen based on real-world usage.
So if your application takes time to start up,
this is going to be very valuable in helping
ensure that your instance group is ready to handle
an increasing load when it happens,
without having to wait too long for initialization.
Together, predictive autoscaling, scaling controls,
and an accurate cooldown period will
increase availability and optimize spending on resources.
So if we go back to our Overview page,
we'll see that the autoscaler has already
started to provision additional instances
to accommodate the CPU load of the group.
Once that load is reduced, it'll scale back
according to the scaling controls
that I specified before.
That was a super quick look at the autoscaling configuration
of a managed instance group.
When you're using managed instance groups
on Google Cloud for your application,
its autoscaling is a really useful and powerful feature.
With the right settings and configuration,
you can increase your availability
while reducing costs associated with compute resources.
[MUSIC PLAYING]