Google Cloud Platform Part 2
Tags: gcp, googlecloud
Published: 2022-03-30 05:35:50

[See Google Cloud Fundamentals Part 1](https://dev.to/mitul3737/google-cloud-fundamentals-part-1-49bp)

**_Custom Machine Type_**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9oovsq5g8i55kipybb26.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jxrl3ltqbj61h1vf13so.png)

**_Instance Group_**
Group of VM instances managed as a single entity.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cr0ddwm11oc76b5rgg35.png)

There are 2 types of Instance groups. 1)Managed 2) Unmanaged
Managed Instance Group (MIG)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jaaa7tlu1zdlp00i9w0f.png)

Let's create managed instance group:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zfab15ufhbftz4n537en.png)
Under the Compute Engine, go to Instance Group

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/anfex24l8bt72smf18ya.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wflgrisbyij31r9p9cg3.png)
You may find managed and unmanaged groups there.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o3xxf9dolt6jsydlfdz7.png)
Managed (Stateful) is for database type of things. For web applications and APIs we use Managed (Stateless).

Let's create a Stateless Managed Instance:
1. First give it a name
2. Choose an instance template
3. Choose Multiple Zone
4. On the Auto Scaling. Choose minimum : 2 and maximum: 2
5. In Autoscaling metrics, you can see "CPU Utilisation","HTTP Load balancing utilisation", "Cloud monitoring metric". Choose CPU utilisation and keep the default value. 
6. Don't need to on Predictive autoscaling( checks last weeks data etc to scale)
7. You can select cooldown period where you will choose how long you want to wait before checking the metrics.
8. You can enable scale in counts. For example: you have 100 instacnces and you want to reduce each time 10 instacnes.You can choose Don't scale by more than : 10 and 10min which will reduce 10instancecs per 10 min.
9. In Auto healing , go to create a health check . Give it a name and change the protocol to "HTTP" . Under Health Criteria, check interval can be 5seconds to check instances after every 5seconds. If you choose 5 seconds for Timeout and the instance does not get any response for 5 seconds, it will be considered as timeout. Healthy threshold means how many consecutive success is needed to mark it as healthy. 
10. Initial delay (how much your instance need to boot up)
11. Press Create

**_Load Balancing_**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/la8fmiqjjx1rrov0k62v.png)
Create a Load balancer:
1. Go to Network services and choose load balancing.
2. Select HTTP(S) Load balancing. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tdhch84arc02vziq1oky.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s93btk4g18pr1hiqexb4.png)
Give the load balancer a name. 
The Backend Configuration is where we want to redirect the incoming traffics. Here we are going to use Managed Instance Group as Backend Configuration. From there create a Backend service.
Use Cloud CDN, if you want to cache static contents like HTML, CSS.
Add health Check and then create .


Host and path rules has rules how one ones to redirect traffic to the back end. Keep host and path empty and instance group as selected to send traffic to the instance group. 

Frontend Configuration is where you would receive the traffic.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9kuw2hgx9iomr01uh5s2.png)
and done. Go to review finalize and Create. 

The load balancer is ready.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6mtwl04qdr4m96k2rx5q.png)