> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nebius.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Preemptible virtual machines

*Preemptible VMs*, also known as spot VMs or spot instances, are virtual machines that Compute may stop at any time. This can happen, for example, when the system needs resources to launch a regular VM in the same region, or if the current spot price exceeds the maximum price set in the pricing policy associated with the preemptible VM.

Compute sends a `SIGTERM` signal 60 seconds before stopping the VM. If your system does not respond in time, Compute sends a `SIGKILL` signal to force shutdown.

Compute preserves all data on the volumes attached to a stopped preemptible VM. It does not preserve dynamic resources, such as dynamic public IP addresses.

Preemptible VMs can help reduce computing costs for workloads that tolerate interruptions, but they don't provide guaranteed availability. Preemptible VMs are charged at the current [spot price](/signup-billing/pricing-policy). To set the maximum spot price at which your preemptible VMs can start and continue running, use a [pricing policy](/signup-billing/manage-pricing-policy). To run at the current spot price without setting a maximum, choose **Follow spot price**.

You can create a preemptible VM, but you cannot change the type of an existing VM—either from regular to preemptible or from preemptible to regular.

## Supported platforms

You can run preemptible VMs on all [VM platforms with GPUs](/compute/virtual-machines/types).

To get an up-to-date list of platforms, run the `nebius compute platform list` [command](/cli/reference/compute/platform/list). The platforms available for preemptible VMs are marked as `allowed_for_preemptibles: true`.

## Prerequisites

If you use the web console, you don't need to complete any prerequisites.

<Tabs group="interfaces">
  <Tab title="CLI">
    [Install and configure](/cli/install) the Nebius AI Cloud CLI.
  </Tab>

  <Tab title="Terraform">
    [Install and configure](/terraform-provider/install) the Nebius AI Cloud provider for Terraform.
  </Tab>

  <Tab title="Go SDK">
    [Install and initialize the Nebius SDK for Go](/sdk/go/install-auth).
  </Tab>

  <Tab title="Python SDK">
    [Install and initialize the Nebius SDK for Python](/sdk/python/install-auth).
  </Tab>

  <Tab title="JavaScript SDK">
    [Install and initialize the Nebius SDK for JavaScript](/sdk/javascript/install-auth).
  </Tab>
</Tabs>

## How to create a preemptible VM

When you create a preemptible VM, configure one of the [spot pricing](/signup-billing/pricing-policy) settings. You can select a pricing policy to set the maximum price, or follow the spot price to have the VM run at the current spot price.

