Compute Engine instance lifecycle


This document explains the lifecycle of a Compute Engine instance, covering the various states it can go through from creation to deletion. To learn how to check the state of one or more instances, see the following:

By understanding the lifecycle of an instance, you can do the following more effectively:

  • Troubleshoot instance issues.

  • Manage instance resources.

  • Plan instance migrations.

Instance states

A compute instance can transition through different states as part of its lifecycle. When creating an instance, Compute Engine provisions resources to start it, after which the instance moves into staging and prepares for first boot. After the instance starts, it's considered running. A running instance can be repeatedly stopped and restarted, or suspended and resumed, until its deletion.

The following diagram shows the different states that Compute Engine can set an instance to:

A flowchart of each state a Compute Engine instance lifecycle can be set to.

The states shown in the preceding diagram are as follows:

  • PROVISIONING: in the first stage of an instance, Compute Engine allocates resources for the instance.

  • STAGING: Compute Engine is preparing the instance for first boot due to one of the following reasons:

    • Compute Engine is still creating and configuring the instance.

    • You, or a scheduled operation, have requested to restart or resume the instance.

    In this state, the instance isn't running yet.

  • RUNNING: Compute Engine is booting up the instance, or the instance is running. In this state, you can stop, suspend, or delete the instance. Additionally, Compute Engine can stop or delete the the instance for scheduled actions, or repair it if the instance is part of a managed instance group (MIG) and a hardware error occurs.

  • PENDING_STOP: the instance is gracefully shutting down. This shutdown process happens only if you've enabled graceful shutdown and you've requested to stop or delete the instance, or Compute Engine is doing so automatically for a scheduled stop or deletion. The instance state changes to STOPPING when one of the following happens:

    • You manually end the graceful shutdown.

    • The graceful shutdown period times out. If any tasks are still running, then Compute Engine forcefully stops them.

  • STOPPING: the instance is shutting down its guest OS, which happens in the following scenarios:

    • You, or a scheduled operation, have requested to stop or delete the instance.

    • A hardware error occurred.

    The shutdown time depends on the instance type; however, if the instance is stopping due to a hardware error, the shutdown time might vary. After Compute Engine shuts down the guest OS, it sets the instance state to TERMINATED, and then either completes the stop operation or deletes the instance and all attached resources.

  • TERMINATED: Compute Engine has completed the stop operation. The attached resources remain attached unless you detach them. In this state, the instance remains stopped until you restart or delete it.

  • REPAIRING: Compute Engine is repairing an instance that is part of a MIG. Compute Engine repairs an instance if it encounters an internal error or the instance's host server is unavailable due to maintenance. While an instance is in repair, the following happens:

    If Compute Engine successfully repairs the instance, then it returns the instance state to its original state before the repair operation began. This state can be STAGING, RUNNING, SUSPENDING, or STOPPING.

  • SUSPENDING: Compute Engine has started the suspend operation of the instance after you've requested to suspend it. In this state, you can only wait for the suspend operation to complete.

  • SUSPENDED: Compute Engine has completed the suspend operation. In this state, you can resume or delete the instance. If an instance remains in the SUSPENDED state for more than 60 days, then Compute Engine stops the instance and transitions its state to TERMINATED.

Hardware failure

Rarely, a compute instance might fail due to an unexpected outage, hardware error, or another system issue. Google recommends mitigating hardware failures by using persistent storage volumes, routinely backing up your data, and designing your system so that a single instance failure isn't catastrophic. For more information, see how to design robust systems.

If an instance fails, then Compute Engine automatically restarts the instance using the same boot disk, metadata, and instance settings. To modify the automatic restart behavior of an instance, see Set VM host maintenance policy.

What's next