Prajwal T
Prajwal T

Reputation: 75

Is there a way to increase the memory of GCP compute instance without stopping the VM?

I have a situation in which I have to increase the Memory of GCP compute instance which is running, and I have to increase the memory without turning it off. I have researched and I found that to increase the memory we have to stop the VM edit the memory and start the VM.

Kindly could someone guide me if there is any workaround to my problem.

Upvotes: 3

Views: 8335

Answers (2)

Jyothi Kiranmayi
Jyothi Kiranmayi

Reputation: 2533

As mentioned by @guillaume blaquiere, you will need to shutdown the VM instance to increase the memory.

To increase memory of the VM instance, you will need to change machine type. You can only change the machine type of a stopped VM. A VM is considered stopped only when the VM is in the TERMINATED state. You cannot change the machine type of a running VM.

Steps to increase memory of a VM instance:

$ gcloud compute instances stop <instance_name>
$ gcloud compute instances set-machine-type <VM_NAME> --machine-type <NEW_MACHINE_TYPE>
$ gcloud compute instances start <instance_name>

Refer Changing the machine type of a VM instance for information.

Upvotes: 1

PeteP
PeteP

Reputation: 621

If you're running a VM that needs 100% uptime then it should be load-balanced, or GCP only covers 99.5% uptime (up to 43.8 hours downtime a year).
Even with load-balancing GCP only promises 99.99% uptime, which gives up to 52 minutes a year downtime.
The only service Google promises 100% uptime for is DNS as far as I'm aware.

Having been in your position quite a few times I can say that the least painful solution is to schedule downtime to resize the instance.

Beyond that I recommend having an architect look at the infrastructure to see if load-balancing can be added to avoid this in future.

If you haven't already, you can try reducing memory usage on the VM or maybe increasing swap size.

Upvotes: 1

Related Questions