This video explains Google Cloud's Managed Instance Groups (MIGs) as a fundamental service for building highly available and scalable applications, contrasting them with unmanaged instance groups and demonstrating key features like auto-healing, auto-scaling, and load balancing through a hands-on lab.
Mind Map
Clic para expandir
Haz clic para explorar el mapa mental interactivo completo
foreign [Music]
[Music]
in this video we are going to learn
about what are managed instance groups
how are they different from unmanaged
instance groups we will also look at the
features of make offers which is auto
scaling Auto healing load balancer we
will do a live Hanson lab where we will
see all these things in action not just
theoretical part this video is very very
important make sure you watch it
completely because whatever Services you
use on Google Cloud whether it's
kubernetes or bigquery or any other
product most of the services backbone is
Mig so if you understand Mig is really
well your life is really easy while you
work on your projects so basically
compute engine offers two kind of
managed and unmanaged so far in the
course we have been using unmanaged
instance groups first of all let's try
to understand what is the difference
between managed and unmanaged Minister
scrubs unmanaged instance groups lets
you load balance across a fleet of VM
that you manage yourself which means we
have to manage our instances what is the
size or how many times you want to keep
it up if you have to add servers if you
delete servers everything is under our control
control
right Google did not help us to manage
those things however we'll talk about
managed instance groups managed instance
groups are basically a collection of
virtual machines that can be used as a
single entity
and its instance groups let you operate
applications on multiple identical VMS
we can ensure that our applications
hosted on Mig instances are highly
available we can also take advantage of
automated mixed services like Auto
scaling Auto healing Regional
multi-reason multi-zone deployments and
automatic updating so these Concepts
like Auto healing Auto scaling auto
updating these things are you know not
something which you use day in day out
so let's try to understand them one by
one what is auto healing whenever a
service goes down the the VM will
restart itself okay the VM will kill
itself without any manual intervention
it will restart itself and start serving
the traffic how to configure that we'll
see this in this video itself second is
multi-zone so you can have your one
instance deployed in your Center one one
instance in U.S east one so that's how
you can distribute your workload across
different zones within one application
what is load balancing you can have
multiple instances in different zones
and you can distribute the traffic while
load balancers the fourth bit is around
Auto scaling so whenever something
whenever a load Peak load happens you
need to ensure that you're increasing
the size of your Fleet which is your
number of VMS should increase to
accommodate the traffic
that's where Auto scaling comes in we'll
try to see that auto scaling also in
action the last bit is auto updating so
whenever we have some safe type of
updates auto updating helps us to update
update our operating system patch any of
those things are done
make instances are ideal for stateless
survey for all sort of batch workloads
or stateful applications
that's the basic difference between
managed and unmanaged instance group you
can also deploy new versions without any
downtime under under management
subscript which is making instances
before we move to understand the
management stress group in detail let's
try to understand what is auto scaling
so suppose one of the examples in terms
of this IPL season today IPL is
happening okay so whenever in your first
and second over suppose you are able to
serve with two servers or entire traffic
the in the third over what happens Ms
dhoni or maybe a Virat Kohli comes to
bat suddenly the number of users will
increase and you'll have to add two or
three more servers to address the peak
load when they get out or you know the
match is finished the traffic will
reduce gracefully
and then you have to shut down your
servers to come back to the same load
which you are able to serve when you
started the map that's the basic graph
of Auto scaling as your demand grows you
have to scale your VMS and as your
demand falls down you scale down your
VMS right that's what Auto scaling
actually looks like that's one of the
example I thought to give you now let's
go ahead and understand what it takes to
create a management sense group the most
basic part is instance template if you
have an instance template you can create
a medicine instance group you can also
create it unmanageable what is instance
template instance template is basically
a resource that we can use to create
virtual machines instance templates are
very very convenient way to save a VM
configuration and then we can later
create VMS group of VMS or reservations
later on why because it gives us a
template and when we have to Auto scale
we have everything ready we just have to
create one replica of it and it's not us
we will configure it Google will create
it for you that's the benefit of using
make instances so instance template
basically will Define what is the series
and machine type you're using service
account your boot disk OS image if you
want to run a container image just pass
that the labels the startup script Network
Network
everything right so you just figure out
uh you just said that you set all these
details in in your templates and it will
boot up your disk it will boot up your
VM wherever you uh Auto scale or descale
or when you create it so that's
templates serves as a read-only copy
very important concept instance
templates are designed to create
instances with identical configuration
so you cannot update the existing
instance templates or change any
template after you create it so it
becomes a read-only copy so you just
have to create another version if you
want to make any changes okay that's
very important and we you cannot go
ahead and change an instance template
once it is submitted to understand this
we are going to do a lab which has these
steps the first step is to create an
instance template and to deploy nginx
with all required properties in multi reasons
reasons
then we'll be creating an auto scale
link then we will be creating an auto
scale manage instance group using that
same instance template which we create
in the first step third step is around
creating a health check than creating a
load balancer stopping the nginx to see
auto healing in action increasing the
road to see auto scale interactions
right so this is the architecture we are
going to do in lab
see you at the labs
first of all we have to create an
instance template to deploy nginx with
all required properties in multi-ts so
what we'll do we'll go ahead and create
an instance
for that we'll come to this we'll come
to the console and click on compute engine
engine
over here you'll see instance template
as I mentioned we have to create an
instance template click on instance
template click on create instance template
template
you can give a meaningful name say cloud Sprint
Sprint template
in series N1 and give me F1 micro which
which is the most cheapest one
okay I'll go ahead if you want to deploy
a container with every VM you can pass a
container over here but in this case we
just want to use the startup script so
I'm not putting any container name here
I'm just using Debian as a image
I'm not changing any of I'm not changing
the service account just keeping a
default one but if you want to choose
you can choose here
everything is by default I am going to
allow HTTP in HTTPS next is Advanced
option now network is I'm putting it as
default what I want to add is uh
Management in here I want to pass a
startup script which will install nginx
and set it up for me for that I'm just
going to use this script but it will do
it will first of all update the voice it
will install nginx start the service and
then it will it will replace this HTML
file with the host name so we will know
that which host name we are being served
the traffic from
nothing else I don't want to change
anything it should be standard
let's click on create so this will
create an instance template very very
quickly for me okay once the template is
created we can move to the Second Step
meanwhile this template is getting
created we will go ahead and check what
is the second second step is we need to
create an auto skilled managed instance
group using the same instance template
now you can see this instance template
is created with Cloud Sprint template
name machine Type image name disk and
everything else is here
you can create a virtual machine from
here or you can create an instance group
from here okay let's go to instance
groups we don't have any instance group
existing uh for for now the Second Step
was to create an instance group using
the same template so click on create
instance scope you can see here many
type of options you have first is
unmanaged instance Group which is uh
we're not going to use in this case we
are going to use the managed one then
there are two type within managed it's
stateless and stateful stateless is uh
basically for serving and batch
processing stateful is used for
databases or Legacy applications I have
to choose the instance template now okay
which we just created Cloud Sprint
template what I'm going to do is just
let it be no changes now the requirement
was I have to create this in multi-zones
so what is the meaning of multi-zone
suppose you have customers from
different different areas within us you
can choose to serve a few of your
servers can be in one C area few of your
servers can be one F zone so you can
serve the customers from all these areas
in a better way to avoid latency they
can have the better user experience so
I'm going to choose these two you can
choose more if you need and target
distribution shape is even or balanced
so I'll just put even for now
okay next step is auto scaling in a
nutshell Auto scaling is all about
automatically adding and removing
instances to the group for a period of
high and lows but what I'm going to say
I need two minimum instances and maximum four
four
okay a minimum means that every time
these number of instances will be
running maximum is irrespective of
whatever the load is I'm I'm not asking
you to create more than four VMS while
working with free tier you might get
issues when you try to create more than
your quota which is by default I think
it so try to test it within that range itself
itself
now when you want the auto scaling to
happen you want signal right it will
work on an event so by default it is if
CPU relation is more than 60 percent it
will create another instance now what is
Target CPU utilization 60 50 40 80 you
can choose depending on your application
how much time your new node is taking uh
to be ready you can choose depending on
that okay click on done if if I want to
add another signal I can choose HTTP
load balancing you need if any based on
some event I want to add suppose I want
that when an e somebody uploads a file a
VM should get added to to this node pool
to create to process that request so
that I can do here any monitoring
metrics I can check here so you can add
different type of singles in this
example we are using CPU utilization
then you have cooldown period this is
very very important concept uh this
basically specifies that how long it is
going to take your app to initialize
okay how long it is going to take your
app to initialize from boot up time
until it is ready to serve what happens
you add a server okay you add a server
and you are still not able to serve the
traffic from that that VM because your
application is not set up properly
that will give a 404 error and that's a
bad user experience so you should ensure
once your website uh once your server is
up and ready it's already boot up how
much time it will re it will take your
app to initialize in this case it is
nginx all right so um in this case we
are saying 60 second I believe 60 second
is more than enough to uh for nginx to
set it up and get started next is about
keeping the instance life cycle I'm not
going to change anything yep next bit is
around Auto healing
what is auto healing Auto healing will
recreate VM instances if an application
cannot be reached by the health check so
health check is an entry let's create a
new health check
say cloud
Sprint let's see what it will do it will
it's send
request every seconds whatever you
configure so in this case the criteria
we're going to find is check intern
values every five second timeout is five
second healthy threshold two consecutive
success is unhealthy threshold two
consecutive success so basically if
twice it will try two times okay if your
your service is not responding it will
Mark your instance as unhealthy and
based on that kpi you your instance will
be recreated that is the benefit of Auto
healing so if if this kind of situation
is happening at 1am or 3 am nobody have
to sit manually and you know recover
that this Auto healing feature will take
care of your instance it will remove the
node which is not able to serve and
create a new one that's the benefit of
Auto healing again we have 300 seconds
of initial delay to ensure that it is
warmed up we just chose the template the location
location
Auto scaling policies
and sixty percent Auto healing policies
Auto healing policies and Port 80 and
I'm going to create the instance group
it will take some time to get created
I'll be back once it is ready
okay so within two minutes the instance
is created you can see we had requested
minimum two number of instances it was
created at this time the instance is
ready template we used is this and
instance are healthy we have used this
CS health check for uh for the health check
check
for auto healing basically and for auto
scaling we have said that whenever CPU
utilization is more than 60 just scale
one uh add one more node and maximum can
be four so these are configurations we
did while uh you know installing it
let's go ahead and check if our nginx is
okay you can see uh you are being served
from Google welcome to Google Cloud
platform you're served from this
instance Group which is uh
7p67 right 7p67
this
you'll be you'll get that you're being
served from 641 641 okay why uh I change
this script like this because when you
use use load balancer you will be able
to see this in action that how the
traffic is balanced between uh two
different VMS deployed in different
zones like this is deployed in C this is
deployed in F so when you get customers
from C this will serve the request when
you get from this Zone this will solve
request so they can have a better user
experience that's the benefit of having
multi-zone deployments to have a highly
available application coming back to
here we have created an instance
template in multi-reason installed nginx
Auto scaled manage instance group using
the instance template the third step was
to create the health check for auto
healing we also did that the fourth step
is to create a load balancer to
distribute the traffic among VMS added
this is the architecture diagram that's
what we have to do so we have we are
done with the right bit where we have
set up the managed instance group now we
have to create a load balancer so
customers can directly reach to this
reload balancer and we can serve them
from these different VMS hosted in
different zones go ahead and create a
load balancer to create a load balancer
we need to go to network Services load balancing
balancing
load balancing create a load balancer
here you will get three type of load
balancer while we study load balancers
in detail I'll be you know showcasing
all the examples but just for now you
can understand we'll be using https
because this is mostly used for internet
facing or internal single or
multi-regional kind of uh application
click on start configuration to create one
one
or the first thing is internet to my VM
yes I the second option could be between
my VMS but I need from internet to my VM
next is global HTTP load balancer
classic uh the classic one is not having
the traffic redirected rules so we
should use the newer one which we may be
we never know we might need the traffic
redirect the rule as well in future
click on continue your select a name
front end protocol
Port will be 80 done
okay we have added front-end ipn port
next is back-end configurations in
backend configurations we have to create
a backend service
let's click on create a backend service
I'll say cloud CS backend service
backend type can be instance group it
can be serverless it can be private
service connect and hybrid these all are
big options okay you can you can choose
as you need tomorrow when you
extensively work you can choose them
back and type in this example I'm going
to choose instance groups HTTP timeout
is 30 seconds
new instance group so this is the
instance Group which we have created I'm
saying port number is 80.
port number is 80 okay I don't want CDN
in this case
health check I'm saying okay yes I have
health check I'll use CS health check
no security policy for now click on create
create
say okay
so I have said that my front end
configuration is there as a backend
configuration I have added my instance
group so whatever I have hosted on my
instance group that can be served here
I'll give a name and I click on create
so this will create a load balancer for
me which has these two VMS added as
their backend alright so this load
balancer creation is completed we'll
open this and see if we are able to open
the website
okay perfect so we are being served from
this instance 7p 67.
okay so you can see that uh we are being
served from 7p67 this one okay this
completes the step four as well okay
you can see we have created a load
balancer hosted a compute Engine with
nginx we are able to create a health
check we'll see that also in action
now I'm going to I'm going to show you
two steps first is stopping the nginx
this will help us see auto healing in
action also how a load balancer helps us
to you know route the traffic to a
different node whenever something is not
healthy you can see now we are being
served from 7p 67 VM so I'll just log in
here SSH
okay I am here now what I need to do is
first of all what I'll do I'll stop the
nginx service
what I'm doing I'm stopping the nginx service
service [Music]
okay you can see it's stopped
you can see it's dead so we stopped the
nginx service which means
this particular VM which is uh which is
sp 67 is not able to serve the traffic
now two things will happen Auto healing
will come into the action first of all
see how load balancer will help us so so
far we are being served from this
particular VM you can see it's dead now
it's being recreated that is the benefit
of Auto healing so somehow your service
stopped working and you are not able to
solve the traffic from that VM so Auto
healing will check that okay instance is
not healthy this health check will check
it and recreate your VM that's the first
part of
Auto healing the second bit is now we
have only one VM running which means
that traffic which was being served from
this VM should shift to this VM that's
why we pay for load balancer let's go
ahead and check if that is happening enter
enter
yes you can see the traffic has shifted
to 641 VM which is the active and
healthy one
right that is the benefit of using load
balancers so load balancers
automatically the through health check
got to know that this 7p 67 is unhealthy
and I need to shift the traffic to 641
for a seamless migration that is the
benefit of using um using Auto healing
with load balancers
right I hope this you are able to follow this
this
now with auto healing this VM is being
recreated it will take approx two to
three minutes to get recreated set it up
depending how much delay we have given
and yeah you can also see this instance
health is down to 50 percent this VM is
recreated and this will be it will be up
and running once it is up and running it
will again start serving the traffic but
for now we will have to serve all the
traffic from this uh one six four one BM
because and this will be sort for entire
Zone unless this Zone uh VM unless this Zone
that's how you design a highly available
architecture even if your Zone goes down
you can still serve your customers you
can see now it is updating which means
which means this instance is being replaced
replaced
so far we have completed all these steps
the only step remaining is to increase
the load and see auto scaling in action
once we are recovered from the auto
healing once auto auto healing VM is
available we will see auto scaling in
action so you can see finally with this
it is showing that one VM is active
serving the traffic another one is not
healthy and it is being recreated
it is being recreated and it is being
updated with the new it is using the
same instance template all right so
perfect so it's ready to again serve our
traffic and it has recovered itself it
has healed itself let's go back and try
to access it six four one yes it is back
to sub backend serving the traffic
healthy okay that's the that's how Auto
healing works and that is how it is
going to save you a lot of midnights
where you can peacefully sleep and let
Auto healing take its new own course
and also you understood that how load
balancer will help you to you know
balance the traffic between these two or
more begins and uh if one in zone goes
down you can serve the traffic from
other Zone just by simple configurations
which we did in this video
the last bit in this video I want to
cover is auto scaling
to manage Auto scaling first of all
simply understand we have set maximum
four uh instances we can get added and
once our
CPU utilization goes beyond 60 then only
adds add VMS so what I'm going to do
since I don't have a live traffic I'm
going to simulate a traffic to simulate
the traffic what I'm going to do I'm
going to install stress it will
basically simulate a load for me let me
install it
okay it doesn't start I'm going to
increase the load this will
create simulator load and stress that
the CPU and it will increase the
significant timeout okay let me click
enter it let's see how it is increasing
the load
and there are many ways to see it you
can just go to this particular VM
what it will do it will increase your
load and how to see that you can click
on observability
and just see your instance increasing
then Note One Thing even if one VM
utilization is 100 overall utilization
has to increase then only Auto scaling
will work it's not like you have just
one VM running at 80 percent overall
it's still less than 60 it is not going
to add any servers so for overall
monitoring we'll come here okay perfect
perfect you can see now
you can see now stress command is
completed and it increased my load more
than 60 60 percent and I have two more
VMS added it is of course not in healthy
condition but it is being verified so I
have four instances Auto scaling is an
action kicked in initial delay which we
have put that is it is warming of the
instances and it will start serving the
traffic once it is available and ready
to be served right a simple load I just
increase the load and you can see auto
scaling happening in action without any
changes so okay you can see we have two
got two more friends to help us to you
know serve with this load and we are
able to quickly add two more servers go
ahead and see if we can get a service
from new VMS you can also check
the current load you can see the current
load has just is decreasing so the
moment overall utilization comes below
60 percent these two new nodes will go
we'll again come back to our minimum in
configuration which is two
that is what I explained at Auto scaling
uh happens so when you have load you add
the servers when the load is gone you
remove them automatically you don't do
anything just configure the kpis and
Google Cloud make instances will help
you to do that you can also see it is we
are being served from new VMS now okay
well one end was not there again one six
four one we are being balanced seven P
sixty seven so it is just shifting the
traffic to new new VMS and whatever is
where available it is being served from
there okay now I'm not going to do
anything I'll just wait for the load to
settle down once load is settled down
these two VMS should go away which we
just added as our Auto scaling I'll be
back once it scales down
okay now you can see the load has gone
down and it has started updating the VMS
so first thing it is doing it is
deleting the fourth wheel which was just
added as uh okay it started deleting
this one as well right so that's how
the moment the load got reduced it is
deleting these two VMS and we'll be left
with the minimum configuration which is
two right see those two instances have
been removed I mean we are going back to two
two
just to give you a recap we created
instance template
we created an instance group
we created a load balancer we created a
health check tested Auto overhealing we
created Auto scaling policies and we
have latest tested Auto scaling
hope this was an informative video and
you are going to go ahead and try your
hands on this lamp thanks for watching
all right so this concludes the big
instance group I hope you like the video
and if there's any question just please
drop a comment and let's try to discuss
them yeah thanks for watching see you in
the next one foreign
foreign [Music]
Haz clic en cualquier texto o marca de tiempo para ir directamente a ese momento del video
Compartir:
La mayoría de las transcripciones están listas en menos de 5 segundos
Copia con un clicMás de 125 idiomasBuscar en el contenidoIr a marcas de tiempo
Pega la URL de YouTube
Ingresa el enlace de cualquier video de YouTube para obtener la transcripción completa
Formulario de extracción de transcripción
La mayoría de las transcripciones están listas en menos de 5 segundos
Instala nuestra extensión para Chrome
Obtén transcripciones al instante sin salir de YouTube. Instala nuestra extensión de Chrome y accede con un clic a la transcripción de cualquier video directamente desde la página de reproducción.