How does preemptible virtual machines work?

Viewed 675

I've created a preemptible virtual instance in Google Compute Engine. And I understand the following warning:

Preemptible instances are available from a finite amount of Compute Engine resources, and might not always be available.

According to the docs, preemptible instances get terminated after 24 hours or before based on computing resources available. That said, I'm not very clear about what terminated means here.

In particular, do my instances and all the related resources connected to my instances (i.e GPU, Disk(100GB)) get deleted when my instances are terminated? (or) Do I have to manually remove everything so I won't get charged (or) Does terminate means that my instance will get shutdown (i.e stop) and when I start it again everything will be there (like my data in my Disk(100GB)). It wasn't very detailed in the docs.

2 Answers

When a preemptable instance is terminated, it is moved to the TERMINATED machine state, it is not deleted (nor are the affiliated resources) as documented here.

This is the relevant part of the documentation for preemptable instances:

Preempted instances still appear in your project, but you are not charged for the instance hours while it remains in a TERMINATED state. You can access and recover data from any persistent disks that are attached to the instance, but those disks still incur storage charges until you delete them. As with normal instances, persistent disks that are marked for auto-delete are deleted when you delete the preemptible instance.

Further down, there is docmentation related to GPUs that clarifies that the GPUs only exist for the life of the instance, so I would not expect that you would be charged for that when your instance is in the TERMINATED state.

You can restart your VM when it is in a Terminated state. It's very interesting when you create a Instance Group, (or a NodePool in K8S/GKE, which mean exactly the same thing).

When your VM is unhealthy, which is normal, because it is terminated, the Instance Group tries to start it again automatically. For not critical jobs, like CI worker, it's the perfect choice for reducing cost.

Related