Suspend or resume a Compute Engine instance

This document explains how to suspend or resume Compute Engine instances. To learn more about suspending, stopping, or resetting instances, see Suspend, stop, or reset Compute Engine instances.

If you want to keep your Compute Engine instance around, but you don't want to incur charges for it when the instance isn't in use, then you can suspend the instance. Suspending an instance preserves the instance and migrates the contents of the instance's memory to storage. After resuming the instance, Compute Engine migrates the instance's memory from storage back to the instance, and the instance starts running again.

Suspending a Compute Engine instance is useful for the following:

  • Development and test environments that are not being fully used during off periods, such as during evenings or weekends, and that you want to maintain for costs saving or faster initialization than creating new instances.

  • Applications that require a long period of initialization after the instance has finished booting, but before the application is ready to service its first request, such as virtual developer workstations or complex Java applications.

Limitations

When you suspend a compute instance, the following limitations apply:

  • You can only suspend an instance if the guest OS supports it. For more information, see Operating system details.

  • You can only suspend an instance that uses the following OS images if you configure their OS, as described in this document:

    • Debian 8 or 9

    • Any Windows OS

  • You can suspend an instance for only up to 60 days before Compute Engine automatically transitions its state to TERMINATED.

  • You can suspend Spot VMs or preemptible instances—however, if Compute Engine preempts the instance before the suspend operation completes, Compute Engine ends the suspend operation and preempts the instance.

  • You can't suspend instances by using the standard processes that are built into their guest environment. Commands such as systemctl suspend in Ubuntu 16.04 or later aren't supported. If called, then Compute Engine ignores the in-guest signal.

  • You can't suspend the following types of instances:

    • Bare metal instances.

    • Confidential VMs.

    • Instances that have GPUs or TPUs attached.

    • Instances that have more than 208 GB of memory.

    • Instances that have CSEK-protected (Deprecated) disks attached.

Before you begin

  • Verify that your project has sufficient Persistent disk standard (GB) quota in the region where the instance is located. When you suspend an instance, Compute Engine stores the instance's memory in persistent storage, which consumes the Persistent disk standard (GB) quota. This requirement applies to all instances, including instances that only have Google Cloud Hyperdisk volumes attached. For more information, see Disk quotas and Troubleshoot insufficient disk quota.
  • If you haven't already, set up authentication. Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:

    Select the tab for how you plan to use the samples on this page:

    Console

    When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

    gcloud

    1. Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:

      gcloud init

      If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

    2. Set a default region and zone.

    Go

    To use the Go samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.

    1. Install the Google Cloud CLI.

  • If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  • If you're using a local shell, then create local authentication credentials for your user account:

    gcloud auth application-default login

    You don't need to do this if you're using Cloud Shell.

    If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.

  • For more information, see Set up authentication for a local development environment.