<Tabs group="interfaces">
  <Tab title="Web console">
    1. In the sidebar, go to <Icon icon="https://mintcdn.com/nebius-ai-cloud/rOlLZ_MFvrheaI-h/_assets/sidebar/compute.svg?fit=max&auto=format&n=rOlLZ_MFvrheaI-h&q=85&s=8d3eda9b92f5a626a81d01268852f482" width="16" height="16" data-path="_assets/sidebar/compute.svg" /> **Compute** → **Virtual machines**.
    2. Click **Create resource** → **Virtual machine**.
    3. If you have [capacity block groups](/overview/limits/capacity-block-groups), on the **General** step, select **Pay-as-you-go VM**. If you do not have capacity block groups, the wizard skips the **General** step and opens **Compute** instead.
    4. On the **Compute** step, select **With GPUs** or **Without GPUs**, set the VM type to **Preemptible** and select a [platform and preset](/compute/virtual-machines/types).
    5. In **Max price**, select or create a [pricing policy](/signup-billing/manage-pricing-policy), or choose **Follow spot price**.

       For more information about the full wizard, see [How to create a virtual machine](/compute/virtual-machines/manage#create-a-vm).
  </Tab>

  <Tab title="CLI">
    When [creating a VM](/compute/virtual-machines/manage):

    * Select a [platform that supports preemptible VMs](#supported-platforms).

    * Add one of the following spot pricing parameters:

      * `--spot-pricing-policy-id <pricing_policy_ID>`: Select a pricing policy that sets the maximum spot price. For information on how to get a pricing policy ID or create a new policy, see [Managing pricing policies](/signup-billing/manage-pricing-policy).
      * `--follows-spot-price`: Accept the current spot price without setting a maximum spot price.

    * Add the following parameters to the `nebius compute instance create` command:

      ```bash theme={null}
      nebius compute instance create \
        ... \
        --spot-pricing-policy-id <pricing_policy_ID> \
        --recovery-policy fail \
        --preemptible-on-preemption stop
      ```

      In this configuration, the following values are specified:

      * `recovery_policy` defines what Compute does with a VM after it's preempted or fails. Preemptible VMs support only the `FAIL` value, which stops the VM. They do not support the `RECOVER` value, which tries to restart the VM. Setting `RECOVER` for a preemptible VM results in an error.
      * `on_preemption` specifies what happens when the VM is preempted. The only supported value is `STOP`: Compute stops the VM without deleting or restarting it.

    For details about the <code>nebius compute instance create</code> command, see the [Nebius AI Cloud CLI reference](/cli/reference/compute/instance/create).
  </Tab>

  <Tab title="Terraform">
    When creating a VM, select a [platform that supports preemptible VMs](#supported-platforms) and set the following parameters in the VM configuration:

    ```hcl theme={null}
    resource "nebius_compute_v1_instance" "instance" {
      ...
      recovery_policy = "FAIL"
      preemptible     = {
        on_preemption = "STOP"
      }
      spot_pricing_policy = {
        id = "<pricing_policy_ID>"
      }
      ...
    }
    ```

    In this configuration, the following values are specified:

    * `recovery_policy` defines what Compute does with a VM after it's preempted or fails. Preemptible VMs support only the `FAIL` value, which stops the VM. They do not support the `RECOVER` value, which tries to restart the VM. Setting `RECOVER` for a preemptible VM results in an error.
    * `on_preemption` specifies what happens when the VM is preempted. The only supported value is `STOP`: Compute stops the VM without deleting or restarting it.

    - `spot_pricing_policy.id` selects a pricing policy that sets the maximum price. To accept the current spot price without setting a maximum price, use `follows_spot_price = {}` instead of `spot_pricing_policy`.

    For details about the <code>nebius\_compute\_v1\_instance</code> Terraform resource, see the [provider reference](/terraform-provider/reference/resources/compute_v1_instance).
  </Tab>

  <Tab title="Go SDK">
    When [creating a VM](/compute/virtual-machines/manage):

    * Select a [platform that supports preemptible VMs](#supported-platforms).
    * Set the preemptible VM parameters in the code:

      ```go theme={null}
      resources := &compute.ResourcesSpec{
          Platform: "gpu-l40s-a",
          Size: &compute.ResourcesSpec_Preset{
              Preset: "1gpu-24vcpu-96gb",
          },
      }
      bootDisk := &compute.AttachedDiskSpec{
          AttachMode: compute.AttachedDiskSpec_READ_WRITE,
          Type: &compute.AttachedDiskSpec_ExistingDisk{
              ExistingDisk: &compute.ExistingDisk{
                  Id: bootDiskID,
              },
          },
      }
      networkInterface := &compute.NetworkInterfaceSpec{
          Name:            "eth0",
          SubnetId:        subnetID,
          IpAddress:       &compute.IPAddress{},
          PublicIpAddress: &compute.PublicIPAddress{},
      }
      instanceSpec := &compute.InstanceSpec{
          Resources:         resources,
          BootDisk:          bootDisk,
          NetworkInterfaces: []*compute.NetworkInterfaceSpec{
              networkInterface,
          },
          RecoveryPolicy: compute.InstanceRecoveryPolicy_FAIL,
          Preemptible: &compute.PreemptibleSpec{
              OnPreemption: compute.PreemptibleSpec_STOP,
          },
      }
      preemptibleOperation, err := sdk.Services().Compute().V1().
          Instance().Create(
              ctx,
              &compute.CreateInstanceRequest{
                  Metadata: &common.ResourceMetadata{
                      Name: "preemptible-instance",
                  },
                  Spec: instanceSpec,
              },
          )
      if err != nil {
          return err
      }
      if _, err = preemptibleOperation.Wait(ctx); err != nil {
          return err
      }
      ```

      In this configuration, the following values are specified:

      * `RecoveryPolicy` defines what Compute does with a VM after it's preempted or fails. Preemptible VMs support only the `FAIL` value, which stops the VM. They do not support the `RECOVER` value, which tries to restart the VM. Setting `RECOVER` for a preemptible VM results in an error.
      * `OnPreemption` specifies what happens when the VM is preempted. The only supported value is `STOP`: Compute stops the VM without deleting or restarting it.
  </Tab>

  <Tab title="Python SDK">
    When [creating a VM](/compute/virtual-machines/manage):

    * Select a [platform that supports preemptible VMs](#supported-platforms).
    * Set the preemptible VM parameters in the code:

      ```python theme={null}
      instance_service = InstanceServiceClient(sdk)
      preemptible_operation = await instance_service.create(
          CreateInstanceRequest(
              metadata=ResourceMetadata(
                  name="preemptible-instance",
              ),
              spec=InstanceSpec(
                  resources=ResourcesSpec(
                      platform="gpu-l40s-a",
                      preset="1gpu-24vcpu-96gb",
                  ),
                  boot_disk=AttachedDiskSpec(
                      attach_mode=(
                          AttachedDiskSpec.AttachMode.READ_WRITE
                      ),
                      existing_disk=ExistingDisk(id=boot_disk_id),
                  ),
                  network_interfaces=[
                      NetworkInterfaceSpec(
                          name="eth0",
                          subnet_id=subnet_id,
                          ip_address=IPAddress(),
                          public_ip_address=PublicIPAddress(),
                      ),
                  ],
                  recovery_policy=InstanceRecoveryPolicy.FAIL,
                  preemptible=PreemptibleSpec(
                      on_preemption=(
                          PreemptibleSpec.PreemptionPolicy.STOP
                      ),
                  ),
              ),
          ),
      )
      await preemptible_operation.wait()
      ```

      In this configuration, the following values are specified:

      * `recovery_policy` defines what Compute does with a VM after it's preempted or fails. Preemptible VMs support only the `FAIL` value, which stops the VM. They do not support the `RECOVER` value, which tries to restart the VM. Setting `RECOVER` for a preemptible VM results in an error.
      * `on_preemption` specifies what happens when the VM is preempted. The only supported value is `STOP`: Compute stops the VM without deleting or restarting it.
  </Tab>

  <Tab title="JavaScript SDK">
    When [creating a VM](/compute/virtual-machines/manage):

    * Select a [platform that supports preemptible VMs](#supported-platforms).
    * Set the preemptible VM parameters in the code:

      ```ts theme={null}
      const instanceService = new InstanceService(sdk);
      const preemptibleOperation = await instanceService.create(
        CreateInstanceRequest.create({
          metadata: ResourceMetadata.create({
            name: "preemptible-instance",
          }),
          spec: InstanceSpec.create({
            resources: ResourcesSpec.create({
              platform: "gpu-l40s-a",
              size: {
                $case: "preset",
                preset: "1gpu-24vcpu-96gb",
              },
            }),
            bootDisk: AttachedDiskSpec.create({
              attachMode:
                AttachedDiskSpec_AttachMode.READ_WRITE,
              type: {
                $case: "existingDisk",
                existingDisk: ExistingDisk.create({
                  id: bootDiskId,
                }),
              },
            }),
            networkInterfaces: [
              NetworkInterfaceSpec.create({
                name: "eth0",
                subnetId,
                ipAddress: IPAddress.create({}),
                publicIpAddress: PublicIPAddress.create({}),
              }),
            ],
            recoveryPolicy: InstanceRecoveryPolicy.FAIL,
            preemptible: PreemptibleSpec.create({
              onPreemption:
                PreemptibleSpec_PreemptionPolicy.STOP,
            }),
          }),
        }),
      ).result;
      await preemptibleOperation.wait();
      ```

      In this configuration, the following values are specified:

      * `recoveryPolicy` defines what Compute does with a VM after it's preempted or fails. Preemptible VMs support only the `FAIL` value, which stops the VM. They do not support the `RECOVER` value, which tries to restart the VM. Setting `RECOVER` for a preemptible VM results in an error.
      * `onPreemption` specifies what happens when the VM is preempted. The only supported value is `STOP`: Compute stops the VM without deleting or restarting it.
  </Tab>
</Tabs>

<Tip>
  A dynamic IP address is released when a preemptible VM stops. To keep your workload stable, consider using a static IP address instead.
</Tip>

## How to continue working with a stopped preemptible VM

When Compute stops a preemptible VM, it preserves all data on the attached volumes. To resume work, [start the VM](/compute/virtual-machines/stop-start) again. If you used a dynamic IP address, update all systems that depended on the old IP address.

If the VM uses local SSD disks, use them with caution. Local SSD disks are ephemeral, meaning any data stored on them will be lost when the preemptible VM stops.

You can also [create a regular VM](/compute/virtual-machines/manage) with the same attached volumes.
