Preemptible VMs
Preemptible VMs are VM instances that may be forcibly stopped at any time. This can happen in these two cases:
- If 24 hours elapsed since the VM was started.
- If there is a lack of resources to launch a regular VM in the same availability zone. Such an event is usually unlikely, but this may vary day to day.
Preemptible VMs are available at a lower price than regular ones. However, they do not provide fault-tolerance.
You can create a preemptible VM or change the type of an existing one.
This will change pricing for the VM instance. For more information, see our pricing policy.
Limits
In addition to the fact that preemptible VMs can be forcibly stopped, they have the following limitations:
- If there are not enough resources in the specified availability zone to launch a preemptible VM, it will not get launched.
- Preemptible VMs are not subject to the SLA.
Working with preemptible VMs
When a preemptible VM is stopped, it is not deleted and all its data is saved. When you need the VM again, you can just start it.
With the Yandex Cloud Functions function, you can configure a stopped preemptible VM to run automatically.
Note
In Instance Groups, stopped VMs start automatically based on the autohealing feature.
With Instance Groups, preemptible VMs in the group get stopped after a random interval of 22 to 24 hours, rather than exactly after 24 hours. This helps avoid situations when all VMs in the group restart at the same time and stop handling the load of running applications.
Preemptible VM features
Stopping a VM
To stop a VM instance, Compute Cloud sends it the ACPI shutdown
In Linux, the ACPI shutdown signal is usually handled by systemdsystemd sends the SIGTERMsystemd forcibly terminates it using the SIGKILL
Tip
The default process termination timeout in systemd is 90 seconds. Therefore, to ensure termination of all processes within the 30-second window allocated by Compute Cloud, we recommend setting DefaultTimeoutStopSec=30s in the /etc/systemd/system.conf
VM lifetime
The lifetime of preemptible VMs is adjusted dynamically based on the current load of Yandex Cloud computing resources.
The maximum lifetime of preemptible VMs is 24 hours.
Preemptible VMs have no minimum lifetime. The system may even fail to create preemptible VMs, returning the not enough resources error, if an availability zone runs out of available configurations. In this case, you can:
- Try deploying a preemptible VM in a different availability zone.
- Modify the preemptible VM configuration. For example, if a VM with eight GPUs is unavailable, try creating four VMs with two GPUs each, as this is a more likely configuration for preemptible VMs.
- Use a non-preemptible VM.
Application fault tolerance
If you use preemptible VMs for batch processing
Tip
To make sure your application recovers correctly after VM termination, save intermediate computation results to Yandex Object Storage or file storage.
When to use preemptible VMs
Preemptible VMs are suitable for stateless, fault-tolerant workloads with flexible VM configuration requirements, for example:
- Big data processing.
- Building artifacts, software, or containers.
- CI/CD pipelines.
- Fault-tolerant HPC
. - Graphics rendering.
- ML model training that takes less than 24 hours.