node.jsgoogle-compute-enginegoogle-managed-vm

GCE managed VM: how to configure the number and location of instances? (nodejs)


Okay so I am testing a hello world application with node.js and gce vm instance.

This is the tutorial I followed: https://cloud.google.com/nodejs/getting-started/hello-world

When created the app following the tutorial, it created 20 vm instances automatically.

My questions are:

  1. Is it normal to have gce to create 20 instances? Will I be charged 20 small instances as it automatically created the 20 instances? (I was just thinking about testing on the MEAN stack, so should it just create the micro instances?)

  2. How would I configure to use different instances? Like I want to create a micro instance in a different area automatically with maybe around 5 maximum for testing.

Any help would be appreciated. and sorry for being newbie.


Solution

  • Yikes! It's not supposed to go straight to 20 instances. The autoscaler is supposed to ramp up the number of instances based on load. I would take a look at the 'versions' list in the cloud developers console, and make sure you don't have instances sitting around. Sometimes old deployed versions stick around, leaving you with a bunch of abandoned VMs.

    On configuring scaling - you want this doc: https://cloud.google.com/appengine/docs/flexible/nodejs/configuring-your-app-with-app-yaml

    You can use manual scaling, which sets a static number of instances by putting this in your app.yaml:

    manual_scaling:
      instances: 5
    

    Or you can change the range of the instance count (it's 2-20 by default):

    automatic_scaling:
      min_num_instances: 5
      max_num_instances: 20
    

    You can control the resources used in the VM like this:

    resources:
      cpu: .5
      memory_gb: 1.3
      disk_size_gb: 10
    

    Hope this all helps!