I would like to know if its possible to increase the CPU/memory of the instance on Google Compute Engine? I am currently running a small instance (g1-small) and I would like to move to n1-highmem-2.
Asked
Active
Viewed 1.9k times
18

Misha Brukman
- 12,938
- 4
- 61
- 78

Piyush Chitkara
- 305
- 3
- 5
- 8
-
Duplicate question; see [this answer](http://stackoverflow.com/a/31329034/3618671) on another question. – Misha Brukman Jul 10 '15 at 18:42
-
If the reader is trying to resize sda1, as I was, [this beautiful post](https://www.cloudkb.net/increase-root-volume-size-in-google-cloud-instances/) solved all my problems (date: April 2019) – Nathan majicvr.com Apr 12 '19 at 15:30
4 Answers
35
Now it's possible: https://cloud.google.com/compute/docs/instances/changing-machine-type-of-stopped-instance
- Go to the VM Instances page.
- In the Name column, click the name of the instance that you want to change the machine type for.
- Click the Stop button to stop the instance, if you have not stopped it yet.
- After the instance stops (this may take couple minutes), click the Edit button at the top of the page.

AI Mechanic
- 631
- 7
- 8
2
This is not currently possible on Google Cloud Platform. For now, you can shut down your instance, and create a new instance with the persistent disk of the older instance attached as described in this StackOverflow answer.

Community
- 1
- 1

Zachary Newman
- 20,014
- 4
- 39
- 37
1
Update- AS of the time of writing:
- One way is to stop the instance, get to edit mode and configure machine to new configuration. Once done, you would need to start and it will come back up with latest config.
- The easiest way is to go to VM instances section and you should be able to see "increase perf" in recommendation section of the VM listings. You can select from there itself with one click and it will be restarted with the selected config.

Aman Chhabra
- 607
- 1
- 8
- 21
0
Call this Python function:
gcpChangeMachineType('project-id', 'us-west1-b', 'youInsanceName', 'custom-96-638976')
Put this in the same Python File:
def gcpChangeMachineType(project, zone, instance_name, newType):
import googleapiclient.discovery
compute = googleapiclient.discovery.build('compute', 'v1')
instances = compute.instances()
instances.stop(project=project, zone=zone, instance=instance_name).execute()
instances.setMachineType(project=project, zone=zone, instance=instance_name, body={'machineType':'zones/{zone}/machineTypes/{newType}'.format(zone=zone, newType=newType)}).execute()
instances.start(project=project ,zone=zone, instance=instance_name).execute()
return(instances.get(project=project ,zone=zone, instance=instance_name).execute())
Other possibles machines:
- f1-micro # 1cpu 640MB
- n1-standard-1
- custom-1-6656
- custom-2-13312
- custom-4-26624
- custom-10-66560
- custom-12-79872
- custom-96-638976

Andreas
- 1