Creating Compute Instance Group

Instance groups

In the last lesson, we looked at Compute instances and how to connect to them for different OSes. The Compute Instance is a fundamental unit for all complex architectures or high availability architectures. Let’s look at one of the ways to handle a large load using Compute instance.

Definition

An instance group is a method to manage a group of instances as a single entity. Instance groups let you organize VM instances or use them in a load-balancing backend service. You can group existing instances or create a group based on an instance template. There are two ways to group instances.

Managed instance group

Managed instance group allows us to have multiple copies of the same instance. A template for an instance is created and the managed instance group creates the specified number of live instances from that template.

This method is used in Autoscaling. We will soon see what autoscaling is but, in short, automatically creating or deleting instances based on the traffic or different metrics is called Autoscaling.

Managed instance group is good for stateless applications where instances are not used for storing any data in them. However, Google Cloud recently launched Instance groups for stateful applications as well. But it is advised to use managed services for stateful applications for reliability.

Unmanaged Instance group

Unmanaged instance group does not use any template and instances having different configuration are grouped together. This type is not used in autoscaling. And also it is recommended to use the managed instance group whenever possible. Maintaining the unmanaged instance group is a tedious task as it includes different types of instances.

Autoscaling

Autoscaling is a must to have for end-user-facing workloads which get irregular traffic. The different metrics such as CPU usage, memory usage, and any log entries are used to automatically create or delete the instances to meet the user demand and save cost when there is not much load on the servers.

Let’s create a managed instance group and see the autoscaling in action.

Creating an instance group

We will focus on the managed instance group for stateless applications in this course. To create an instance group, go to,

  • Main menu > Compute Engine > Instance group.

  • Click on the Create Instance Group button. (Keep the selected category of managed instance group for stateless apps.)

A form will be displayed to create an instance group. Let’s understand the fields one by one.

  • Name: You can provide any hyphen-separated alphanumeric name. Let’s use “instance-group-demo” for now.

  • Description: Optional. Describe the purpose of what this group is created or any other information.

  • Location: Choose the location. The single zone will create instances at one location as opposed to multiple locations when multiple zones are selected.

  • Instance Template: To create new VMs immediately, we need to provide an instance template. You can select the existing one or click on Create a new instance template in the dropdown. Since we don’t have any template created click on the Create a new instance template button. This will open the same exact form we used to create a VM.

Get hands-on with 1200+ tech skills courses.