DEV Community

Cover image for Azure vs GCP part 12: Virtual Machine - Scaling (GCP)
Kenichiro Nakamura
Kenichiro Nakamura

Posted on

Azure vs GCP part 12: Virtual Machine - Scaling (GCP)

In previous article, I use GCP VM (GCE) to host my application, as single instance.

I look into scaling options like I did for Azure for GCP.

Availability

Repeat from Azure post, but one of the reasons why I recommend multi-instance is availability. There are two types of concerns.

  • Hardware failure
  • Software update

Managed Instance Groups

A group contains identical VMs and offer auto-scale. It uses instance template as seed image to add additional VM when load exceeds threshold. There are two types of managed instance groups.

Zonal managed instance group

All VMs runs in same group. This article
says "single failure events will affect only a single zone". Thus I assume it may cover software update, but I still have issue with hardware failure.

Regional managed instance group

VMs run in multiple zones in a region. This should cover hardware failure too, unless entire region goes down.

Load balancer

GCP also offers load balancer but it gives more option than Azure.

Global external load balancing

  • HTTP(S) load balancing: Distributes HTTP(S) traffic among groups of instances based on proximity to the user, the requested URL, or both.
  • SSL Proxy load balancing: Distributes SSL traffic among groups of instances based on proximity to the user.
  • TCP Proxy load balancing: Distributes TCP traffic among groups of instances based on proximity to the user.

Regional external/internal load balancing

Distribute network traffic in one region

  • Network load balancing: Distributes traffic among a pool of instances within a region. Network load balancing can balance any kind of TCP/UDP traffic.
  • Internal load balancing: Distributes traffic from Google Cloud Platform virtual machine instances to a group of instances in the same region.

Let's try!

Enough talk, now let me try.

Create Custom Image

To start off, I need to create windows image which contains application.

1. Login to VM which contains the application via RDP.
image

2. Open PowerShell as administrator and run following command.

GCESysprep
Enter fullscreen mode Exit fullscreen mode

3. Go to "Images" and click "CREATE IMAGE".

4. Specify necessary parameters. Set source as Disk and source disk which you just generalized. Click "Create".

image

Create Instance Template

Next, create instance template from the custom image.

1. Go to "Instance templates" and click "Create instance template".
template

2. Enter name and select machine type. Click "Change" for boot disk.
template

3. Click "Custom images" and select the created image.
template

4. If the application requires access to any resources in GCP, set "Identity and API access". In this case I don't need any. Enable "Allow HTTP traffic". Click Create.
template

Create Instance Groups

Now, as I have template image, I go ahead to create instance group.

1. Go to "Insatnce groups" and click "Create Instance Group".
group

2. Enter name, and specify "Location". I select "Multi-zone" here.
group

3. Specify "Instance template" as created template, and set "Autoscaling" to "On". I use default values but you can tweak it.
group

4. In addition to autoscaling, I can set Autohealing.
group

5. Wait until creation completes. Then select the created instance group. There are running instances showing with public IP.
group

6. Access to the public IP to check the application.
group

Create Load Balancer

When autoscaling kicked in, there are multiple instances. To give users single access point, add load balancer.

1. Go to "Network services" | "Load balancing", then click "Create load balancer".
lb

2. As I need to load balance HTTP, select "HTTP(S) Load Balancing".
lb

3. Enter name nad click Create. Select "Backend configuration" and create new background service.
lb

4. Select created instance group, and select balancing rule. I use default rule here. Click "Done".
lb

5. Click "Health Check" and create new one.
lb

6. Now I can click "Create" button.

7. I use default rules and configuration for the rest. Click "Create" to create the load balancer. Wait until creation completes.

8. Once load balancer created, select it. Check the global IP.
lb

9. Access to the IP to confirm the page is loaded.
lb

Quote

As I am using Free trial account, there are certain quota that I cannot exceed. If I keep accessing the endpoint and let keep auto scale happen, then I exceed my limitation.

1. Go to "Instance Groups" and open the one I created. There is a VM with warning. It says I exceeds quota.
quota

2. Go to "IAM & admin" | "Quotas". You see have 8 CPU limitation for the location.
quota

Summary

The way it auto scale is similar to Azure, such as creating seed image and set auto scale, with load balancer in front. However there are several differences how each cloud platform treats VMs.

As a developer, I feel Azure gives me better documentation, but GCP gives me better experience to configure scaling environment especially when using custom image.

There are tons of other features I may need to look at, but I move on to different technology from next article. Either function or container.

Reference

Creating a Windows Image
Autoscaling Groups of Instances

Top comments (0)