Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I hibernate a Google Compute Engine server?

I'd like to use a GCE server and VNC to run some desktop programs I've written. However, I'd like to not have the GCE server running all the time (to save money) and I'd like to have the setup of my VNC desktop persisted (to save time). It seems like the easiest way to accomplish this is to somehow hibernate the GCE instance. Is there a way to do this either from a script or from the command line?

like image 434
Thomas Johnson Avatar asked Nov 04 '13 00:11

Thomas Johnson


People also ask

Does GCP charge for stopped instances?

A stopped instance does not incur charges, but all of the resources that are attached to the instance will still be charged. For example, you are charged for persistent disks and external IP addresses according to the price sheet, even if an instance is stopped.

What is the difference between Google App Engine and Google Compute Engine?

Google App Engine is a Platform as a Service (PaaS) solution that makes deployment easier. On the other hand, the Google Compute Engine is an Infrastructure as a Service (IaaS) tool.


2 Answers

The only currently supported technique that I'm aware of would be to use a bootable persistent disk, which outlives the virtual machine so you could delete and restart the VM with moderately quick (under 30s) startup time but I don't think that would meet your needs because unless your app has built-in, robust checkpoint/resume logic, you might not be able to pick up where you left off on the desktop.

Another way to approach this would be to use a lightweight container, like Docker, which has suspend/resume and checkpointing built into its design. You can't currently run Docker containers on Google Compute Engine but we're interested in exploring the potential of Docker on GCE so stay tuned.

Sounds like what you'd really like is a native suspend capability with near instantaneous resume and no or very low charge for VMs in the suspended state. I think that's an interesting idea - I've submittted an internal feature request to the Compute Engine engineering team for future consideration.

like image 160
Marc Cohen Avatar answered Nov 01 '22 17:11

Marc Cohen


Compute Engine has alpha support for suspending virtual machines. A quote from that documentation:

gcloud alpha compute instances suspend is used to suspend a Google Compute Engine virtual machine. Suspending a VM is the equivalent of sleep or standby mode: the guest receives an ACPI S3 suspend signal, after which all VM state is saved to temporary storage. An instance can only be suspended while it is in the RUNNING state. A suspended instance will be put in SUSPENDED state.

The command is not yet available in the Compute Engine web UI but can be invoked from the command line like:

gcloud alpha compute instances suspend my-vm
like image 30
mndrix Avatar answered Nov 01 '22 17:11

mndrix